## Info

Arrival time (hours)

Fig. 5.7 Residuals versus arrival time for each sex-food treatment combination. A LOESS smoother with a span of 0.5 was fitted to aid visual interpretation

The term j3 x ArrivalTimey has been replaced by /(ArrivalTimey}, which is now a smoother (smoothing spline}; see also Chapter 3. If the resulting shape of the smoother is a straight line, we know that in the model presented in step 9 of the protocol, arrival time has indeed a linear effect. However, if the smoother is not a straight line, the linear mixed effects model is wrong!

The following R code fits the additive mixed model.

> library(mgcv)

> M6 <- gamm(LogNeg ~ FoodTreatment + s(ArrivalTime), random = list(Nest =~ 1), data = Owls)

Formulation of the random intercept is slightly different and uses the list argument. Just do it, it's better not to ask why at this stage. Because no family argument is specified, the gamm function uses the Gaussian distribution. Other options are the Poisson, binomial, negative binomial, etc., and these will be discussed in Chapter 9. The output from gamm is slightly confusing. If you type summary(M6), R gives:

Length Class Mode lme 18 lme list gam 2 5 gam list

The object M6 has an lme component and a gam component. You can use the following commands:

Fig. 5.8 Estimated smoother for the additive mixed model. The solid line is the estimated smoother and the dotted lines are 95% point-wise confidence bands. The horizontal axis shows the arrival time in hours (25 is 01.00 AM) and the vertical axis the contribution of the smoother to the fitted values. The smoother is centred around 0

### ArrivalTime

Fig. 5.8 Estimated smoother for the additive mixed model. The solid line is the estimated smoother and the dotted lines are 95% point-wise confidence bands. The horizontal axis shows the arrival time in hours (25 is 01.00 AM) and the vertical axis the contribution of the smoother to the fitted values. The smoother is centred around 0

• summary(M6\$gam). This gives detailed output on the smoothers and parametric terms in the models.

• anova(M6\$gam). This command gives a more compact presentation of the results as compared to the summary(M6 \$gam) command. The anova table is not doing sequential testing!

• plot(M6\$gam). This command plots the smoothers.

• plot(M6\$lme). This command plots the normalised residuals versus fitted values and can be used to assess homogeneity.

• summary(M6\$lme). Detailed output on the estimated variances. Not everything is relevant.

Good, let us now have a look at the shape of the smoother and see whether it is a straight line or not. The command plot(M6\$gam) produces the smoother in Fig. 5.8 and indicates that it is bad news for the linear mixed effects model; the effect of arrival time is non-linear. The summary(M6\$gam) gives the following output.

Family: Gaussian. Link function: identity Formula: LogNeg ~ FoodTreatment + s(ArrivalTime)

Parametric coefficients:

(Intercept) 0.41379 0.02222 18.622 <2e-16

FoodTreaSatiated -0.17496 0.01937 -9.035 <2e-16

Approximate significance of smooth terms:

edf Est.rank F p-value s(ArrivalTime) 6.921 9 10.26 8.93e-15

The estimated regression parameter for food treatment is the similar to the one obtained by the linear mixed effects model. The smoother is significant and has nearly seven degrees of freedom! A straight line would have had one degree of freedom.

We also tried models with two smoothers using the by command (one smoother per sex or one smoother per treatment), but the AIC indicated that the model with one smoother was the best.

So, it seems that there is a lot of sibling negotiation at around 23.00 hours and a second (though smaller) peak at about 01.00-02.00 hours.