why does fitlme with a random effect gives the same results to fitlme without the random effect

13 Ansichten (letzte 30 Tage)
considering the data attached.
tbl = readtable('t.txt');
mdl1 = fitlme(tbl, 'y ~ g + (1|match)')
mdl1 =
Linear mixed-effects model fit by ML Model information: Number of observations 1134 Fixed effects coefficients 2 Random effects coefficients 567 Covariance parameters 2 Formula: y ~ 1 + g + (1 | match) Model fit statistics: AIC BIC LogLikelihood Deviance 2914.1 2934.2 -1453 2906.1 Fixed effects coefficients (95% CIs): Name Estimate SE tStat DF pValue Lower Upper {'(Intercept)'} -0.087584 0.036597 -2.3932 1132 0.016864 -0.15939 -0.015779 {'g' } -0.20722 0.051756 -4.0038 1132 6.6391e-05 -0.30877 -0.10567 Random effects covariance parameters (95% CIs): Group: match (567 Levels) Name1 Name2 Type Estimate Lower Upper {'(Intercept)'} {'(Intercept)'} {'std'} 1.5011e-06 NaN NaN Group: Error Name Estimate Lower Upper {'Res Std'} 0.87144 0.8363 0.90805
mdl2 = fitlme(tbl, 'y ~ g')
mdl2 =
Linear mixed-effects model fit by ML Model information: Number of observations 1134 Fixed effects coefficients 2 Random effects coefficients 0 Covariance parameters 1 Formula: y ~ 1 + g Model fit statistics: AIC BIC LogLikelihood Deviance 2912.1 2927.2 -1453 2906.1 Fixed effects coefficients (95% CIs): Name Estimate SE tStat DF pValue Lower Upper {'(Intercept)'} -0.087584 0.036597 -2.3932 1132 0.016864 -0.15939 -0.015779 {'g' } -0.20722 0.051756 -4.0038 1132 6.6391e-05 -0.30877 -0.10567 Random effects covariance parameters (95% CIs): Group: Error Name Estimate Lower Upper {'Res Std'} 0.87144 0.8363 0.90805
Why do they give exactly the same outputs? Presumebly the first model should be equivalent to a paird t-test
[h, p] = ttest(tbl.y(tbl.g == 1), tbl.y(tbl.g == 0))
h = 1
p = 1.0788e-04
  1 Kommentar
Peng Li
Peng Li am 6 Aug. 2021
Using other software (JMP), they clearly give different results:
upper panel without random effect, and lower panel with the random effect. The one with the random effect gives a p value the same to ttest.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Ive J
Ive J am 8 Aug. 2021
This shows the model fits well with only fixed effect and there is no variance left for random effects. Also, your observations (sample size) to group ratio is relatively small. Either increase your sample size (which I guess not possible with your current design), or simply use fitlm instead.
  1 Kommentar
Peng Li
Peng Li am 12 Aug. 2021
thanks for your answer. It is essentially a matched design, so theoretically, a matched test or mixed model (if including covariates) should be the right choice i suppose?
The JMP outputs gave different results between the models with and without random effect. And we figured out that, somehow, in JMP, it allows a negative variance of the random effect (by checking the condition "Unbounded Variance Components". If uncheck it, the variance of random effect was 0, and all became the same to matlab output, but the p value, which was due to different ways to calculate the DF i think.

Melden Sie sich an, um zu kommentieren.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by