stochastic_greedy_search: Greedy search function in the IV model space.

Description Usage Arguments Value Examples

View source: R/greedy_search.R

Description

At each greedy step, we explore the IV models in the neighbor set one by one. As soon as one has higher evidence than the current IV model, we greedily move to the better neighbor.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
stochastic_greedy_search(
  J,
  N,
  SS,
  sigma_G = NULL,
  sd_slab = 1,
  sd_spike = 0.01,
  init_model = NULL,
  get_neighbors = neighbor_IV_models,
  LA_function = safe_Laplace_approximation,
  ...
)

Arguments

J

Integer number of candidate instruments..

N

Integer number of observations.

SS

Numeric matrix containing first- and second-order statistics.

sigma_G

Numeric vector of genetic IV standard deviations.

sd_slab

Numeric scale parameter of slab component.

sd_spike

Numeric scale parameter of spike component.

init_model

Character vector describing starting IV model in search.

get_neighbors

Function to get neighbor IV models at every step.

LA_function

Function for computing the IV model Laplace approximation

...

Extra arguments to pass to Laplace approximation function.

Value

A list containing the optimum found with greedy search, the list of IV models visited and their approximations, and the number of visited models.

Examples

1
2
3
4
5
6
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)
stochastic_greedy_search(J, N, dat$SS, binomial_sigma_G(dat$SS), 1, 0.01)

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