# [R] a question on df of linear model

Spencer Graves spencer.graves at pdf.com
Sat Apr 22 02:43:52 CEST 2006

```	  Short answer:  3=8-5.

(1) mf4Orth.lm:  The degrees of freedom for the output of lm is 5 =
the 4 linear regression parameters + the estimated residual standard
deviation.

(2) fm2Orth.lme:  The "lme" fit with 8 degrees of freedom adds to
that model random = ~I(age-11)|Subject, which estimated 3 additional
parameters:  The standard deviation of the adjustments for each subject
to the intercept and the I(age-11) term in the model plus the
correlation between those two random adjustments.

(3) The naive, traditional theory for nested hypotheses would say
that 2*log(likelihood ratio) is approximately distributed as chi-square
with degrees of freedom = the number of additional parameters estimated
in the larger model but fixed in the smaller one.  This number is 3 in
this case.  However, the traditional chi-square approximation to the
distribution of 2*log(likelihood ratio) is known NOT to work well in
this case because 2 of the 3 additional parameters estimated are fixed
at a boundary in the smaller model, and the third one becomes
meaningless in that case.  To understand this issue better and to see
how to get around it, please read ch. 2 of Pinheiro and Bates.

hope this helps.
spencer graves

Joe Moore wrote:

> Dear R-users:
>
> On page 155 of "Mixed-effects Models in S and S-Plus", the degree of
> freedoms of the anova comparison of lme and lm are 8 and 5.
>
> But when I use the following SAS code:
> proc glm data=ortho2;
>    class gender;
>    model distance = age|gender / solution ;
> run;
>
> The df is 3.
>
> Could you please explain this to me?
>
> Thanks
>
> Joe
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help