)")
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 <-
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^
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
>> 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
>
>
>>
>>
>> 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)")
>>>
>
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
>
> 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
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
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
help.search("polynomial")
---
Jeff NewmillerThe . . Go Live...
DCN:Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playin
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).
11 matches
Mail list logo