[Rd] predict in Pspline package (PR#2714)

Prof. Brian Ripley ripley at stats.ox.ac.uk
Tue Apr 1 09:39:03 MEST 2003


There is a pspline package, but no Pspline package.  I presume you mean
*pspline*, and have no idea how library(Pspline) would work.

For *pspline* your example works correctly on Linux, Solaris and Windows, 
so the problem is definitely with your installation (and perhaps your OS).

[Note that testing something where the fit is exact is not a very clever 
idea: you don't need smoothing splines to fit a cubic.  It is entirely 
possible that a realistic problem would work.]

In any case, we cannot debug your machine: you have the source code so
please debug it yourself and if a MacOS-specific patch is needed please
submit it to the maintainer (who might decline to add workarounds for
broken systems).


On Tue, 1 Apr 2003 h95mr at mun.ca wrote:

> To whom it may concern,
> 
> I don't know whether this is really a bug with the Pspline package or 
> only a problem with my installation. Things work fine in Linux but 
> not in Mac OS X (Darwin). Both system run the latest public versions 
> of R and Pspline.
> 
> predict.smooth.Pspline produces only NaN instead of predicted values 
> when norder>2:
> 
> >  library (Pspline)
> >  tt <- seq (0,1,length=20)
> >  xt <- tt^3
> >
> >  fit <- smooth.Pspline (tt, xt, norder=3,spar=0.0001, method=1)
> >  predict.smooth.Pspline (fit, tt, nderiv=0)[,1]
>   [1] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 
> NaN NaN NaN
> [20] NaN
> >
> 
> smooth.Pspline seems to work fine since
> >plot (tt,xt)
> >lines (fit)
> produces the expected result (curve fits data closely). Using norder 
> = 2 instead works fine:
> 
> >  fit2 <- smooth.Pspline(tt,xt,norder=2,spar=0.0001,method=1)
> >  lines(fit2, col="red")
> >  px <- predict(fit2,tt)[,1]
> >  round(px,2)
>   [1] 0.00 0.00 0.00 0.00 0.01 0.02 0.03 0.05 0.07 0.11 0.15 0.19 0.25 0.32 0.40
> [16] 0.49 0.60 0.72 0.85 0.99
> >  round(xt,2)
>   [1] 0.00 0.00 0.00 0.00 0.01 0.02 0.03 0.05 0.07 0.11 0.15 0.19 0.25 0.32 0.40
> [16] 0.49 0.60 0.72 0.85 1.00
> >
> >
> >  version
>           _                     
> platform powerpc-apple-darwin6.2
> arch     powerpc               
> os       darwin6.2             
> system   powerpc, darwin6.2    
> status                         
> major    1                     
> minor    6.1                   
> year     2002                  
> month    11                    
> day      01                    
> language R            

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list