Re: [Rd] Strange behavior of model.frame() when given subset

From: Liaw, Andy <andy_liaw_at_merck.com>
Date: Wed, 25 Apr 2012 09:41:57 -0400

Never mind. Found the problem: The package has been missing a subset method for the "lp" class since [...]. Adding "[.lp" solved the problem.

Cheers,
Andy

-----Original Message-----
From: r-devel-bounces_at_r-project.org [mailto:r-devel-bounces_at_r-project.org] On Behalf Of Liaw, Andy Sent: Wednesday, April 25, 2012 8:34 AM
To: r-devel_at_r-project.org
Subject: [Rd] Strange behavior of model.frame() when given subset

Dear R-devel,

I recent got a bug report from a locfit user about the use of the subset argument when calling locfit(). Basically the symptom is that the following two calls should produce the same result, but they don't:

locfit(y ~ lp(x, h=1), data=subset(dat, x > 1)) locfit(y ~ lp(x, h=1), data=dat, subset= x > 1)

I've tracked the problem down to something shown in the following example, but have no idea how to get further:

R> x <- 1:5
R> y <- sample(5)
R> m1 <- model.frame(y ~ lp(x))
R> m2 <- model.frame(y ~ lp(x), subset=x>1)
R> class(m1[[2]])

[1] "lp"

R> class(m2[[2]])
[1] "matrix"

So basically model.frame() seems to treat the lp() term differently depending on whether the subset argument is present or not. Is this supposed to happen? str(m1) and str(m2) show that besides having one row less and the lp() term being of class matrix instead of "lp", there's no difference between m1 and m2.

I'd really appreciate it if anyone shed some light on this.

Best,
Andy
Merck Research Labs

Notice: This e-mail message, together with any attachme...{{dropped:11}}



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Notice: This e-mail message, together with any attachme...{{dropped:11}}

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed 25 Apr 2012 - 13:46:53 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

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 Wed 25 Apr 2012 - 21:30:49 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