Re: [Rd] R-devel Digest, Vol 62, Issue 24

From: John Maindonald <john.maindonald_at_anu.edu.au>
Date: Fri, 25 Apr 2008 10:24:19 +1000

Actually, this may be a useful feature! It allows calculation of a basis for the orthogonal complement of the space spanned by model.matrix(lm(y ~ poly(x,12)). However, the default ought surely to be to disallow df > k-1 in poly(x,df), where k = length(unique(x)).

John Maindonald email: john.maindonald_at_anu.edu.au phone : +61 2 (6125)3473 fax : +61 2(6125)5549 Centre for Mathematics & Its Applications, Room 1194, John Dedman Mathematical Sciences Building (Building 27) Australian National University, Canberra ACT 0200.

On 24 Apr 2008, at 8:00 PM, r-devel-request_at_r-project.org wrote:

> From: russell-lenth_at_uiowa.edu
> Date: 24 April 2008 3:05:28 AM
> To: r-devel_at_stat.math.ethz.ch
> Cc: R-bugs_at_biostat.ku.dk
> Subject: [Rd] poly() can exceed degree k - 1 for k distinct points
> (PR#11251)
>
>
> The poly() function can create more variables than can be fitted when
> there are replicated values. In the example below, 'x' has only 5
> distinct values, but I can apparently fit a 12th-degree polynomial
> with
> no error messages or even nonzero coefficients:
>
> R> x = rep(1:5,3)
> R> y = rnorm(15)
> R> lm(y ~ poly(x, 12))
>
> Call:
> lm(formula = y ~ poly(x, 12))
>
> Coefficients:
> (Intercept) poly(x, 12)1 poly(x, 12)2 poly(x, 12)3
> -0.27442 0.35822 -0.26412 2.11780
> poly(x, 12)4 poly(x, 12)5 poly(x, 12)6 poly(x, 12)7
> 1.83117 -0.09260 -0.48572 1.94030
> poly(x, 12)8 poly(x, 12)9 poly(x, 12)10 poly(x, 12)11
> -0.88297 -1.04556 0.74289 -0.01422
> poly(x, 12)12

> -0.46548
>
<snip>
<snip>

> [I thought I submitted this via the website yesterday, but I can
> find no
> trace of it. I apologize if this is a duplicate, but I don't think
> it is.]
> --
> Russell V. Lenth, Professor
> Department of Statistics
> & Actuarial Science (319)335-0814 FAX (319)335-3017
> The University of Iowa russell-lenth_at_uiowa.edu
> Iowa City, IA 52242 USA http://www.stat.uiowa.edu/~rlenth/

        [[alternative HTML version deleted]]



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri 25 Apr 2008 - 00:27:42 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 25 Apr 2008 - 04:31:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive