Skip to content

Commit

Permalink
version 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ingebogh authored and cran-robot committed Mar 14, 2022
1 parent 1a2176b commit 7222e6b
Show file tree
Hide file tree
Showing 25 changed files with 428 additions and 127 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
@@ -1,14 +1,14 @@
Package: makemyprior
Type: Package
Title: Intuitive Construction of Joint Priors for Variance Parameters
Version: 1.0.1
Version: 1.1.0
Authors@R: c(
person("Ingeborg Gullikstad", "Hem", email = "ingeborg.hem@ntnu.no", role = c("cre", "aut")),
person("Geir-Arne", "Fuglstad", role = "aut"),
person("Andrea", "Riebler", role = "aut") )
Description: Tool for easy prior construction and visualization. It helps to formulates joint prior distributions for variance parameters in latent Gaussian models. The resulting prior is robust and can be created in an intuitive way. A graphical user interface (GUI) can be used to choose the joint prior, where the user can click through the model and select priors. An extensive guide is available in the GUI. The package allows for direct inference with the specified model and prior. Using a hierarchical variance decomposition, we formulate a joint variance prior that takes the whole model structure into account. In this way, existing knowledge can intuitively be incorporated at the level it applies to. Alternatively, one can use independent variance priors for each model components in the latent Gaussian model.
License: GPL (>= 2)
Date: 2022-02-22
Date: 2022-03-14
Encoding: UTF-8
LazyData: true
Imports: ggplot2, Matrix, methods, shiny, shinyjs, shinyBS, visNetwork,
Expand All @@ -19,10 +19,10 @@ Additional_repositories: https://inla.r-inla-download.org/R/stable/
VignetteBuilder: knitr
RoxygenNote: 7.1.2
NeedsCompilation: no
Packaged: 2022-02-21 12:40:07 UTC; ingebogh
Packaged: 2022-03-14 10:49:22 UTC; ingebogh
Author: Ingeborg Gullikstad Hem [cre, aut],
Geir-Arne Fuglstad [aut],
Andrea Riebler [aut]
Maintainer: Ingeborg Gullikstad Hem <ingeborg.hem@ntnu.no>
Repository: CRAN
Date/Publication: 2022-02-21 13:30:08 UTC
Date/Publication: 2022-03-14 14:20:02 UTC
46 changes: 24 additions & 22 deletions MD5
@@ -1,14 +1,14 @@
2ac25e0ca90eb8b8458753f25aabb02f *DESCRIPTION
aad1621c0b4648cb98b54bcd0ef431b0 *NAMESPACE
a4239368e5e3d53699bc6a3807d0020f *NEWS.md
7fa250e587f004032bfdf1d8fb78bf17 *DESCRIPTION
696a21842a923c23e18a07f2fe6ce795 *NAMESPACE
5f951df0bad8f4028be14562190075b1 *NEWS.md
0712b679191f1f4e5c32d8c8728a6b28 *R/custom_stan_code_functions.R
9142c515f1bb441529a67de535b02b32 *R/data.R
7b41818a1a132d8a69639c643628a69d *R/data.R
fb8118a8fbf828e60a26e28ccca8a2c1 *R/functions_both.R
c6c5557a8c1996c63ad66526240b8062 *R/functions_calculate_pc_prior.R
7acaa4333077f509b62ddaca5d49a484 *R/functions_for_server_shiny.R
1c0662c270f61602cb814461105871bc *R/functions_posterior_diagnostics.R
78729579db2cc69e5c0fe5d97ee34156 *R/functions_for_server_shiny.R
3cd45f7b2861f8f2888520827f78acdb *R/functions_posterior_diagnostics.R
f7d9875ee3d89a7c0f16f487a5086b42 *R/guide_modules.R
8a9cb6145cced850d2212e6831ca0053 *R/make_prior_object_functions.R
78bedd5bc2df27607ed3fc7fa6dcde8b *R/make_prior_object_functions.R
f2b8c2c545433f84f2fa9a8a3b3513f9 *R/modules.R
9847489e6d1e5f326f945119b56245c9 *R/pc_prior_functions.R
bbff300e1d4396a8857b2af894fef6ef *R/server.R
Expand All @@ -21,39 +21,41 @@ e1ce9c170db213728b7256841ca6d6af *data/neonatal_data.rda
25aaad97322a37661bbce15286b00d7a *data/wheat_data.rda
6284a9c32500b63743b14c505e9e2db4 *inst/doc/latin_square.R
b867067c4fc5505049dff8530c8c21c1 *inst/doc/latin_square.Rmd
3249777f8cebd5a8c09796dd1093b5ba *inst/doc/latin_square.html
5ab291d02d2383a1956b51aa7681fb67 *inst/doc/latin_square.html
f06caa598702def411205906b2ceb39c *inst/doc/make_prior.R
ce74fea6ce238678471e9ef569962f11 *inst/doc/make_prior.Rmd
8ad1839786b1b17a0ade9c636933cca2 *inst/doc/make_prior.html
75df23f8d274c8854063657e3dbaad8e *inst/doc/make_prior.html
c4367592886b0e77a62197fd405a2fd7 *inst/doc/neonatal_mortality.R
e1bfd6dcc318f96d57d022739238ac56 *inst/doc/neonatal_mortality.Rmd
800068dfd188a018cdc315e3e3dc164a *inst/doc/neonatal_mortality.html
de415a8b30a401a4ebbb2c9fbe6be2e8 *inst/doc/neonatal_mortality.html
f096eb129319edf8d347a286cc6ddcf3 *inst/doc/wheat_breeding.R
3c695254f66b60fcfc91731e5a060f4d *inst/doc/wheat_breeding.Rmd
983b386c2d6cea0565a46c66214bd383 *inst/doc/wheat_breeding.html
c4052bf1b5a287631dd4244547fe974a *inst/doc/wheat_breeding.html
15b48dd6eef6e477ec33324eeba49d18 *inst/full_file.stan
43689165b956214527b58651142b9707 *inst/include/jacobian_function_general.stan
39ce1cd35ee972a86488627b46ebbc20 *inst/include/latent_models.stan
92f6d237206afe44b53ce46ab0584b7c *inst/include/variance_priors.stan
6559fc7d25fa643ad3eec5d7663117d3 *inst/neonatal.graph
b2b6e1cf3c994cdd57df2e6afd4ecf26 *man/compile_stan.Rd
11f6715e14584bedb8297ff86627194e *man/compile_stan.Rd
e1e44beb3cd9f9f6dbfbae1138cfc596 *man/create_stan_file.Rd
0c9b6473b40b70d75829f366dd4abb34 *man/eval_pc_prior.Rd
5486a1f6d968f91182bcb18fc2668837 *man/eval_joint_prior.Rd
32f0fcd9af8189cde980e9e9028f4555 *man/eval_pc_prior.Rd
e0c06015c694415a00d3bce50b993ee9 *man/expit.Rd
a05ded7b03a9bebe2ec335f475d5bf96 *man/extract_posterior_effect.Rd
d3598a6877c616e4624f6ee877816589 *man/extract_posterior_parameter.Rd
43a7a2ebe106321fa77d08bf5b8b183d *man/extract_posterior_effect.Rd
a652ba6b5038d22d46a307769bb26f25 *man/extract_posterior_parameter.Rd
d8e078e2222744cafc4be055665b0476 *man/find_pc_prior_param.Rd
0f7cf9b832f1cf74785eac6ed7b6efc6 *man/inference_inla.Rd
c9058250e84ccf4fa4913c4397dcb92a *man/inference_stan.Rd
281c5aa12e7fa84c64c44741274b94ae *man/latin_data.Rd
63034b6d3f2fa3513bea9e27e43719a4 *man/get_parameter_order.Rd
3573ee583b3fee2c6f2e92ddf58d3480 *man/inference_inla.Rd
c4d2a3e45991640168b8b78f6268b59d *man/inference_stan.Rd
986eb9623be700556d10cd161b71e00c *man/latin_data.Rd
b4c88eae4440963943a21bd7f76d49dd *man/logit.Rd
03c50fda00c0363b9229e80c44fcea93 *man/make_prior.Rd
14bd8a13b861588b0d1bbffbca09594d *man/makemyprior_example_model.Rd
e5bbebd81bde6fee4dd227920c8fc4ce *man/makemyprior_example_model.Rd
32b8cabec1a09144fb04d0bf9131744d *man/makemyprior_gui.Rd
f7fb30a87db85104a0584d0b38948d22 *man/makemyprior_models.Rd
dd0ed517a8854befa67d070d260065de *man/makemyprior_plotting.Rd
c4191f0ab0fdadc77ba7af4d405fd54d *man/makemyprior_plotting.Rd
1a4f2dbf437ed90b0f6cb8ba5bdf0da5 *man/mc.Rd
71423a7d3051781d831b4daf5871abc5 *man/neonatal_data.Rd
b6d557168440659b6bfd96272761e7cd *man/neonatal_data.Rd
2ce142c20a10fc7ef7380aa44050a317 *man/plot.mmp_prior.Rd
46da07d51c22a5237b6f103005725e2e *man/plot_marginal_prior.Rd
56f4200ecc1e359962fce09dda515cc5 *man/plot_posterior_fixed.Rd
Expand All @@ -66,7 +68,7 @@ da25e6682285bea8781d17fbe23d3227 *man/plot_tree_structure.Rd
bbb4a599022a0026bd2f2d4c664fb60d *man/scale_precmat.Rd
3ab508e91e89aa31d188dcfef749c95d *man/summary.mmp_prior.Rd
ff20f38edea6ac39cb451ed0ff637e77 *man/typical_variance.Rd
890d27705adf84db235fffda8309db9c *man/wheat_data.Rd
71908178abef2f32003012b3a34e8801 *man/wheat_data.Rd
b867067c4fc5505049dff8530c8c21c1 *vignettes/latin_square.Rmd
ce74fea6ce238678471e9ef569962f11 *vignettes/make_prior.Rmd
e1bfd6dcc318f96d57d022739238ac56 *vignettes/neonatal_mortality.Rmd
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Expand Up @@ -11,14 +11,17 @@ S3method(summary,mmp_prior)
S3method(summary,mmp_stan)
export(compile_stan)
export(create_stan_file)
export(eval_joint_prior)
export(eval_pc_prior)
export(expit)
export(extract_posterior_effect)
export(extract_posterior_parameter)
export(find_pc_prior_param)
export(get_parameter_order)
export(inference_inla)
export(inference_stan)
export(logit)
export(make_eval_prior_data)
export(make_prior)
export(makemyprior_example_model)
export(makemyprior_gui)
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
@@ -1,5 +1,10 @@


