safe_Laplace_approximation: Routine for computing the Laplace approximation of the...

Description Usage Arguments Value Examples

View source: R/Laplace_approximation.R

Description

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.

Usage

 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"
)

Arguments

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?

Value

A list containing the Laplace approximation.

Examples

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)
)

igbucur/MASSIVE documentation built on Oct. 26, 2020, 1:26 a.m.