I have an output from two LMER-models and I'd like to calculate AIC & BIC. I believe I've understood the tables correctly, but I'm uncertain regarding the k parameter; have I understood it correctly?
My models:
#Model1
Mixed Linear Model Regression Results
================================================================================
Model: MixedLM Dependent Variable: Volume
No. Observations: 183 Method: REML
No. Groups: 13 Scale: 135112391671077.1250
Min. group size: 13 Log-Likelihood: -3232.0814
Max. group size: 15 Converged: Yes
Mean group size: 14.1
--------------------------------------------------------------------------------
Coef. Std.Err. z P>|z| [0.025 0.975]
--------------------------------------------------------------------------------
Intercept 33526487.924 7715549.309 4.345 0.000 18404289.158 48648686.690
Score 4612862.511 2011290.523 2.293 0.022 670805.524 8554919.498
Group Var 758032009969204.875 27899429.226
================================================================================
I used k = Interecept+Score+Group Var = 3
#Model2
Mixed Linear Model Regression Results
================================================================
Model: MixedLM Dependent Variable: Transformed_Volume
No. Observations: 181 Method: REML
No. Groups: 13 Scale: 8698.0110
Min. group size: 13 Log-Likelihood: -1098.8257
Max. group size: 15 Converged: Yes
Mean group size: 13.9
----------------------------------------------------------------
Coef. Std.Err. z P>|z| [0.025 0.975]
----------------------------------------------------------------
Intercept 330.777 74.894 4.417 0.000 183.989 477.566
Score 39.102 16.390 2.386 0.017 6.979 71.224
Group Var 71886.612 333.046
Group x Score Cov 2161.829 70.984
Score Var 65.015 18.319
================================================================
# I used k = Intercept+Score+Group Var+Group x Score Cov + Score Var = 5
My calculations:
#AIC & BIC Model1
k1 = 3
l1 = -3232.0814
n1 = np.log(183)
AIC1 = 2k-2l1
BIC1 = k1n1-2l1
#AIC & BIC Model2
k2 = 5
l2 = -1098.8257
n2 = np.log(181)
AIC2 = 2k1-2l2
BIC2 = k2n2-2l2
Result:
AIC1: 6474.1628
BIC1: 6479.791258458525
AIC2: 2203.6514
BIC2: 2223.6438851563294
method='ML'to get a likelihood instead of just a profile likelihood. Lastly, there are already default method forAICandBICin R that work. – AdamO May 18 '21 at 18:16reml=Falseas done in Python, I get two different error messages:RuntimeWarning: invalid value encountered in log&ConvergenceWarning: Maximum Likelihood optimization failed to converge. Check mle_retvals. One problem I can identify from this is that myScorevariable ranges from -1 to 1. Is there any other way to compare the models while still using the REML method? – OLGJ May 18 '21 at 19:14lme4-nlmetag, so @AdamO perhaps presumed that you are using R, since that tag is for specifically for the R packageslme4andnlmeI will edit your question to change the tags. – Robert Long May 18 '21 at 20:37