As pointed out by Ben Bolker in a comment, PQL versus GHQ for Gaussian responses should not make a difference. However, as shown above, results of mgcv::gam
, mgcv::gamm
and gamm4::gamm4
differ. These differencesDifferences can be due to different optimizers used, but such differences would generally be small. The standard error differences for the parametric terms and the difference in F-values for the smooth of Year
seem substantial. Posting a reproducible example, I don't know why, could be helpfuldue to instability due to relatively small sample size.
With 72 observations, and the presented plots of the observed data,If you may want to keep the model simple. Sample size is small,test for differences between the treatments seem slight. A factor, a by
smooth might be overdoingmore appriate (although it, but whether that is the case is perhaps an empirical question; at least a factor smooth takes up less degreesmore df than a by
factor smooth, but I honestly don't know how to use those for testing differences).
I am not sure whyAssuming you want to have separate smooths pertake level PlotA
, for treatment as it appears the interest is inreference category, and check whether each of the effectother two levels differ, I would take the 'ordered factor' approach. This directly allows you to test whether the parametric and smooth terms differ between the different levels of Treatment
:
leaf_rand$oTreatment <- ordered(leaf_rand$Treatment)
gam_model <- gamm4(N.P ~ Treatment + s(Year, k = 5) +
s(Year, by = oTreatment, k = 5),
random = ~(1|Plot),
data = leaf_rand, REML = TRUE)
gam_model1 <- gamm(N.P ~ Treatment + s(Year, k = 5) +
s(Year, by = oTreatment, k = 5),
random = list(Plot=~1),
data = leaf_rand, REML = TRUE)
gam_model2 <- gam(N.P ~ Treatment + s(Year, k = 5) +
s(Year, by = oTreatment, k = 5) +
s(Plot, bs = 're'), data = leaf_rand,
method="REML")
# Model summaries and plots
summary(gam_model$gam)
summary(gam_model1$gam)
summary(gam_model2)
plot(gam_model$gam)
plot(gam_model1$gam)
plot(gam_model2)
The summaries indicate a difference between the smooth effects of Year
between Treatment
levels A
and C
. Consider keeping onlyAt least, the random intercept termp-values are $< .05$,but you might want to consider correcting for multiple testing. Only the Plotgamm4
model indicates a difference in the parametric effect of (it seems to explain most variability, going byTreatment
levels A
and C
. But point estimates are all in the same direction.
Inspecting the plots (and Fedf
valuevalues) shows that the difference between the two differing levels can be described by a negative linear effect over time.
I do not see the use of comparing fit between the results of the fitted gam
), and modeling only interactions of Yeargamm
and Treatmentgamm4
, either models. They are essentially equivalent models with a 'linear' interaction as you specified in your model formula, or aidentical degrees of freedom by
or factor smooth(hence the warnings), they just used different estimation and/or optimization approaches.