Type: | Package |
Title: | Latent Variable Count Regression Models |
Version: | 0.2-2 |
Date: | 2024-06-13 |
Description: | Estimation of a multi-group count regression models (i.e., Poisson, negative binomial) with latent covariates. This packages provides two extensions compared to ordinary count regression models based on a generalized linear model: First, measurement models for the predictors can be specified allowing to account for measurement error. Second, the count regression can be simultaneously estimated in multiple groups with stochastic group weights. The marginal maximum likelihood estimation is described in Kiefer & Mayer (2020) <doi:10.1080/00273171.2020.1751027>. |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
URL: | https://github.com/chkiefer/lavacreg |
BugReports: | https://github.com/chkiefer/lavacreg/issues |
LazyData: | true |
Depends: | R (≥ 3.5.0) |
Imports: | Rcpp (≥ 1.0.5), fastGHQuad, pracma, methods, stats, SparseGrid |
LinkingTo: | Rcpp, RcppArmadillo |
RoxygenNote: | 7.3.1 |
Suggests: | knitr, rmarkdown, testthat |
Encoding: | UTF-8 |
VignetteBuilder: | knitr |
NeedsCompilation: | yes |
Packaged: | 2024-06-13 07:37:16 UTC; ckiefer |
Author: | Christoph Kiefer |
Maintainer: | Christoph Kiefer <christoph.kiefer@uni-bielefeld.de> |
Repository: | CRAN |
Date/Publication: | 2024-06-13 13:50:02 UTC |
lavacreg: Latent Variable Count Regression Models
Description
Estimation of a multi-group count regression models (i.e., Poisson, negative binomial) with latent covariates. This packages provides two extensions compared to ordinary count regression models based on a generalized linear model: First, measurement models for the predictors can be specified allowing to account for measurement error. Second, the count regression can be simultaneously estimated in multiple groups with stochastic group weights. The marginal maximum likelihood estimation is described in Kiefer & Mayer (2020) doi:10.1080/00273171.2020.1751027.
Author(s)
Maintainer: Christoph Kiefer christoph.kiefer@uni-bielefeld.de (ORCID)
See Also
Useful links:
Fitting Count Regression Models with Latent Covariates
Description
This function is the main function of the package and can be used to estimate latent variable count regression models in one or multiple group(s).
Usage
countreg(
forml,
data,
lv = NULL,
group = NULL,
family = "poisson",
silent = FALSE,
se = TRUE,
creg_options = NULL
)
Arguments
forml |
An object of class |
data |
A data frame containing all variables specified in |
lv |
A named list, where names of elements represent the names of the
latent variables and each element consists of a character vector containing
variable names of indicators for the respective latent variable, e.g.,
|
group |
A group variable. If specified, the regression model specified
in |
family |
A character indicating the family of the generalized linear
model to be estimated. At the moment, |
silent |
Logical. Should informations about the estimation process be suppressed? (Defaults to FALSE) |
se |
Logical. Should standard errors be computed? Defaults to TRUE. (Can take a while for complex models) |
creg_options |
optional list of additional options for the estimation procedure |
Value
An object of type lavacreg
. Use summary(object)
to
print results containing parameter estimates and their standard errors.
Examples
fit <- countreg(forml = "dv ~ z11", data = example01, family = "poisson")
summary(fit)
fit <- countreg(
forml = "dv ~ eta1 + z11 + z21",
lv = list(eta1 = c("z41", "z42", "z43")),
group = "treat",
data = example01,
family = "poisson"
)
summary(fit)
A first example dataset to illustrate the use of lavacreg
Description
A dataset containing 9 variables: a dependent variable dv, a group variable treat and 7 indicators for 3 latent covariates.
Usage
example01
Format
A data frame with 871 rows and 9 variables:
- dv
Count of correctly-answered items (dependent variable)
- treat
Treatment group variable, where
0
is control and2
is treatment- z11
First indicator of internal LoC
- z12
Second indicator of internal LoC
- z21
First indicator of external LoC
- z22
Second indicator of external LoC
- z41
First indicator of depression
- z42
Second indicator of depression
- z43
Third indicator of depression
Check for count variable
Description
Checks if the variable is a count variable
Usage
is_count(x, tol = .Machine$double.eps^0.5)
Arguments
x |
vector to be checked |
tol |
Tolerance |
Value
Function returns logical value indicating whether x can be considered a count variable or not.
Summary of a lavacreg object
Description
Exports the parameter table with parameter estimates and standard errors for an estimated latent variable count regression model.
Usage
## S4 method for signature 'lavacreg'
summary(object)
Arguments
object |
lavacreg object |
Value
Function prints the parameter table of an estimated model, which includes the parameter estimates and standard errors.