drizopoulos / GLMMadaptive

GLMMs with adaptive Gaussian quadrature
https://drizopoulos.github.io/GLMMadaptive/
60 stars 14 forks source link

Using `update()` to fit a null-model #16

Closed strengejacke closed 5 years ago

strengejacke commented 5 years ago

When I use update() to re-fit a null-model, I get a warning, and the "null-model" seems to be the full-model.

Could you help me regarding how I can refit the model using update() to get a null-model?

fm1 <- mixed_model(y ~ sex * time, random = ~ 1 | id, data = DF, family = zi.poisson(), zi_fixed = ~ sex)
fm1_null <- update(fm1, "y ~ 1")
#> Warning in mixed_model(fixed = y ~ sex * time, random = ~1 | id, data =
#> DF, : unknown names in control: formula

summary(fm1_null)
#> 
#> Call:
#> mixed_model(fixed = y ~ sex * time, random = ~1 | id, data = DF, 
#>     family = zi.poisson(), zi_fixed = ~sex, formula = y ~ sex + 
#>         time + sex:time)
#> 
#> Data Descriptives:
#> Number of Observations: 800
#> Number of Groups: 100 
#> 
#> Model:
#>  family: zero-inflated poisson
#>  link: log 
#> 
#> Fit statistics:
#>    log.Lik      AIC     BIC
#>  -2223.937 4461.874 4480.11
#> 
#> Random effects covariance matrix:
#>                StdDev
#> (Intercept) 0.8272898
#> 
#> Fixed effects:
#>                Estimate Std.Err z-value p-value
#> (Intercept)      1.5276  0.1288 11.8605 < 1e-04
#> sexfemale        0.0174  0.1819  0.0954 0.92396
#> time            -0.0040  0.0159 -0.2542 0.79937
#> sexfemale:time   0.0004  0.0230  0.0188 0.98496
#> 
#> Zero-part coefficients:
#>             Estimate Std.Err z-value   p-value
#> (Intercept)  -1.2106  0.1411 -8.5811   < 1e-04
#> sexfemale     0.4986  0.1823  2.7348 0.0062411
#> 
#> Integration:
#> method: adaptive Gauss-Hermite quadrature rule
#> quadrature points: 11
#> 
#> Optimization:
#> method: hybrid EM and quasi-Newton
#> converged: TRUE

Created on 2019-03-20 by the reprex package (v0.2.1)

drizopoulos commented 5 years ago

This should be done via update(fm1, fixed = y ~ 1).