This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | anova(gm1, fm2, test = FALSE) | |
| #> | |
| #> AIC BIC log.Lik df | |
| #> gm1 3933.49 3954.33 -1958.75 | |
| #> fm2 4446.61 4446.61 -2214.31 1 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | anova(gm1, fm2, test = FALSE) | |
| #> | |
| #> AIC BIC log.Lik df | |
| #> gm1 3933.49 3954.33 -1958.75 | |
| #> fm2 4446.61 4446.61 -2214.31 1 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | gm1 <- mixed_model(y ~ sex * time, random = ~ 1 | id, data = DF, | |
| family = zi.negative.binomial(), zi_fixed = ~ sex) | |
| gm1 | |
| #> | |
| #> Call: | |
| #> mixed_model(fixed = y ~ sex * time, random = ~1 | id, data = DF, | |
| #> family = zi.negative.binomial(), zi_fixed = ~sex) | |
| #> | |
| #> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | anova(fm1, fm2) | |
| #> | |
| #> AIC BIC log.Lik LRT df p.value | |
| #> fm1 4461.87 4480.11 -2223.94 | |
| #> fm2 4446.61 4446.61 -2214.31 19.26 2 1e-04 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | fm2 <- update(fm1, zi_random = ~ 1 | id) | |
| fm2 | |
| #> | |
| #> Call: | |
| #> mixed_model(fixed = y ~ sex * time, random = ~1 | id, data = DF, | |
| #> family = zi.poisson(), zi_fixed = ~sex, zi_random = ~1 | | |
| #> id) | |
| #> | |
| #> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | fm1 <- mixed_model(y ~ sex * time, random = ~ 1 | id, data = DF, | |
| family = zi.poisson(), zi_fixed = ~ sex) | |
| fm1 | |
| #> | |
| #> Call: | |
| #> mixed_model(fixed = y ~ sex * time, random = ~1 | id, data = DF, | |
| #> family = zi.poisson(), zi_fixed = ~sex) | |
| #> | |
| #> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | set.seed(1234) | |
| n <- 100 # number of subjects | |
| K <- 8 # number of measurements per subject | |
| t_max <- 5 # maximum follow-up time | |
| # we constuct a data frame with the design: | |
| # everyone has a baseline measurment, and then measurements | |
| # at random follow-up times | |
| DF <- data.frame(id = rep(seq_len(n), each = K), | |
| time = c(replicate(n, c(0, sort(runif(K - 1, 0, t_max))))), | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | fm3 <- mixed_model(fixed = y ~ sex * time, random = ~ time | id, data = DF, | |
| family = binomial(), nAGQ = 15) | |
| summary(fm3) | |
| #> | |
| #> Call: | |
| #> mixed_model(fixed = y ~ sex * time, random = ~time | id, data = DF, | |
| #> family = binomial(), nAGQ = 15) | |
| #> | |
| #> Data Descriptives: | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | fm2 <- mixed_model(fixed = y ~ sex * time, random = ~ time || id, data = DF, | |
| family = binomial()) | |
| anova(fm1, fm2) | |
| #> | |
| #> AIC BIC log.Lik LRT df p.value | |
| #> fm1 759.04 772.07 -374.52 | |
| #> fm2 730.94 730.94 -359.47 30.1 1 <0.0001 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | fm1 <- mixed_model(fixed = y ~ sex * time, random = ~ 1 | id, data = DF, | |
| family = binomial()) | |
| summary(fm1) | |
| #> | |
| #> Call: | |
| #> mixed_model(fixed = y ~ sex * time, random = ~1 | id, data = DF, | |
| #> family = binomial()) | |
| #> | |
| #> Data Descriptives: | 
NewerOlder