[R-sig-ME] means , CIs from lmer, glmer
Rune Haubo
rune.haubo at gmail.com
Tue Feb 27 15:53:42 CET 2018
On 27 February 2018 at 15:27, Kornbrot, Diana <d.e.kornbrot at herts.ac.uk>
wrote:
> Thanks
> Am also replying to list, so excuse duplication
> used install packages followed by library
> though that was happening on 1st attempt - but sadly no
>
>
> On 27 Feb 2018, at 12:53, Rune Haubo <rune.haubo at gmail.com> wrote:
>
> Well, you could also just do a linear mixed model on the
> logit-transformed proportions, which would make the Satterthwaite
> F-tests via lmerTest available to you. This can be OK if all the
> proportions have (approximately) the same denominator but
>
>
>
> usually
>
> *ALWAYS*
>
No, not always, but usually. In 'regular' cases (designed experiment with
the same denominator) the anova F-test is superior to the asymptotic
chi-square tests in the 'right' model.
> is better to fit the 'correct' binomial mixed model with glmer - even
> when all the proportions have the same denominator. Using glmer leaves
> you with likelihood ratio tests which are matched against the
> chi-square distribution - use anova(model2, model1) to obtain these
> likelihood ratio tests.
>
> It would be helpful if glmer did not [rpobably incorrectly] label
> chi-square tests as ‘F’
>
I don't think it does:
library(lme4)
gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
cbpp, binomial)
anova(gm1, gm2 <- update(gm1a, ~.-period))
Data: cbpp
Models:
gm2 <- update(gm1a, ~. - period): cbind(incidence, size - incidence) ~ (1 |
herd)
gm1: cbind(incidence, size - incidence) ~ period + (1 | herd)
Df AIC BIC logLik deviance Chisq
Chi Df
gm2 <- update(gm1a, ~. - period) 2 213.66 217.71 -104.832 209.66
gm1 5 194.05 204.18 -92.027 184.05 25.61
3
Pr(>Chisq)
gm2 <- update(gm1a, ~. - period)
gm1 1.151e-05 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
[actually, and to my surprise, anova(gm1) prints something that looks like
an anova table with a column labeled 'F', but I don't know what that means
(if it has a meaning). Wiser heads than mine will have to chip in here...]
> But this is a generalised linear model and was hoping get a mean and sd
> for the random subject (Participant) effect
>
Just printing the object (e.g. gm1) does give you the standard deviations
for the random effects. The mean is zero per definition, but I suspect that
this is not what you are really asking for?
> Also really do want an F comparing the predictor effects with appropriate
> error effects
>
I personally think that is an odd thing to ask for and I have no clue how
it is reasonably defined. I suspect you may have to use SPSS. I don't
really know what SPSS is doing but if it is doing a PQL-kind of thing that
would explain why you are led in the direction of F-tests (but note that
PQL is much inferior to the Laplace and AGQ methods in glmer).
Best
Rune
> It seems the in spite of R supposedly being more sophisticated than
> standard packages like SPSS, it has fewer options on the crucial issue of
> specifying error variance
>
>
>
> And by the way: you probably want to install the emmeans package via
> 'install.packages("emmeans")' in R - not via gitHub using devtools.
> See https://github.com/runehaubo/lmerTest under 'Installation' for the
> advice we give on installing lmerTest. Short version is to install
> using install.packages() before thinking about installing from github.
>
> good advice
>
> results form SPSS and R are very different
> R glmer MIXED
> Rab Between emmean SE df asymp.LCL asymp.UCL Rab Between Mean SE lcl ucl
> 1 1 -.316 .170 Inf -.650 .018 1 1 -.267 .148 -.562 .027
> 2 1 -.820 .172 Inf -1.158 -.482 2 1 -.688 .169 -1.023 -.352
> 3 1 -1.838 .183 Inf -2.196 -1.480 3 1 -1.550 .188 -1.924 -1.176
> 4 1 -2.558 .198 Inf -2.946 -2.170 4 1 -2.168 .230 -2.624 -1.712
> 1 2 .357 .165 Inf .034 .681 1 2 .297 .144 .011 .583
> 2 2 -.895 .167 Inf -1.223 -.567 2 2 -.745 .165 -1.073 -.417
> 3 2 -2.607 .192 Inf -2.984 -2.230 3 2 -2.238 .235 -2.705 -1.772
> 4 2 -2.891 .201 Inf -3.285 -2.497 4 2 -2.498 .255 -3.005 -1.992
> Df SS MS F Source F df1 df2 Sig.
> Rab 3 870.17 290.06 290.06 Rab 66.76 3 94 .000000
> Between 1 .12 .12 .12 Between .38 1 93 .539643
> Rab:Between 3 63.20 21.07 21.07 Rab*Between 5.31 3 94 .001998
> Corrected 30.64 7 101 .000000
>
>
> best
> Diana
>
>
> Best regards,
>
> Rune Haubo B. Christensen, PhD, MSc.
> Director, Owner
>
> Christensen Statistics
> Bringetoften 7
> <https://maps.google.com/?q=Bringetoften+7&entry=gmail&source=g>
> 3500 Værløse - Denmark
> +45 3026 4554 <+45%2030%2026%2045%2054>
> Rune at ChristensenStatistics.dk
> www.ChristensenStatistics.dk
>
>
> On 27 February 2018 at 12:32, Kornbrot, Diana <d.e.kornbrot at herts.ac.uk>
> wrote:
>
> thanks
>
> do you have any suggestions for glmer?
> SPSS seems happy to do Sattherwaite, which seems to be alogical approach
> for any model that is effectively doing a multivariate ANOVA on the logit
> transformed proportion
> best
> Diana
>
> On 27 Feb 2018, at 10:22, Rune Haubo <rune.haubo at gmail.com> wrote:
>
> Just a small note that lmerTest (and the Satterthwaite method for
> degrees of freedom) is only meaningful for _linear_ mixed models - not
> for the generalized variants such as the one considered here for
> proportions.
>
> Best,
> Rune
>
> On 27 February 2018 at 02:02, Ben Bolker <bbolker at gmail.com> wrote:
>
> Hi Diana,
>
> A reproducible example is always helpful/increases your chances of
> getting a useful answer ...
> It might help if you included the SPSS output (or posted it somewhere
> -- note that this list doesn't take HTML-formatted messages nor most
> attachments), as many of us don't have access to it.
>
> Look into the (very well-documented) emmeans package:
> https://CRAN.R-project.org/package=emmeans
> and the lmerTest package (for Satterthwaite df approximations)
>
> On Mon, Feb 26, 2018 at 12:11 PM, Kornbrot, Diana
> <d.e.kornbrot at herts.ac.uk> wrote:
>
> I am keen to promote the use of generalised mixed models for the analysis
> of
> proportions to psychologists
> Have straight fowl code in SPSS [costly] and would like to supply
> equivalent
> R Code without ‘tears’
> Design is a follows raw frequencies are: FreqPos for ‘success’ and FreqNeg
> for ‘failure’
> Predictors are Rab with 4 levels, repeated over participants and Between
> with 2 separate groups of participants
> Model is binomial with logit link
>
> Require following output to correspond to SPSS output from code below
> Descriptive: Means, se and 95% CIs by Rab, by Between and by Rab*Between
> Inferential: fo Rab, Between and Rab*Between: F value, MSE, numerator df,
> denominator df [this enables p-values]
>
> Have tried
>
> logit1 <- glmer(cbind(FreqPos,FreqNeg) ~ Rab + Between + Rab*Between + (1|
> Participant), family=binomial(link="logit"))
> gives F and MSE no denominator df or MSE. Different results to SPSS
> nb F=MSE - that can’t be right F is supposed to be ratio of chi-squares
>
> summary (logit1)
> gives coefficients and SEs. Different results to SPSS
> also tried predicted and fitted but still no means
>
> have spent days searching internet for examples - but none of them seem to
> show how to get the output I need
>
> All help greatly appreciated
>
> ____
> Spss syntax
>
> *Generalized Linear Mixed Models.
> GENLINMIXED
> /DATA_STRUCTURE SUBJECTS=Participant REPEATED_MEASURES=Rab
> COVARIANCE_TYPE=UNSTRUCTURED
> /FIELDS TARGET=FreqPos TRIALS=FIELD(Nmax) OFFSET=NONE
> /TARGET_OPTIONS DISTRIBUTION=BINOMIAL LINK=LOGIT
> /FIXED EFFECTS=Rab Between Rab*Between USE_INTERCEPT=TRUE
> /BUILD_OPTIONS TARGET_CATEGORY_ORDER=DESCENDING
> INPUTS_CATEGORY_ORDER=DESCENDING MAX_ITERATIONS=100 CONFIDENCE_LEVEL=95
> DF_METHOD=SATTERTHWAITE COVB=MODEL PCONVERGE=0.000001(ABSOLUTE) SCORING=0
> SINGULAR=0.000000000001
> /EMMEANS TABLES=Rab COMPARE=Rab CONTRAST=DEVIATION
> /EMMEANS TABLES=Between CONTRAST=NONE
> /EMMEANS TABLES=Rab*Between CONTRAST=NONE
> /EMMEANS_OPTIONS SCALE=ORIGINAL PADJUST=LSD.
>
> best
> Diana
>
>
> _____________________________________
> Professor Diana Kornbrot
> Mobile
> +44 (0) 7403 18 16 12
> Work
> University of Hertfordshire
> College Lane, Hatfield, Hertfordshire AL10 9AB, UK
> +44 (0) 170 728 4626 <+44%201707%20284626>
> d.e.kornbrot at herts.ac.uk<mailto:d.e.kornbrot at herts.ac.uk>
> http://dianakornbrot.wordpress.com/
> http://go.herts.ac.uk/Diana_Kornbrot
> skype: kornbrotme
> Home
> 19 Elmhurst Avenue
> <https://maps.google.com/?q=19+Elmhurst+Avenue+%0D%0ALondon+N2&entry=gmail&source=g>
> London N2 0LT, UK
> +44 (0) 208 444 2081 <+44%2020%208444%202081>
> ------------------------------------------------------------
>
>
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
>
> _____________________________________
> Professor Diana Kornbrot
> Mobile
> +44 (0) 7403 18 16 12
> Work
> University of Hertfordshire
> College Lane, Hatfield, Hertfordshire AL10 9AB, UK
> +44 (0) 170 728 4626 <+44%201707%20284626>
> d.e.kornbrot at herts.ac.uk
> http://dianakornbrot.wordpress.com/
> http://go.herts.ac.uk/Diana_Kornbrot
> skype: kornbrotme
> Home
> 19 Elmhurst Avenue
> <https://maps.google.com/?q=19+Elmhurst+Avenue+%0D%0ALondon+N2&entry=gmail&source=g>
> London N2 0LT, UK
> +44 (0) 208 444 2081 <+44%2020%208444%202081>
> ------------------------------------------------------------
>
>
>
>
> _____________________________________
> Professor Diana Kornbrot
> *Mobile*
> +44 (0) 7403 18 16 12
> *Work*
> University of Hertfordshire
> College Lane, Hatfield, Hertfordshire AL10 9AB, UK
> +44 (0) 170 728 4626 <+44%201707%20284626>
> d.e.kornbrot at herts.ac.uk
> http://dianakornbrot.wordpress.com/
> http://go.herts.ac.uk/Diana_Kornbrot
> skype: kornbrotme
> *Home*
> 19 Elmhurst Avenue
> <https://maps.google.com/?q=19+Elmhurst+Avenue+%0D%0ALondon+N2&entry=gmail&source=g>
> London N2 0LT, UK
> +44 (0) 208 444 2081 <+44%2020%208444%202081>
>
> ------------------------------------------------------------
>
>
>
>
>
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list