View source: R/at_scale_em_algo_functs.R
run_glmeiv_random_init_simulatr | R Documentation |
Runs GLM-EIV using random initializations for the parameters. Currently, the function assumes that there is (at most) a single covariate term.
run_glmeiv_random_init_simulatr(
dat,
m_fam,
g_fam,
covariate_matrix,
m_offset,
g_offset,
alpha = 0.95,
n_em_rep = 15,
save_membership_probs_mult = 250,
pi_guess_range = c(1e-05, 0.03),
m_perturbation_guess_range = log(c(0.1, 1.5)),
g_perturbation_guess_range = log(c(0.5, 10)),
m_intercept_guess_range = log(c(1e-04, 0.1)),
g_intercept_guess_range = log(c(1e-04, 0.1)),
m_covariate_coefs_guess_range = log(c(0.25, 2)),
g_covariate_coefs_guess_range = log(c(0.25, 2)),
exponentiate_coefs = FALSE
)
dat |
a data frame containing columns m, g |
m_fam |
family describing m |
g_fam |
family describing g |
covariate_matrix |
the matrix of covariates; NULL if there are no covariates. |
m_offset |
offsets for m |
g_offset |
offsets for g |
alpha |
CIs returned at level (1-alpha)% |
n_em_rep |
number of EM replicates |
save_membership_probs_mult |
save membership probabilities at this multiple |
pi_guess_range |
range of values over which to sample pi |
m_perturbation_guess_range |
range of values over which to sample m_perturbation |
g_perturbation_guess_range |
range of values over which to sample g_perturbation |
m_intercept_guess_range |
range over which to sample m_intercept |
g_intercept_guess_range |
range over which to sample g_intercept |
m_covariate_coefs_guess_range |
range over which to sample m_covariate_coefs |
g_covariate_coefs_guess_range |
range over which to sample g_covariate_coefs |
exponentiate_coefs |
(boolean) should the estimated coefficients (and CIs) be exponentiated? |
a fitted GLM-EIV object
# A simpler Gaussian example
m_fam <- g_fam <- gaussian() %>% augment_family_object()
n <- 20000
B <- 2
pi <- 0.05
m_intercept <- 1
m_perturbation <- -2
g_intercept <- -1
g_perturbation <- 2
m_offset <- g_offset <- NULL
covariate_matrix <- data.frame(batch = rbinom(n = n, size = 1, prob = 0.5))
m_covariate_coefs <- g_covariate_coefs <- 0.5
dat <- generate_full_data(m_fam = m_fam, m_intercept = m_intercept,
m_perturbation = m_perturbation, g_fam = g_fam, g_intercept = g_intercept,
g_perturbation = g_perturbation, pi = pi, n = n, B = B,
covariate_matrix = covariate_matrix, m_covariate_coefs = m_covariate_coefs,
g_covariate_coefs = g_covariate_coefs, m_offset = m_offset, g_offset = g_offset)[[1]]
fit <- run_glmeiv_random_init_simulatr(dat = dat, m_fam = m_fam, g_fam = g_fam,
covariate_matrix = NULL, m_offset = NULL, g_offset = NULL)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.