Description Usage Arguments Value Examples
View source: R/Laplace_approximation.R
Routine for computing the Laplace approximation of the MASSIVE posterior using smart initialization points to find all the conjectured optima. This 'safe' version provides a fail-safe in case no optima are found with the smart initialization, in which case the "guess" strategy is used instead.
1 2 3 4 5 6 7 8 9 10 11 12 | safe_Laplace_approximation(
J,
N,
SS,
sigma_G,
prior_sd,
post_fun = scaled_neg_log_posterior,
gr_fun = scaled_neg_log_gradient,
hess_fun = scaled_neg_log_hessian,
opt_fun = robust_find_optimum,
starting_points = "smart"
)
|
J |
Integer number of candidate instrumental variables. |
N |
Integer number of observations. |
SS |
Numeric matrix containing first- and second-order statistics. |
sigma_G |
Numeric vector of instrument standard deviations. |
prior_sd |
List of standard deviations for the parameter Gaussian priors. |
post_fun |
Function for computing the IV model posterior value. |
gr_fun |
Function for computing the IV model posterior gradient. |
hess_fun |
Function for computing the IV model posterior Hessian. |
opt_fun |
Function for finding the IV model posterior optima. |
starting_points |
Character vector indicating how to pick the starting points: "smart" or "guess" strategy? |
A list containing the Laplace approximation.
optima - List of optima found.
num_optima - Number of optima found on the posterior surface.
evidence - Numeric value of total approximation model evidence.
1 2 3 4 5 6 7 8 9 | J <- 5 # number of instruments
N <- 1000 # number of samples
parameters <- random_Gaussian_parameters(J)
EAF <- runif(J, 0.1, 0.9) # EAF random values
dat <- generate_data_MASSIVE_model(N, 2, EAF, parameters)
safe_Laplace_approximation(
J, N, dat$SS, binomial_sigma_G(dat$SS),
decode_IV_model(get_random_IV_model(J), 1, 0.01)
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.