Skip to contents

This function computes the null-model (i.e. (y ~ 1)) of a model. For mixed models, the null-model takes random effects into account.

Usage

null_model(model, ...)

# Default S3 method
null_model(model, verbose = TRUE, ...)

Arguments

model

A (mixed effects) model.

...

Arguments passed to or from other methods.

verbose

Toggle off warnings.

Value

The null-model of x

Examples

data(sleepstudy)
m <- lmer(Reaction ~ Days + (1 + Days | Subject), data = sleepstudy)
summary(m)
#> Linear mixed model fit by REML ['lmerMod']
#> Formula: Reaction ~ Days + (1 + Days | Subject)
#>    Data: sleepstudy
#> 
#> REML criterion at convergence: 1743.6
#> 
#> Scaled residuals: 
#>     Min      1Q  Median      3Q     Max 
#> -3.9536 -0.4634  0.0231  0.4634  5.1793 
#> 
#> Random effects:
#>  Groups   Name        Variance Std.Dev. Corr
#>  Subject  (Intercept) 612.10   24.741       
#>           Days         35.07    5.922   0.07
#>  Residual             654.94   25.592       
#> Number of obs: 180, groups:  Subject, 18
#> 
#> Fixed effects:
#>             Estimate Std. Error t value
#> (Intercept)  251.405      6.825  36.838
#> Days          10.467      1.546   6.771
#> 
#> Correlation of Fixed Effects:
#>      (Intr)
#> Days -0.138
summary(null_model(m))
#> Linear mixed model fit by REML ['lmerMod']
#> Formula: Reaction ~ (1 + Days | Subject)
#>    Data: structure(list(Reaction = c(249.56, 258.7047, 250.8006, 321.4398,  
#> 356.8519, 414.6901, 382.2038, 290.1486, 430.5853, 466.3535, 222.7339,  
#> 205.2658, 202.9778, 204.707, 207.7161, 215.9618, 213.6303, 217.7272,  
#> 224.2957, 237.3142, 199.0539, 194.3322, 234.32, 232.8416, 229.3074,  
#> 220.4579, 235.4208, 255.7511, 261.0125, 247.5153, 321.5426, 300.4002,  
#> 283.8565, 285.133, 285.7973, 297.5855, 280.2396, 318.2613, 305.3495,  
#> 354.0487, 287.6079, 285, 301.8206, 320.1153, 316.2773, 293.3187,  
#> 290.075, 334.8177, 293.7469, 371.5811, 234.8606, 242.8118, 272.9613,  
#> 309.7688, 317.4629, 309.9976, 454.1619, 346.8311, 330.3003, 253.8644,  
#> 283.8424, 289.555, 276.7693, 299.8097, 297.171, 338.1665, 332.0265,  
#> 348.8399, 333.36, 362.0428, 265.4731, 276.2012, 243.3647, 254.6723,  
#> 279.0244, 284.1912, 305.5248, 331.5229, 335.7469, 377.299, 241.6083,  
#> 273.9472, 254.4907, 270.8021, 251.4519, 254.6362, 245.4523, 235.311,  
#> 235.7541, 237.2466, 312.3666, 313.8058, 291.6112, 346.1222, 365.7324,  
#> 391.8385, 404.2601, 416.6923, 455.8643, 458.9167, 236.1032, 230.3167,  
#> 238.9256, 254.922, 250.7103, 269.7744, 281.5648, 308.102, 336.2806,  
#> 351.6451, 256.2968, 243.4543, 256.2046, 255.5271, 268.9165, 329.7247,  
#> 379.4445, 362.9184, 394.4872, 389.0527, 250.5265, 300.0576, 269.8939,  
#> 280.5891, 271.8274, 304.6336, 287.7466, 266.5955, 321.5418, 347.5655,  
#> 221.6771, 298.1939, 326.8785, 346.8555, 348.7402, 352.8287, 354.4266,  
#> 360.4326, 375.6406, 388.5417, 271.9235, 268.4369, 257.2424, 277.6566,  
#> 314.8222, 317.2135, 298.1353, 348.1229, 340.28, 366.5131, 225.264,  
#> 234.5235, 238.9008, 240.473, 267.5373, 344.1937, 281.1481, 347.5855,  
#> 365.163, 372.2288, 269.8804, 272.4428, 277.8989, 281.7895, 279.1705,  
#> 284.512, 259.2658, 304.6306, 350.7807, 369.4692, 269.4117, 273.474,  
#> 297.5968, 310.6316, 287.1726, 329.6076, 334.4818, 343.2199, 369.1417,  
#> 364.1236), Days = c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3,  
#> 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4,  
#> 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5,  
#> 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0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 16L, 16L, 16L, 16L,  
#> 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 18L, 18L, 18L,  
#> 18L, 18L, 18L, 18L, 18L, 18L, 18L), levels = c("308", "309",  
#> "310", "330", "331", "332", "333", "334", "335", "337", "349",  
#> "350", "351", "352", "369", "370", "371", "372"), class = "factor")), row.names = c(NA,  
#> 180L), class = "data.frame")
#> 
#> REML criterion at convergence: 1769.8
#> 
#> Scaled residuals: 
#>     Min      1Q  Median      3Q     Max 
#> -4.0449 -0.4486  0.0089  0.4819  5.2186 
#> 
#> Random effects:
#>  Groups   Name        Variance Std.Dev. Corr 
#>  Subject  (Intercept) 651.6    25.53         
#>           Days        142.2    11.93    -0.18
#>  Residual             654.9    25.59         
#> Number of obs: 180, groups:  Subject, 18
#> 
#> Fixed effects:
#>             Estimate Std. Error t value
#> (Intercept)   257.76       6.76   38.13