star_CI: Compute asymptotic confidence intervals for STAR linear...

View source: R/source_EM.R

star_CIR Documentation

Compute asymptotic confidence intervals for STAR linear regression

Description

For a linear regression model within the STAR framework, compute (asymptotic) confidence intervals for a regression coefficient of interest. Confidence intervals are computed by inverting the likelihood ratio test and profiling the log-likelihood.

Usage

star_CI(
  y,
  X,
  j,
  level = 0.95,
  include_plot = TRUE,
  transformation = "np",
  y_max = Inf,
  sd_init = 10,
  tol = 10^-10,
  max_iters = 1000
)

Arguments

y

n x 1 vector of observed counts

X

n x p design matrix of predictors

j

the scalar column index for the desired confidence interval

level

confidence level; default is 0.95

include_plot

logical; if TRUE, include a plot of the profile likelihood

transformation

transformation to use for the latent data; must be one of

  • "identity" (identity transformation)

  • "log" (log transformation)

  • "sqrt" (square root transformation)

  • "np" (nonparametric transformation estimated from empirical CDF)

  • "pois" (transformation for moment-matched marginal Poisson CDF)

  • "neg-bin" (transformation for moment-matched marginal Negative Binomial CDF)

  • "box-cox" (box-cox transformation with learned parameter)

y_max

a fixed and known upper bound for all observations; default is Inf

sd_init

add random noise for initialization scaled by sd_init times the Gaussian MLE standard deviation

tol

tolerance for stopping the EM algorithm; default is 10^-10;

max_iters

maximum number of EM iterations before stopping; default is 1000

Value

the upper and lower endpoints of the confidence interval

Note

The design matrix X should include an intercept.

Examples

# Simulate data with count-valued response y:
sim_dat = simulate_nb_lm(n = 100, p = 2)
y = sim_dat$y; X = sim_dat$X

# Select a transformation:
transformation = 'np'

# Confidence interval for the intercept:
ci_beta_0 = star_CI(y = y, X = X,
                   j = 1,
                   transformation = transformation)
ci_beta_0

# Confidence interval for the slope:
ci_beta_1 = star_CI(y = y, X = X,
                   j = 2,
                   transformation = transformation)
ci_beta_1


drkowal/rSTAR documentation built on July 5, 2023, 2:18 p.m.