In Python, I'm trying to validate the LS means from a mixed model that I ran with R's lme4 after using the lsmeans library. I'm using Python's mixedlm() from statsmodels.
I've successfully obtained the fixed effects means (by "hand") by extracting the parameters and alternatively with .predict() and a pandas dataframe. But I'm hung up on the standard errors for my predicted values. I'm not quite sure how to obtain these, though R's lsmeans library spits them out. In truth, I'm not sure how R is calculating them.
Does anyone know how to calculate the LS mean standard errors?
lsmeans
are based the pooled standard deviation, obtained from a weighted average of the variances:sqrt(sum((n - 1) * s^2) / sum(n - 1))
$\endgroup$ – Robert Long Aug 25 '20 at 7:27