Separate linear models are fit via lm
similar to lmList
,
however, adjust_lmList
can handle models where a factor takes only one
level within a group. In this case, the formula
is updated eliminating
the offending factors from the formula for that group as the effect is
absorbed into the intercept.
# S3 method for class 'formula'
adjust_lmList(object, data, pool)
Douglas Bates, Martin Maechler and Ben Bolker (2012). lme4: Linear mixed-effects models using S4 classes. R package version 0.999999-0.
data(Exam, package = 'mlmRev')
sepLM <- adjust_lmList(normexam ~ standLRT + sex + schgend | school, data = Exam)
confint(sepLM)
#> , , 1
#>
#> 2.5 % 97.5 %
#> (Intercept) 0.3263569 0.880487552
#> standLRT 0.5428713 0.866088363
#> sexM -0.7062104 -0.005229246
#>
#> , , 2
#>
#> 2.5 % 97.5 %
#> (Intercept) 0.2741168 0.6904430
#> standLRT 0.5856914 0.9368854
#> sexM NA NA
#>
#> , , 3
#>
#> 2.5 % 97.5 %
#> (Intercept) 0.1808845 0.8652867
#> standLRT 0.3506674 0.8180285
#> sexM -0.3548285 0.4692764
#>
#> , , 4
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.01708563 0.48795787
#> standLRT 0.57293686 0.90154411
#> sexM -0.73604554 -0.06961313
#>
#> , , 5
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.1595617 0.5173484
#> standLRT 0.3196197 1.0194057
#> sexM -0.3122614 0.6787381
#>
#> , , 6
#>
#> 2.5 % 97.5 %
#> (Intercept) 0.3994135 0.8070153
#> standLRT 0.3429282 0.7277607
#> sexM NA NA
#>
#> , , 7
#>
#> 2.5 % 97.5 %
#> (Intercept) 0.24328532 0.5537685
#> standLRT 0.06437063 0.4201863
#> sexM NA NA
#>
#> , , 8
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.1694081 0.1190189
#> standLRT 0.4359288 0.6988817
#> sexM NA NA
#>
#> , , 9
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.5163689 0.3113809
#> standLRT 0.1773889 0.6149736
#> sexM -0.7367574 0.2919920
#>
#> , , 10
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.45804811 0.21709881
#> standLRT 0.02129566 0.57311913
#> sexM -0.75500829 0.09317282
#>
#> , , 11
#>
#> 2.5 % 97.5 %
#> (Intercept) 0.04520193 0.4867243
#> standLRT 0.26858390 0.6486871
#> sexM NA NA
#>
#> , , 12
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.1851760 0.41786999
#> standLRT 0.1568075 0.68324550
#> sexM -0.8170397 0.06032129
#>
#> , , 13
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.3121936 0.1602812
#> standLRT 0.4231835 0.7842949
#> sexM -0.5761591 0.1841319
#>
#> , , 14
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.2340343 0.063454982
#> standLRT 0.4823489 0.710977683
#> sexM -0.4104064 0.006161141
#>
#> , , 15
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.3897919 0.05931406
#> standLRT 0.5468211 0.92725157
#> sexM -0.4497958 0.16101075
#>
#> , , 16
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.5521980 -0.2190879
#> standLRT 0.2195726 0.5943072
#> sexM NA NA
#>
#> , , 17
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.2983521 0.0005841605
#> standLRT 0.3663959 0.6146511204
#> sexM -0.4595705 0.1462777495
#>
#> , , 18
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.1933661 0.07868622
#> standLRT 0.1547744 0.56399159
#> sexM NA NA
#>
#> , , 19
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.1988869 0.51911911
#> standLRT 0.4110062 1.03191597
#> sexM -0.7989017 0.02781329
#>
#> , , 20
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.06610851 0.6511977
#> standLRT 0.28592233 0.7516565
#> sexM -0.50887093 0.4261859
#>
#> , , 21
#>
#> 2.5 % 97.5 %
#> (Intercept) 0.09411429 0.4433261
#> standLRT 0.36417729 0.7448105
#> sexM NA NA
#>
#> , , 22
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.6429741 -0.1931720
#> standLRT 0.3718559 0.6694182
#> sexM -0.3994458 0.2207079
#>
#> , , 23
#>
#> 2.5 % 97.5 %
#> (Intercept) -1.0589335 -0.3542877
#> standLRT 0.1232313 0.6513788
#> sexM -0.3858722 0.7645369
#>
#> , , 24
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.08440336 0.4398668
#> standLRT 0.13979257 0.6554386
#> sexM NA NA
#>
#> , , 25
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.4681044 -0.06747851
#> standLRT 0.3696859 0.69442914
#> sexM NA NA
#>
#> , , 26
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.2127768 0.3459270
#> standLRT 0.3539255 0.7146563
#> sexM -0.5282161 0.1576498
#>
#> , , 27
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.2432297 0.3136069
#> standLRT 0.3332213 0.8125156
#> sexM NA NA
#>
#> , , 28
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.99160002 -0.4200939
#> standLRT 0.02992496 0.4868472
#> sexM -0.54519752 0.2678522
#>
#> , , 29
#>
#> 2.5 % 97.5 %
#> (Intercept) 0.02893775 0.3799085
#> standLRT 0.22122253 0.5798091
#> sexM NA NA
#>
#> , , 30
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.1119115 0.3496121
#> standLRT 0.6086169 1.0031872
#> sexM NA NA
#>
#> , , 31
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.29519837 0.2167474
#> standLRT 0.09812043 0.7064471
#> sexM NA NA
#>
#> , , 32
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.2725009 0.4884809
#> standLRT 0.4469030 0.8652109
#> sexM -0.5656019 0.4015437
#>
#> , , 33
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.1308773 0.3760244
#> standLRT 0.3136608 0.7161246
#> sexM -0.4852955 0.1893604
#>
#> , , 34
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.4280417 0.6917086
#> standLRT 0.5417207 0.9908155
#> sexM -0.9782206 0.3229082
#>
#> , , 35
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.10733145 0.3707919
#> standLRT 0.08583033 0.7074766
#> sexM NA NA
#>
#> , , 36
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.3814711 -0.0323657
#> standLRT 0.2899044 0.5867862
#> sexM NA NA
#>
#> , , 37
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.86303981 -0.1074051
#> standLRT -0.04683207 0.5233799
#> sexM NA NA
#>
#> , , 38
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.4117786 0.1964173
#> standLRT 0.4324098 0.8045009
#> sexM -0.4869755 0.3172313
#>
#> , , 39
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.08580749 0.3408916
#> standLRT 0.26389329 0.6412903
#> sexM NA NA
#>
#> , , 40
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.4229468 -0.07745003
#> standLRT 0.5610778 0.89149116
#> sexM NA NA
#>
#> , , 41
#>
#> 2.5 % 97.5 %
#> (Intercept) 0.01591697 0.4090773
#> standLRT 0.28336164 0.6834597
#> sexM NA NA
#>
#> , , 42
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.07672777 0.5315250
#> standLRT 0.14768929 0.6177283
#> sexM -0.64733724 0.1542706
#>
#> , , 43
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.3694495 0.06225094
#> standLRT 0.4825313 0.96690972
#> sexM -2.2578769 0.68123642
#>
#> , , 44
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.6217776 -0.06703287
#> standLRT 0.1116875 0.62756630
#> sexM NA NA
#>
#> , , 45
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.3237111 0.1040984
#> standLRT 0.3568099 0.7762701
#> sexM -0.7863768 0.5817425
#>
#> , , 46
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.7547097 -0.2589714
#> standLRT 0.2678466 0.6303908
#> sexM -0.1240484 0.5266384
#>
#> , , 47
#>
#> 2.5 % 97.5 %
#> (Intercept) -1.6414956 1.2884991
#> standLRT 0.4758159 0.8601886
#> sexM -1.3279602 1.6270263
#>
#> , , 48
#>
#> 2.5 % 97.5 %
#> (Intercept) -13.63570 7.09154
#> standLRT -31.80557 18.00264
#> sexM NA NA
#>
#> , , 49
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.08945059 0.1843917
#> standLRT 0.32895521 0.6401583
#> sexM NA NA
#>
#> , , 50
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.5619947 -0.08856006
#> standLRT 0.5009351 0.84965420
#> sexM -0.3444848 0.34067081
#>
#> , , 51
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.2170689 0.30425141
#> standLRT 0.1326133 0.48269456
#> sexM -0.8343468 -0.05585432
#>
#> , , 52
#>
#> 2.5 % 97.5 %
#> (Intercept) 0.1982797 0.5777984
#> standLRT 0.5580361 0.9225023
#> sexM NA NA
#>
#> , , 53
#>
#> 2.5 % 97.5 %
#> (Intercept) 0.4057054 0.7817016
#> standLRT 0.8896918 1.2642644
#> sexM NA NA
#>
#> , , 54
#>
#> 2.5 % 97.5 %
#> (Intercept) -1.511635 0.3726510
#> standLRT -0.884864 0.9272546
#> sexM -1.190699 0.8842954
#>
#> , , 55
#>
#> 2.5 % 97.5 %
#> (Intercept) 0.4582710 1.05665797
#> standLRT 0.4073517 0.81633769
#> sexM -0.8087157 0.00864674
#>
#> , , 56
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.1066648 0.51413522
#> standLRT 0.5827576 1.12899891
#> sexM -0.8709050 0.08854877
#>
#> , , 57
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.1432485 0.2243516
#> standLRT 0.4184475 0.8062908
#> sexM NA NA
#>
#> , , 58
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.03930461 0.4534591
#> standLRT 0.07650285 0.6350650
#> sexM NA NA
#>
#> , , 59
#>
#> 2.5 % 97.5 %
#> (Intercept) -1.0155664 -0.2701350
#> standLRT 0.1330872 0.5857961
#> sexM -0.7713684 0.1124081
#>
#> , , 60
#>
#> 2.5 % 97.5 %
#> (Intercept) 0.08844282 0.4154892
#> standLRT 0.45619221 0.8194257
#> sexM NA NA
#>
#> , , 61
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.3460901 0.2017394
#> standLRT 0.4529938 0.8327429
#> sexM -0.3159877 0.4360368
#>
#> , , 62
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.1590656 0.39744840
#> standLRT 0.3210642 0.76124913
#> sexM -0.6371948 0.06990985
#>
#> , , 63
#>
#> 2.5 % 97.5 %
#> (Intercept) 0.38260418 1.1225002
#> standLRT -0.05601729 0.6743487
#> sexM -0.70073875 0.3999581
#>
#> , , 64
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.1709083 0.2458974
#> standLRT 0.5057029 0.9053449
#> sexM NA NA
#>
#> , , 65
#>
#> 2.5 % 97.5 %
#> (Intercept) -0.3418580 -0.007942406
#> standLRT 0.4098036 0.727114837
#> sexM NA NA
#>
#> attr(,"class")
#> [1] "adjust_lmList.confint"