countreg {lavacreg}R Documentation

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 formula (or one that can be coerced to that class): a symbolic description of the model to be fitted. The details of model specification are given under Details.

data

A data frame containing all variables specified in forml and/or indicators of the latent variables specified in lv (if applicable).

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., list(eta1 = c("z1", "z2", "z3")).

group

A group variable. If specified, the regression model specified in forml is estimated as multi-group model (i.e., within each group).

family

A character indicating the family of the generalized linear model to be estimated. At the moment, "poisson" (for Poisson regression; default) or "nbinom" (for negative binomial regression) are available.

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)



[Package lavacreg version 0.2-2 Index]