[R] Odp: fit data with y = x^-1

From: Petr PIKAL <petr.pikal_at_precheza.cz>
Date: Mon, 07 Jun 2010 14:41:21 +0200

Hi

r-help-bounces_at_r-project.org napsal dne 07.06.2010 14:28:58:

> Dear list,
>
> I am getting weired with fitting data with a 1/x-polynomial. Suggest I
have
> the following data:
>
> x <- c(1,2,3,4,5,6,7)
> y <- c(100,20,4,2,1,.3,.1)
>
> I may fit this with a linear model
>
> fit1 = lm(y ~ I(x))

fit1 = lm(y ~ x)
is enough

>
> Getting plot out of this model I applied
> library(polynom)
> pol1 = polynomial(fit1$coefficients)
> f1 = as.function(pol1)
>
> plot(x,y)
> lines(x, f1(x), col = 2)

why not

plot(x,y)
lines(x, fitted(fit))

>
> Clearly, this model appears insufficient. Therefore I intended to aplly
> fit2 = lm(y ~ I(1/x))
> pol2 = polynomial(fit2$coefficients)
> f2 = as.function(pol2)
> lines(x, f2(x), col = 3)

The same applies here

fit3 = lm(y ~ I(1/x^3))
lines(x, fitted(fit3))

seems to give quite reasonable output.

Regards
Petr

>
> as this would be much more pleasant. However, the second model does not
work
> at all.
>
>
> Does anyone know about how to correctly fit an x^-1-polynomial to my
data
> cloud?
>
>
> Many thanks in advance,
>
>
> behelfsadresse
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 07 Jun 2010 - 12:43:51 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 Mon 07 Jun 2010 - 13:20:27 GMT.

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

list of date sections of archive