[R-sig-ME] significance of slope (different than zero) in triple interaction

Lenth, Russell V ru@@ell-lenth @ending from uiow@@edu
Wed Sep 5 16:25:13 CEST 2018


I'm a little confused because you refer to predictors by different names in different places, and 'year' seems to be used as both a covariate and a grouping factor. But try something like this:

    library(emmeans)
    emt <- emtrends(mod, ~ syst:timing, var = "year")
    summary(emt, infer = c(TRUE, TRUE))

This will estimate the slope for year at each combination of the two factors syst and timing. (You may need to re-fit the model after creating an additional variable, say WEED$syear <- scale(WEED$year), and with syear in place of scale(year) in the model formula and the emtrends call. You may follow-up with call(s) to emmeans::contrast(emt, ...) to compare or contrast these slopes.

Hope that helps.
-- Russ

Russell V. Lenth  -  Professor Emeritus
Department of Statistics and Actuarial Science   
The University of Iowa  -  Iowa City, IA 52242  USA   
Voice (319)335-0712 (Dept. office)  -  FAX (319)335-3017



-----Original Message-----
Date: Wed, 5 Sep 2018 10:43:39 +0200
From: Guillaume Adeux <guillaumesimon.a2 using gmail.com>
To: R-mixed models mailing list <r-sig-mixed-models using r-project.org>
Subject: [R-sig-ME] significance of slope (different than zero) in
	triple interaction


Hi mixmoders,

I have the following model:

mod=glmer(Weed_density~block+scale(year)*syst*timing+(1|year)+(1|plot)+(1|plot:year)+(1|ID_quadrat)+(1|OLRE)+offset(log(size_quadrat)),family=poisson(link="log"),dat=WEED)

I have a significant triple interaction between time : treatment : season.

Time is continuous, syst(=treatment) has 5 levels and season(=sampling
session) has two levels.

Here is the model output:

Generalized linear mixed model fit by maximum likelihood (Laplace
Approximation) ['glmerMod']
 Family: poisson  ( log )
Formula: WDall ~ block + scale(year) * syst * timing + (1 | year) + (1
|      plot) + (1 | plot:year) + (1 | ID_quadrat) + (1 | OLRE) +
offset(log(size_quadrat))
   Data: WEED_paired_2
Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))

     AIC      BIC   logLik deviance df.resid
 21206.3  21371.9 -10577.2  21154.3     4286

Scaled residuals:
    Min      1Q  Median      3Q     Max
-1.6531 -0.4373 -0.1646  0.1426  2.6313

Random effects:
 Groups     Name        Variance  Std.Dev.
 OLRE       (Intercept) 4.456e-01 6.675e-01
 ID_quadrat (Intercept) 1.011e+00 1.006e+00  plot:year  (Intercept) 1.429e+00 1.195e+00
 year       (Intercept) 5.635e-15 7.506e-08
 plot       (Intercept) 0.000e+00 0.000e+00
Number of obs: 4312, groups:  OLRE, 4312; ID_quadrat, 2156; plot:year, 86; year, 17; plot, 10

Fixed effects:
                                Estimate Std. Error z value Pr(>|z|)
(Intercept)                     -0.84765    0.33352  -2.542 0.011036 *
blockD                          -0.28663    0.27596  -1.039 0.298971
scale(year)                      0.11385    0.25128   0.453 0.650500
systS2                           2.21797    0.43765   5.068 4.02e-07 ***
systS3                           2.97934    0.42857   6.952 3.61e-12 ***
systS4                           2.64787    0.43488   6.089 1.14e-09 ***
systS5                           0.55059    0.45565   1.208 0.226912
timingavant1                     1.87971    0.10286  18.275  < 2e-16 ***
scale(year):systS2               0.40061    0.38882   1.030 0.302863
scale(year):systS3               0.44798    0.37297   1.201 0.229698
scale(year):systS4              -0.01245    0.36549  -0.034 0.972819
scale(year):systS5               1.06031    0.37957   2.793 0.005215 **
scale(year):timingavant1         0.07949    0.09954   0.799 0.424489
systS2:timingavant1             -0.36039    0.12128  -2.972 0.002963 **
systS3:timingavant1             -0.56704    0.11777  -4.815 1.47e-06 ***
systS4:timingavant1             -0.39785    0.11984  -3.320 0.000901 ***
systS5:timingavant1             -0.06724    0.14990  -0.449 0.653770
scale(year):systS2:timingavant1 -0.15246    0.11992  -1.271 0.203628
scale(year):systS3:timingavant1 -0.04057    0.11556  -0.351 0.725543
scale(year):systS4:timingavant1 -0.49134    0.11614  -4.231 2.33e-05 ***
scale(year):systS5:timingavant1 -0.34391    0.13427  -2.561 0.010429 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


I wish to set up constrats to test if the slopes for scale(year):syst differ from zero at level 1 of timing.

It seems like we can do this with testInteractions but I'm not sure if my set up is correct:

testInteractions(mod1,custom=list(syst=c(1,0,0,0,0),timing=c(1,0)),
slope="scale(year)", adjustment="none")

The preceding code yields the following:

Adjusted slope for scale(year)
Chisq Test:
P-value adjustment method: none
                   Value Df  Chisq Pr(>Chisq)
syst1 : timing1 -0.82831  1 0.6464     0.4214

This doesn't seem correct because Value doesn't represent the slope for the first level of "syst" at the first level of "timing".

Could anyone shed their light?

Thank you very much!

Guillaume ADEUX




More information about the R-sig-mixed-models mailing list