Re: [R] solving x in a polynomial function

2013-03-01 Thread Rui Barradas
)") Should this be: if(names(model)[1] == "(Intercept)") A.K. - Original Message - From: Rui Barradas To: Mike Rennie Cc: r-help Mailing List Sent: Friday, March 1, 2013 3:18 PM Subject: Re: [R] solving x in a polynomial function Hello, Try the following. a <-

Re: [R] solving x in a polynomial function

2013-03-01 Thread Rui Barradas
g List Sent: Friday, March 1, 2013 3:18 PM Subject: Re: [R] solving x in a polynomial function Hello, Try the following. a <- 1:10 b <- c(1, 2, 2.5, 3, 3.5, 4, 6, 7, 7.5, 8) dat <- data.frame(a = a, b = b) # for lm(), it's better to use a df po.lm <- lm(a~b+I(b^2)+I(b^

Re: [R] solving x in a polynomial function

2013-03-01 Thread William Dunlap
gt; Behalf > Of Mike Rennie > Sent: Friday, March 01, 2013 1:48 PM > To: Peter Ehlers > Cc: R help > Subject: Re: [R] solving x in a polynomial function > > Hi Peter, > > With the edit you suggested, now I'm just getting back the value of a > that I put in, not the

Re: [R] solving x in a polynomial function

2013-03-01 Thread Mike Rennie
>> So I think there's a calculation error somehwere. >> >> You need to replace the following line >> >>if(names(model)[1] == "(Intercept)") >> >> with >> >>if(names(coef(model))[1] == "(Intercept)") >> >> >> Peter Ehlers >

Re: [R] solving x in a polynomial function

2013-03-01 Thread Mike Rennie
> >> >> >> On 3/1/13, arun wrote: >>> Hi Rui, >>> >>> Looks like a bug: >>> ###if(names(model)[1] = "(Intercept)") >>> Should this be: >>> >>> if(names(model)[1] == "(Intercept)") >>> >

Re: [R] solving x in a polynomial function

2013-03-01 Thread Peter Ehlers
r-help Mailing List Sent: Friday, March 1, 2013 3:18 PM Subject: Re: [R] solving x in a polynomial function Hello, Try the following. a <- 1:10 b <- c(1, 2, 2.5, 3, 3.5, 4, 6, 7, 7.5, 8) dat <- data.frame(a = a, b = b) # for lm(), it's better to use a df po.lm <- lm(a

Re: [R] solving x in a polynomial function

2013-03-01 Thread Mike Rennie
> > if(names(model)[1] == "(Intercept)") > > A.K. > > > > - Original Message - > From: Rui Barradas > To: Mike Rennie > Cc: r-help Mailing List > Sent: Friday, March 1, 2013 3:18 PM > Subject: Re: [R] solving x in a polynomial function

Re: [R] solving x in a polynomial function

2013-03-01 Thread arun
Hi Rui, Looks like a bug: ###if(names(model)[1] = "(Intercept)") Should this be: if(names(model)[1] == "(Intercept)") A.K. - Original Message - From: Rui Barradas To: Mike Rennie Cc: r-help Mailing List Sent: Friday, March 1, 2013 3:18 PM Subject: Re: [R] solvi

Re: [R] solving x in a polynomial function

2013-03-01 Thread Rui Barradas
Hello, Try the following. a <- 1:10 b <- c(1, 2, 2.5, 3, 3.5, 4, 6, 7, 7.5, 8) dat <- data.frame(a = a, b = b) # for lm(), it's better to use a df po.lm <- lm(a~b+I(b^2)+I(b^3)+I(b^4), data = dat); summary(po.lm) realroots <- function(model, b){ is.zero <- function(x, tol = .Machine

Re: [R] solving x in a polynomial function

2013-03-01 Thread Jeff Newmiller
help.search("polynomial") --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playin

[R] solving x in a polynomial function

2013-03-01 Thread Mike Rennie
Hi there, Does anyone know how I solve for x from a given y in a polynomial function? Here's some example code: ##example file a<-1:10 b<-c(1,2,2.5,3,3.5,4,6,7,7.5,8) po.lm<-lm(a~b+I(b^2)+I(b^3)+I(b^4)); summary(po.lm) (please ignore that the model is severely overfit- that's not the point).