Inverse Prediction with splines
On Jan 20, 2011, at 2:37 PM, <Jeffrey.Morris at sanofipasteur.com> <Jeffrey.Morris at sanofipasteur.com
> wrote:
Hello, I have fit a simple spline model to the following data. Data x y 0 1.298 2 0.605 3 0.507 4 0.399 5 0.281 6 0.203 7 0.150 8 0.101 Model Sp.1=lm(y~bs(x,df=4)) Now I wish to inverse predict the x for y=.75, say. Optimize works fine for a polynomial but I can figure out how to get the spline model into the function argument.
Why not pass the reversed x and y vectors from the spline fit to approxfun()? > pred.Spl <- predict(Sp.1, data.frame(x=seq(0,8, by=0.01) ) ) > approxfun(x=pred.Spl, y=seq(0,8, by=0.01) )(0.75) [1] 1.447311 Looks plausible, anyway.
David. > > Can anyone help me out. > > Thanks!! > > Jeff > > Jeff Morris > Sanofi Pasteur > > > > This communication, including any attachments, is intended solely > for the use of the addressee and may contain information which is > privileged, confidential, exempt from disclosure under applicable > law or subject to copyright. If you are not an intended recipient, > any use, disclosure, distribution, reproduction, review or copying > is unauthorized and may be unlawful. If you have received this > transmission in error, please notify the sender immediately. Thank > you. > > Cette communication,y compris les pieces jointes, est reservee a > l'usage exclusif du destinataire et peut contenir des informations > privilegiees, confidentielles, exemptees de divulgation selon la loi > ou protegees par les droits de publication. Si vous n'etes pas un > destinataire, toute utilisation, divulgation, distribution, > reproduction, examen ou copie est non-autorisee et peut etre > illegale. Si vous avez recu cette communication par erreur, veuillez > aviser l'expediteur immediatement. Merci. > > > [[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. David Winsemius, MD West Hartford, CT