# makemyprior 1.1.0

Added functionality to generalize the package, through simple usage of the joint HD prior.


# makemyprior 1.0.1

Minor bug fixes.
Expand Down
6 changes: 3 additions & 3 deletions R/data.R
Expand Up @@ -14,7 +14,6 @@
#' \dontrun{
#'
#' vignette("wheat_breeding", package = "makemyprior")
#'
#' }
#'
#' if (interactive() && requireNamespace("rstan")){
Expand Down Expand Up @@ -47,6 +46,7 @@
#' }
#'
#' \dontrun{
#'
#' posterior <- inference_stan(prior, iter = 150, warmup = 50,
#' chains = 1, seed = 1)
#'
Expand Down Expand Up @@ -76,7 +76,6 @@
#' \dontrun{
#'
#' vignette("latin_square", package = "makemyprior")
#'
#' }
#'
#' if (interactive() && requireNamespace("rstan")){
Expand All @@ -103,6 +102,7 @@
#' }
#'
#' \dontrun{
#'
#' posterior <- inference_stan(prior, iter = 15000, warmup = 5000,
#' seed = 1, init = "0", chains = 1)
#'
Expand Down Expand Up @@ -132,7 +132,6 @@
#' \dontrun{
#'
#' vignette("neonatal_mortaily", package = "makemyprior")
#'
#' }
#'
#' if (interactive() && requireNamespace("rstan")){
Expand Down Expand Up @@ -164,6 +163,7 @@
#' }
#'
#' \dontrun{
#'
#' posterior <- inference_stan(prior, iter = 15000, warmup = 5000,
#' seed = 1, init = "0", chains = 1)
#'
Expand Down
4 changes: 2 additions & 2 deletions R/functions_for_server_shiny.R
Expand Up @@ -1377,7 +1377,7 @@ get_prior_expr <- function(prior_data, node_data, param = c("cw", "totvar", "wei
if (param == "cw"){

if (prior_data$prior == "pc0") {
param_name <- sprintf("\\sigma_{%s}", gsub("_", "\\_", prior_data$name, fixed = TRUE), "}")
param_name <- sprintf("\\sigma_{%s}", gsub("_", "\\_", prior_data$name, fixed = TRUE)) #, "}")
prior_expr <- sprintf("\\mathrm{PC}_{\\mathrm{0}}(%s, %s)", prior_data$param[1], prior_data$param[2])
} else if (prior_data$prior == "jeffreys"){
param_name <- sprintf("\\sigma_{%s}^2", gsub("_", "\\_", prior_data$name, fixed = TRUE))
Expand All @@ -1386,7 +1386,7 @@ get_prior_expr <- function(prior_data, node_data, param = c("cw", "totvar", "wei
param_name <- sprintf("\\sigma_{%s}^2", gsub("_", "\\_", prior_data$name, fixed = TRUE))
prior_expr <- paste0("\\mathrm{InvGam}(", prior_data$param[1], ",", prior_data$param[2], ")")
} else if (prior_data$prior == "hc"){
param_name <- sprintf("\\sigma_{%s}", gsub("_", "\\_", prior_data$name, fixed = TRUE), "}")
param_name <- sprintf("\\sigma_{%s}", gsub("_", "\\_", prior_data$name, fixed = TRUE)) #, "}")
prior_expr <- paste0("\\mathrm{HC}(", prior_data$param[1], ")")
}

Expand Down
8 changes: 4 additions & 4 deletions R/functions_posterior_diagnostics.R
Expand Up @@ -796,9 +796,9 @@ plot_posterior_precision <- function(obj){

#' Extract the posterior of a random effect
#'
#' #' Extract the posterior of a random effect in the model for inference done with Stan
#' Extract the posterior of a random effect in the model for inference done with Stan
#' @param obj An object from \code{inference_stan}.
#' @param effname Name of the effect, same name as in the data.
#' @param effname Name of the random effect, same name as in the data.
#' @keywords posterior
#' @return Returns a matrix with the posterior samples of the chosen effect
#' @examples
Expand Down Expand Up @@ -837,7 +837,7 @@ extract_posterior_effect <- function(obj, effname){
#'
#' @param obj An object from \code{inference_stan}.
#' @param param Name of the variance parameter, which is the same as the name of the corresponding
#' fixed or random effect in the data. Intercept is denoted 'intercept'.
#' fixed or random effect in the data. Intercept is denoted 'intercept', and residual variance is denoted 'eps'.
#' @keywords posterior
#' @return Returns a vector with the posterior samples of the chosen parameter, on variance scale for
#' variances parameters and original (the common) scale for fixed effect coefficients
Expand Down Expand Up @@ -1192,7 +1192,7 @@ plot_marginal_prior <- function(x, obj, param, sd = FALSE){
#' @param param Which weight to plot, indicated using syntax shown when printing (do not need to include the
#' \code{w[..]} part to indicate that it is a variance proportion, but can be included). Print the prior object
#' to see syntax for each weight.
#' @param logitscale Return prior on logitscale? (default \code{FALSE}).
#' @param logitscale Is the input \code{x} on logit-scale? (default \code{FALSE}).
#' @return Returns density for the given variance proportion.
#' @examples
#' ex_prior <- makemyprior_example_model()
Expand Down

0 comments on commit 7222e6b

Please sign in to comment.