run_full_glmeiv_given_weights: Run full GLM-EIV given weights

View source: R/full_em_algo_functs.R

run_full_glmeiv_given_weightsR Documentation

Run full GLM-EIV given weights

Description

Runs the full GLM-EIV model given starting weights. Starting

Usage

run_full_glmeiv_given_weights(
  m,
  g,
  m_fam,
  g_fam,
  covariate_matrix,
  initial_Ti1s,
  m_offset,
  g_offset,
  prev_log_lik = -Inf,
  ep_tol = 1e-04,
  max_it = 15,
  use_mrna_modality = TRUE
)

Arguments

m

mRNA counts

g

gRNA counts

m_fam

family describing m

g_fam

family describing g

covariate_matrix

the matrix of covariates; NULL if there are no covariates.

initial_Ti1s

starting membership probabilities; these probabilities should be such that sum(initial_Ti1s)/length(initial_Ti1s) < 0.5.

m_offset

offsets for m

g_offset

offsets for g

prev_log_lik

optional starting log-likelihood value (useful if an E step has been called ahead of running this function).

ep_tol

(optional) EM convergence threshold

max_it

(optional) maximum number of EM iterations

Value

a fitted GLM-EIV object

Examples

m_fam <- g_fam <- augment_family_object(poisson())
n <- 5000
lib_size <- rpois(n = n, lambda = 5000)
m_offset <- g_offset <- log(lib_size)
pi <- 0.1
m_intercept <- log(0.05)
m_perturbation <- log(0.8)
g_intercept <- log(0.025)
g_perturbation <- log(1.2)
covariate_matrix <- data.frame(batch = rbinom(n = n, size = 1, prob = 0.5))
m_covariate_coefs <- log(0.9)
g_covariate_coefs <- log(1.1)
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 = 2,
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]]
m <- dat$m
g <- dat$g
initial_Ti1s <- runif(n)
fit <- run_full_glmeiv_given_weights(m, g, m_fam, g_fam, covariate_matrix,
initial_Ti1s, m_offset, g_offset)

timothy-barry/glmeiv documentation built on Jan. 30, 2024, 3:46 p.m.