[R] Splines
vito muggeo
vmuggeo at dssm.unipa.it
Fri Oct 5 11:01:15 CEST 2007
As reported in ?spline, you should use splinefun() instead.
ff<-splinefun(x,y)
ff(x0)
where x0=5.25 is your case.
best,
vito
stat stat ha scritto:
> I want to fit a cubic spline of x on y. where :
>
> x
> [1] 467 468 460 460 450 432 419 420 423 423
> y
> [1] 1 2 3 4 5 6 7 8 9 10
>
> using the syntax
>
> spline(y, x)
>
> I got following output :
>
> $x
> [1] 1.000000 1.310345 1.620690 1.931034 2.241379 2.551724 2.862069
> [8] 3.172414 3.482759 3.793103 4.103448 4.413793 4.724138 5.034483
> [15] 5.344828 5.655172 5.965517 6.275862 6.586207 6.896552 7.206897
> [22] 7.517241 7.827586 8.137931 8.448276 8.758621 9.068966 9.379310
> [29] 9.689655 10.000000
> $y
> [1] 467.0000 469.5381 469.8643 468.4865 465.9444 463.0284 460.6479 459.6560
> [9] 459.8737 460.2296 459.6313 457.4921 454.0094 449.4482 444.1040 438.3613
> [17] 432.6204 427.2892 422.8183 419.6733 418.2646 418.3633 419.3283 420.5202
> [25] 421.5768 422.4555 423.1312 423.5419 423.5480 423.0000
>
> Now I want to get what is the value of y at x = 5.25. Can anyone tell me how to find that?
>
>
>
> thanks in advance
>
> ---------------------------------
> Meet people who discuss and share your passions. Join them now.
> [[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.
>
>
--
====================================
Vito M.R. Muggeo
Dip.to Sc Statist e Matem `Vianelli'
Università di Palermo
viale delle Scienze, edificio 13
90128 Palermo - ITALY
tel: 091 6626240
fax: 091 485726/485612
More information about the R-help
mailing list