View source: R/STAR_frequentist.R
lm_star | R Documentation |
Compute the MLEs and log-likelihood for the STAR linear model. The regression coefficients are estimated using least squares within an EM algorithm.
lm_star(
formula,
data = NULL,
transformation = "np",
y_max = Inf,
sd_init = 10,
tol = 10^-10,
max_iters = 1000
)
formula |
an object of class " |
data |
an optional data frame, list or environment (or object coercible by as.data.frame to a data frame)
containing the variables in the model; like |
transformation |
transformation to use for the latent data; must be one of
|
y_max |
a fixed and known upper bound for all observations; default is |
sd_init |
add random noise for EM algorithm initialization scaled by |
tol |
tolerance for stopping the EM algorithm; default is 10^-10; |
max_iters |
maximum number of EM iterations before stopping; default is 1000 |
Standard function calls including
coefficients
, fitted
, and residuals
apply. Fitted values are the expectation
at the MLEs, and as such are not necessarily count-valued.
an object of class
"lmstar", which is a list with the following elements:
coefficients
the MLEs of the coefficients
fitted.values
the fitted values at the MLEs
g.hat
a function containing the (known or estimated) transformation
ginv.hat
a function containing the inverse of the transformation
sigma.hat
the MLE of the standard deviation
mu.hat
the MLE of the conditional mean (on the transformed scale)
z.hat
the estimated latent data (on the transformed scale) at the MLEs
residuals
the Dunn-Smyth residuals (randomized)
residuals_rep
the Dunn-Smyth residuals (randomized) for 10 replicates
logLik
the log-likelihood at the MLEs
logLik0
the log-likelihood at the MLEs for the *unrounded* initialization
lambda
the Box-Cox nonlinear parameter
and other parameters that (1) track the parameters across EM iterations and (2) record the model specifications
Infinite latent data values may occur when the transformed Gaussian model is highly inadequate. In that case, the function returns the *indices* of the data points with infinite latent values, which are significant outliers under the model. Deletion of these indices and re-running the model is one option, but care must be taken to ensure that (i) it is appropriate to treat these observations as outliers and (ii) the model is adequate for the remaining data points.
Kowal, D. R., & Wu, B. (2021). Semiparametric count data regression for selfâreported mental health. Biometrics. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1111/biom.13617")}
# Simulate data with count-valued response y:
sim_dat = simulate_nb_lm(n = 100, p = 3)
y = sim_dat$y; X = sim_dat$X
# Fit model
fit_em = lm_star(y~X)
# Fitted coefficients:
coef(fit_em)
# Fitted values:
y_hat = fitted(fit_em)
plot(y_hat, y);
# Residuals:
plot(residuals(fit_em))
qqnorm(residuals(fit_em)); qqline(residuals(fit_em))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.