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).

countreg(
  forml,
  lv = NULL,
  group = NULL,
  data,
  family,
  silent = FALSE,
  se = TRUE
)

Arguments

forml

an object of class for 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.

lv

Definition of the latent variables.

group

A group variable

data

a data frame

family

Poisson or negative binomial

silent

Should informations about the estimation process be suppressed?

se

Should standard errors be computed? (Can take a while for complex models)

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')
#> Fitting the model...done. Took: 0.3 s #> Computing standard errors...done. Took: 0.1 s
summary(fit)
#> #> #> --------------------- Group 1 --------------------- #> #> Regression: #> Estimate SE Est./SE p-value #> 1 2.759 0.0146 189 0 #> z11 -0.138 0.0081 -17 0 #> #> Means: #> Estimate SE Est./SE p-value #> z11 1.58 0.0418 37.8 0 #> #> Variances: #> Estimate SE Est./SE p-value #> z11 1.52 0.0729 20.9 0
# \donttest{ fit <- countreg(forml = 'dv ~ eta1 + z11 + z21', lv = list(eta1=c('z41', 'z42', 'z43')), group = 'treat', data = example01, family = 'poisson')
#> Computing starting values...done. Took: 5.8 s #> Fitting the model...done. Took: 42.8 s #> Computing standard errors...done. Took: 75.4 s
summary(fit)
#> #> #> --------------------- Group 1 --------------------- #> #> Regression: #> Estimate SE Est./SE p-value #> 1 2.3053 0.0845 27.30 0.00e+00 #> z11 -0.0987 0.0133 -7.45 9.66e-14 #> z21 0.1045 0.0175 5.97 2.31e-09 #> eta1 -0.0885 0.0151 -5.87 4.40e-09 #> #> Means: #> Estimate SE Est./SE p-value #> eta1 1.58 0.0798 19.8 0 #> z11 1.59 0.0626 25.5 0 #> z21 3.91 0.0471 83.0 0 #> #> Variances: #> Estimate SE Est./SE p-value #> eta1 1.91 0.198 9.64 0 #> z11 1.68 0.115 14.66 0 #> z21 0.95 0.065 14.62 0 #> #> Covariances: #> Estimate SE Est./SE p-value #> z11 ~~ z21 -0.503 0.0657 -7.66 1.91e-14 #> eta1 ~~ z11 0.467 0.0991 4.71 2.48e-06 #> eta1 ~~ z21 -0.270 0.0740 -3.65 2.66e-04 #> #> Measurement Model: #> Estimate SE Est./SE p-value #> z42 ~ 1 -0.0592 0.1110 -0.533 0.593694 #> eta1 =~ z42 1.2633 0.0546 23.120 0.000000 #> z43 ~ 1 -0.3978 0.1174 -3.389 0.000702 #> eta1 =~ z43 1.3290 0.0593 22.395 0.000000 #> z41 ~~ z41 1.5164 0.1335 11.358 0.000000 #> z42 ~~ z42 1.4506 0.1593 9.108 0.000000 #> z43 ~~ z43 1.4675 0.1671 8.784 0.000000 #> #> #> --------------------- Group 2 --------------------- #> #> Regression: #> Estimate SE Est./SE p-value #> 1 2.4704 0.0811 30.46 0.00e+00 #> z11 -0.0794 0.0132 -6.03 1.66e-09 #> z21 0.0860 0.0166 5.19 2.10e-07 #> eta1 -0.0312 0.0117 -2.68 7.46e-03 #> #> Means: #> Estimate SE Est./SE p-value #> eta1 1.64 0.0742 22.1 0 #> z11 1.55 0.0548 28.3 0 #> z21 4.00 0.0430 93.0 0 #> #> Variances: #> Estimate SE Est./SE p-value #> eta1 2.216 0.2450 9.05 0 #> z11 1.384 0.0949 14.58 0 #> z21 0.841 0.0572 14.70 0 #> #> Covariances: #> Estimate SE Est./SE p-value #> z11 ~~ z21 -0.480 0.0573 -8.38 0.00e+00 #> eta1 ~~ z11 0.662 0.1047 6.32 2.58e-10 #> eta1 ~~ z21 -0.403 0.0794 -5.08 3.71e-07 #> #> Measurement Model: #> Estimate SE Est./SE p-value #> z42 ~ 1 -0.0592 0.1110 -0.533 5.94e-01 #> eta1 =~ z42 1.2633 0.0546 23.120 0.00e+00 #> z43 ~ 1 -0.3978 0.1174 -3.389 7.02e-04 #> eta1 =~ z43 1.3290 0.0593 22.395 0.00e+00 #> z41 ~~ z41 1.3356 0.1178 11.336 0.00e+00 #> z42 ~~ z42 1.5372 0.1502 10.237 0.00e+00 #> z43 ~~ z43 1.0953 0.1718 6.376 1.82e-10
# }