Re: [R] Predict polynomial problem

2010-01-19 Thread Peter Ehlers
Charles C. Berry wrote: On Tue, 19 Jan 2010, Charles C. Berry wrote: and the values in those places are different: On Tue, 19 Jan 2010, Barry Rowlingson wrote: On Tue, Jan 19, 2010 at 1:36 AM, Charles C. Berry wrote: > Its the environment thing. > > I think you want something like t

Re: [R] Predict polynomial problem

2010-01-19 Thread Peter Ehlers
Barry Rowlingson wrote: On Tue, Jan 19, 2010 at 5:37 PM, Charles C. Berry wrote: Note: i <- 20 bquote(y ~ poly(x,.(i))) y ~ poly(x, 20) I see it now. bquote(y~poly(x,.(i))) gets it's 'i' there and then, sticks it in the returned expression as the value '20', so any further evaluati

Re: [R] Predict polynomial problem

2010-01-19 Thread Thomas Lumley
On Tue, 19 Jan 2010, Barry Rowlingson wrote: On Tue, Jan 19, 2010 at 5:37 PM, Charles C. Berry wrote: Note: i <- 20 bquote(y ~ poly(x,.(i))) y ~ poly(x, 20) I see it now. bquote(y~poly(x,.(i))) gets it's 'i' there and then, sticks it in the returned expression as the value '20', so

Re: [R] Predict polynomial problem

2010-01-19 Thread Barry Rowlingson
On Tue, Jan 19, 2010 at 5:37 PM, Charles C. Berry wrote: > >> Note: >> >> i <- 20 >>> bquote(y ~ poly(x,.(i))) >>> >> y ~ poly(x, 20) >> >> I see it now. bquote(y~poly(x,.(i))) gets it's 'i' there and then, sticks it in the returned expression as the value '20', so any further evaluations get

Re: [R] Predict polynomial problem

2010-01-19 Thread Charles C. Berry
and the values in those places are different: On Tue, 19 Jan 2010, Barry Rowlingson wrote: On Tue, Jan 19, 2010 at 1:36 AM, Charles C. Berry wrote: Its the environment thing. I think you want something like this:        models[[i]]=lm( bquote( y ~ poly(x,.(i)) ), data=d) Use        terms

Re: [R] Predict polynomial problem

2010-01-19 Thread Charles C. Berry
On Tue, 19 Jan 2010, Charles C. Berry wrote: and the values in those places are different: On Tue, 19 Jan 2010, Barry Rowlingson wrote: On Tue, Jan 19, 2010 at 1:36 AM, Charles C. Berry wrote: > Its the environment thing. > > I think you want something like this: > > ? ? ? ? ? ? ? ?mo

Re: [R] Predict polynomial problem

2010-01-19 Thread Gavin Simpson
On Tue, 2010-01-19 at 08:27 +, Barry Rowlingson wrote: > On Tue, Jan 19, 2010 at 1:36 AM, Charles C. Berry > wrote: > > > Its the environment thing. > > > > I think you want something like this: > > > >models[[i]]=lm( bquote( y ~ poly(x,.(i)) ), data=d) > > > > Use > >terms(

Re: [R] Predict polynomial problem

2010-01-19 Thread Barry Rowlingson
On Tue, Jan 19, 2010 at 1:36 AM, Charles C. Berry wrote: > Its the environment thing. > > I think you want something like this: > >        models[[i]]=lm( bquote( y ~ poly(x,.(i)) ), data=d) > > Use >        terms( mmn[[3]] ) > > both with and without this change and > > >        ls( env = enviro

Re: [R] Predict polynomial problem

2010-01-18 Thread Charles C. Berry
On Mon, 18 Jan 2010, Barry Rowlingson wrote: I have a function that fits polynomial models for the orders in n: lmn <- function(d,n){ models=list() for(i in n){ models[[i]]=lm(y~poly(x,i),data=d) } return(models) } My data is: > d=data.frame(x=1:10,y=runif(10)) So first just do it for

Re: [R] Predict polynomial problem

2010-01-18 Thread Bert Gunter
Subject: [R] Predict polynomial problem I have a function that fits polynomial models for the orders in n: lmn <- function(d,n){ models=list() for(i in n){ models[[i]]=lm(y~poly(x,i),data=d) } return(models) } My data is: > d=data.frame(x=1:10,y=runif(10)) So first just do

[R] Predict polynomial problem

2010-01-18 Thread Barry Rowlingson
I have a function that fits polynomial models for the orders in n: lmn <- function(d,n){ models=list() for(i in n){ models[[i]]=lm(y~poly(x,i),data=d) } return(models) } My data is: > d=data.frame(x=1:10,y=runif(10)) So first just do it for a cubic: > mmn = lmn(d,3) > predict