I have the ctlns
list and I am trying to produce some visualization of the data
ctlns<-list(structure(list(level = 10, x = c(0.101666666666667, 0.06,
0.0385714285714286, 0.035, 0.035, 0.035, 0.04, 0.0433333333333333,
0.05, 0.0516666666666667, 0.06, 0.0606416584402764, 0.0606416584402764,
0.0766666666666667, 0.0766666666666667, 0.0933333333333333, 0.0933333333333333,
0.0975, 0.11, 0.110956351152526, 0.110956351152526, 0.135, 0.135
), y = c(0.01, 0.04125, 0.06, 0.11, 0.16, 0.21, 0.26, 0.31, 0.36,
0.41, 0.458123195380173, 0.46, 0.51, 0.56, 0.61, 0.66, 0.71,
0.76, 0.808123195380173, 0.81, 0.86, 0.91, 0.96)), .Names = c("level",
"x", "y")))
Then I,
plot(ctlns[[1]]$x,ctlns[[1]]$y, xlim=c(0,.21), ylim=c(0,1), lwd=2, type="l", col="darkred" )
And I get the plot
I would like to smooth the upper part of the red curve (y>0.2) while maintaining some of the curved structure (y<0.2)
lines(lowess(ctlns[[1]]$x,ctlns[[1]]$y,f=2/3), lwd=2, col="darkblue")
does a fine job for the former part but deletes the lower part of the curve. I have the following questions:
- Why does this happen that?
- How can I preserve and smooth the lower part of the red curve? Or maybe combine curves/smooth lines?
- Ignoring the red curve, how can I instruct lowess based on the blue curve data to extrapolate the values till y=0?
EDIT after discussion with agstudy
Because of of the curved nature of the red line, I was thinking what I need is probably a not a function smoothing y~x
but rather a graph function that connects the points x, y
with some kind of curved line. The points should be connected in order they appear within their vectors (x[1]
with y[1]
and so on...)
Is this possible?
$x
and$y
, doing the fit, and then swapping back if desired. – Carl Witthofty=f(x)
is not single-valued, whilex=g(y)
is. – Carl Witthoft