Skip to content

interpolation

4 messages · René Mayer, David Winsemius

#
Dear R-users,
I have a complex line by xy-values (ordered by z).
And I would like to get interpolated y-values on the positions of x = 0:600.
How do I get the correct points?

x=c(790,790,790,790,790,786,783,778,778,766,763,761,761,761,715,628,521,350,160,134,134,129,108,101,93,111,161,249,288,243,139,45,7)

y=c(606,606,606,606,606,612,617,627,627,640,641,641,641,641,689,772,877,1048,1240,1272,1272,1258,1242,1239,1239,1214,1122,959,770,479,273,133,45)

z=c(0,29,58,87,116,145,174,203,232,261,290,319,348,377,406,435,464,493,522,551,580,609,638,667,696,725,754,783,812,841,870,899,928)


plot(y,x,type="b")

# this fails ?????
lines(approx(y,x),col="blue") # with xout = c(0:600)

thanks in advance,
Ren?
#
On Jan 11, 2010, at 7:44 AM, Ren? Mayer wrote:

            
That would plot x as a function of y (the reverse of the usual  
convention. Is that what you want. If so, then the statement that  
these are ordered by z is misleading. Ordering by z would suggest that  
each series is a function of z. What sort of interpolation do you want  
and in how many dimensions?
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
#
My problem is that x values increas with y until some point then the pattern
reverses. The whole line is a kind of U-shape with a right-buttom to  
middel-top diagonal at the end of it (a look at the plot makes it  
clearer). The interpolation (approx, spline) makes a zick-zack aut of  
it. What I need is to interpolate some points and to preserve the shape.

thanks in andvance
Ren?


Zitat von "David Winsemius" <dwinsemius at comcast.net>:
#
On Jan 11, 2010, at 11:49 AM, Ren? Mayer wrote:

            
x is mostly decreasing in the order you presented:

plot(x, type="l")
which line?
The starting values of x are the ones at the "top" of the plot you  
suggested.
which points? ... and as a function of what? You plotted x as a  
function of y. Are you interested in an approximation of the last 9  
points where the mathematical definition of a "function" of one  
variable in terms of one other variable might have meaning. At most  
other points you don't really have a function (unless you make a two  
dimensional parametric function of z)  because there are two values of  
x for each value of y.

Your question asked for an approximation of y as a function of x over  
a range (1:600) where that is not particularly sensible.. If you want  
segments over that range success might be possible, but you need to  
clarify what you want and how the program is supposed to figure out  
which leg of the segment you desire when there are two possible values  
of y.

-- David
David Winsemius, MD
Heritage Laboratories
West Hartford, CT