[R] Spline Question
David Winsemius
dwinsemius at comcast.net
Wed Feb 15 15:02:00 CET 2012
On Feb 15, 2012, at 12:26 AM, Rolf Turner wrote:
>
> David:
>
> Why do you say the OP wants a 503rd or 504th degree polynomial?
> He/she wants an interpolating spline.
I suppose that a piecewise approach could lower the degree of
polynomial needed, but it would still require estimating a huge number
of knot points and local coefficients for an overly specified basis,
and in a statistical sense still appear to be a massive case of over-
fitting. If you look at the data graphically, it appears to be a noisy
band of fairly uniform data between -1.2 and 1.2 with a few outliers.
>
> But that is precisely what "spline()" or "splinefun()" would give
> him/her.
Even if it did, I was trying too raise the question whether it _should_.
Attached is the result of this:
> plot(sensor.sample)
> ?spline
> lines(spline(x=sensor.sample[,1], y=sensor.sample[,2]), col = 2)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sensor.spline.fit.pdf
Type: application/pdf
Size: 152888 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120215/e384db74/attachment.pdf>
-------------- next part --------------
It's 149 KB (over the size limit for automatic posting which will get
it flagged for moderation). One of the other moderators can decide
whether it adds to the discussion.
There are a couple of points that on visual inspection could be said
to have been "missed" in that the incredibly complex spline function
has under shot some points. Increasing the number of points in the
spline() call to increasing multiples of 504 lets most of the circles
get touched by red lines but there is (at least) one point that is
resistant to inclusion. Perhaps it is at a point where there is a tie
and the mean is being plotted. (There are 4 ties in the x data:
> which(table(sensor.sample[,1]) >1)
1328565718.65 1328566162.65 1328566571.1 1328566608.9
179 305 404 414 )
So what? I think the whole exercise is misguided on statistical
grounds, AND we were not given any basis for considering other grounds
AND this is a statistical list.
--
David.
>
> So I don't understand the problem either!!!
>
> To the OP:
>
> What did you actually *do* to create your spline?
> Did you use spline() or splinefun()? And if not, why not?
>
> Do read the posting guide!
>
> cheers,
>
> Rolf
>
> On 15/02/12 15:37, David Winsemius wrote:
>>
>> On Feb 14, 2012, at 4:14 PM, Hasan Diwan wrote:
>>
>>>> dput(sensor.sample)
>>> structure(c(1328565718.65, 1328566608.9, 1328566162.65,
>>> 1328566571.1,
>> snipped 5 pages of data....
>>> 0.909395426580465, 0.806793813827552, 0.474927337412093,
>>> -0.0383057034947468,
>>> -0.454526719533217, -0.187379201707524, 0.249983084438962,
>>> 0.632832546743065,
>>> -0.986399675507447, -0.970631383787144), .Dim = c(504L,
>>> 2L), .Dimnames = list(
>>> NULL, c("sensors.sample", "")))
>>>
>>> What I'd like to do is get a spline through all the points.
>>
>> On the face of it that seems to be an extraordinary request. So
>> (not for the first time) I must not be understanding something.
>> Are you really asking for assistance in constructing a 503rd or
>> 504th degree polynomial? And if you are, then why pose the
>> question on a statistics-oriented mailing list. We only deal in
>> approximations to the Truth.
>>
>>
>>
>>> I'm
>>> thinking the spline function is my best approach. But a plot of the
>>> spline and the points shows it does not cross every one perfectly.
>>> Do
>>> I need to specify a particular method for this, or am I using the
>>> wrong approach? Thanks in advance! -- H
>>> --
>>> Sent from my mobile device
>>> Envoyait de mon portable
>>
>>
>
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list