On 13/01/2009, David Winsemius <dwinsem...@comcast.net> wrote: > It's fairly clear from the documentation that approxfun() will not > extrapolate. > > help.search("extrapolate") > library(Hmisc) > ?approxExtrap > > Some sort of minimization approach: > > > approxExtrap(x=c(0,5,10,15,20), y=c(16,45,77,101,125),xout=c(-4,0,4)) > $x > [1] -4 0 4 > > $y > [1] -7.2 16.0 39.2 > > > approxExtrap(x=c(0,5,10,15,20), > y=c(16,45,77,101,125),xout=seq(-2.8,-2.6, by=0.01)) > $x > [1] -2.80 -2.79 -2.78 -2.77 -2.76 -2.75 -2.74 -2.73 -2.72 -2.71 > -2.70 -2.69 -2.68 > [14] -2.67 -2.66 -2.65 -2.64 -2.63 -2.62 -2.61 -2.60 > > $y > [1] -0.240 -0.182 -0.124 -0.066 -0.008 0.050 0.108 0.166 0.224 > 0.282 0.340 > [12] 0.398 0.456 0.514 0.572 0.630 0.688 0.746 0.804 0.862 > 0.920 > > How accurate do you need the answer? > > I tried Hmisc's inverseFunction(), but it returned 0 for an argument > of zero: > > > invF <- inverseFunction(x=c(0,5,10,15,20), y=c(16,45,77,101,125)) > > invF(0) > > So I then hacked Harrell's inverseFunction by substituting > approxExtrap in every in instance > where approx appeared, creating invFunc2: > > then > > > invF <- invFunc2(x=c(0,5,10,15,20), y=c(16,45,77,101,125)) > > > > invF(0) > [1] -2.758621 I have compared your answer to those obtained from gnuplot, scilab and qtiplot; all report a result of x=-3.28. Why is r different?
______________________________________________ R-help@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.