Skip to content
Prev 4168 / 20628 Next

gamm4 model formulation clarification

Thanks, though I'm not clear on how assigning contrasts to g then
adding it as a fixed effect is different from the original
specification, where the smooth is told to vary by g but g isn't in
the fixed effects; instead I had ddB*design in the fixed effects,
which I thought would be equivalent to having g and the contrasts you
suggested. However, it seems that I get different results between the
two approaches (see below). Any ideas why? I presume I'm missing
something!

Also, I'm just now thinking that neither approach really gets at what
I want to test; what I want to test whether the model is improved by
(1) letting the smooth vary as a function of design, (2) letting the
smooth vary as a function of ddB, and (3) letting the smooth vary as a
function of both design & ddB. That is, is there a design*soa
interaction, a ddB*soa interaction and/or a design*ddB*soa
interaction? In the case of support for any of these interactions, I'd
also be interested in pinpointing the timeframe over which the
interactions take place.

Thoughts?

#here is the "ddB*design+s(soa,by=g)" versus "g+s(soa,by=g)" fits and
output, showing that they're not identical:
Linear mixed model fit by REML
     AIC     BIC logLik deviance REMLdev
 -564383 -564261 282205  -564567 -564411
Random effects:
 Groups   Name              Variance   Std.Dev.
 id       (Intercept)       6.9251e-08 0.00026316
 Xr.4     s(soa):g0ddB NCD 6.1200e-05 0.00782305
 Xr.3     s(soa):g0ddB CD  1.3823e-03 0.03717992
 Xr.2     s(soa):g+ddB NCD 2.4589e-04 0.01568096
 Xr.1     s(soa):g+ddB CD  2.0301e-03 0.04505718
 Residual                   2.0814e-07 0.00045623
Number of obs: 45013, groups: id, 20; Xr.4, 8; Xr.3, 8; Xr.2, 8; Xr.1, 8

Fixed effects:
                        Estimate Std. Error t value
X(Intercept)           2.455e-03  5.896e-05   41.63
XddB+ddB               5.104e-05  5.232e-06    9.76
XdesignNCD            -2.665e-04  7.066e-06  -37.72
XddB+ddB:designNCD    -4.450e-05  1.007e-05   -4.42
Xs(soa):g+ddB CDFx1  -1.592e-04  5.178e-05   -3.07
Xs(soa):g+ddB NCDFx1  1.099e-04  6.717e-05    1.64
Xs(soa):g0ddB CDFx1   9.027e-06  4.942e-05    0.18
Xs(soa):g0ddB NCDFx1  3.618e-05  4.430e-05    0.82
Family: gaussian
Link function: identity

Formula:
rrt ~ ddB * design + s(soa, by = g)

Parametric coefficients:
                    Estimate Std. Error t value Pr(>|t|)
(Intercept)        2.455e-03  3.706e-06 662.327  < 2e-16 ***
ddB+ddB            5.104e-05  5.230e-06   9.760  < 2e-16 ***
designNCD         -2.665e-04  7.260e-06 -36.710  < 2e-16 ***
ddB+ddB:designNCD -4.450e-05  1.005e-05  -4.428 9.55e-06 ***
---
Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1

Approximate significance of smooth terms:
                    edf Ref.df       F  p-value
s(soa):g+ddB CD  8.042  8.042 205.327  < 2e-16 ***
s(soa):g+ddB NCD 5.419  5.419   4.375 0.000361 ***
s(soa):g0ddB CD  7.795  7.795 213.477  < 2e-16 ***
s(soa):g0ddB NCD 3.977  3.977   4.461 0.001358 **
---
Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1

R-sq.(adj) =  0.0964lmer.REML score = -5.6441e+05  Scale est. =
2.0814e-07  n = 45013
Linear mixed model fit by REML
     AIC     BIC logLik deviance REMLdev
 -564381 -564259 282205  -564567 -564409
Random effects:
 Groups   Name              Variance   Std.Dev.
 id       (Intercept)       6.9252e-08 0.00026316
 Xr.4     s(Ssoa):g0ddB NCD 6.1196e-05 0.00782278
 Xr.3     s(Ssoa):g0ddB CD  1.3824e-03 0.03718002
 Xr.2     s(Ssoa):g+ddB NCD 2.4589e-04 0.01568093
 Xr.1     s(Ssoa):g+ddB CD  2.0302e-03 0.04505719
 Residual                   2.0814e-07 0.00045623
Number of obs: 45013, groups: id, 20; Xr.4, 8; Xr.3, 8; Xr.2, 8; Xr.1, 8

Fixed effects:
                        Estimate Std. Error t value
X(Intercept)           2.336e-03  5.890e-05   39.66
Xg.34-12              -2.879e-05  5.035e-06   -5.72
Xg.24-13              -2.887e-04  5.032e-06  -57.38
Xg.14-23               2.225e-05  5.035e-06    4.42
Xs(soa):g+ddB CDFx1  -1.592e-04  5.178e-05   -3.07
Xs(soa):g+ddB NCDFx1  1.099e-04  6.717e-05    1.64
Xs(soa):g0ddB CDFx1   9.027e-06  4.942e-05    0.18
Xs(soa):g0ddB NCDFx1  3.618e-05  4.430e-05    0.82
Family: gaussian
Link function: identity

Formula:
rrt ~ g + s(soa, by = g)

Parametric coefficients:
              Estimate Std. Error t value Pr(>|t|)
(Intercept)  2.336e-03  2.637e-06 885.684  < 2e-16 ***
g.34-12     -2.879e-05  5.025e-06  -5.728 1.02e-08 ***
g.24-13     -2.887e-04  5.275e-06 -54.741  < 2e-16 ***
g.14-23      2.225e-05  5.025e-06   4.428 9.55e-06 ***
---
Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1

Approximate significance of smooth terms:
                    edf Ref.df       F  p-value
s(soa):g+ddB CD  8.042  8.042 205.328  < 2e-16 ***
s(soa):g+ddB NCD 5.419  5.419   4.375 0.000361 ***
s(soa):g0ddB CD  7.795  7.795 213.477  < 2e-16 ***
s(soa):g0ddB NCD 3.977  3.977   4.462 0.001357 **
---
Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1

R-sq.(adj) =  0.0964lmer.REML score = -5.6441e+05  Scale est. =
2.0814e-07  n = 45013



On Sat, Jul 31, 2010 at 6:47 PM, Reinhold Kliegl
<reinhold.kliegl at gmail.com> wrote: