[R] Problem plotting with xyplot

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Dec 26 00:00:18 CET 2003


You are trying to fit a loess curve to just five points: that is not 
sensible (and interpolates in S-PLUS, so I don't think it `works' there 
either).

Loess in R is not the same as loess in S-PLUS.  (The latter is
proprietary, and loess in R was implemented as a wrapper for the released
C/Fortran code from the same group of authors.)  You could have tried
looking at the warnings, the first four of which are

1: pseudoinverse used at 13
2: neighborhood radius 1
3: reciprocal condition number  0
4: There are other near singularities as well. 1

and indicate that there were problems in doing the loess fit.

What did you (or the authors) want here?  It is hard to think of a useful 
visualization of the pattern of 5 points beyond linear interpolation.


BTW, you want library(lattice) and not library(nlme).  In 1.8.1 
nlme attaches lattice, but in the next release it will not do so.


On Thu, 25 Dec 2003 DJNordlund at aol.com wrote:

> Hi all,
> 
> I am just learning R and I am trying to work through the book "Applied 
> Longitudinal Data Analysis" by Singer & Willett.  I have some code for this book 
> that supposedly works in S-Plus (I don't have S-Plus so I can't verify that) and 
> I am trying to run the examples in R.  Most of the examples run, but I have 
> one plot that gives me an error message.  I have provided a small dataset below 
> and the problematic code.
> 
> I don't know if the problem is a dissimilarity between R and S-Plus, or if I 
> have done something wrong because I don't know R well enough yet (I am also 
> working through MASS by Venables & Ripley, and the Pinheiro & Bates book on 
> Mixed-Effect Models).  
> 
> I looked at the warnings and also did traceback() which just took me to the 
> function listed in the error message.  I can't determine where the NA/NaN/Inf 
> is (are) coming from.
> 
> Any help would be appreciated.  I am using Rwin 1.8.1 (pre-compiled) on 
> Win2000 Professional.
> 
> Thanks,
> 
> Dan Nordlund
> 
> ## toy problem
> library(nlme)
> 
> tolerance.pp <- as.data.frame(
> matrix(c(   
> 9,11,2.23,
> 9,12,1.79,
> 9,13,1.90,
> 9,14,2.12,
> 9,15,2.66,
> 45,11,1.12,
> 45,12,1.45,
> 45,13,1.45,
> 45,14,1.45,
> 45,15,1.99,
> 268,11,1.45,
> 268,12,1.34,
> 268,13,1.99,
> 268,14,1.79,
> 268,15,1.34,
> 314,11,1.22,
> 314,12,1.22,
> 314,13,1.55,
> 314,14,1.12,
> 314,15,1.12
> ), byrow = T, ncol = 3 ))
> 
> names(tolerance.pp) <- c('id','age','tolerance')
> 
> ## this plots out fine
> xyplot(tolerance~age | factor(id), data=tolerance.pp)
> 
> ## this produces an error message
> xyplot(tolerance~age | factor(id), data=tolerance.pp, 
>   prepanel = function(x, y) prepanel.loess(x, y), 
>   panel = function(x, y){
>     panel.xyplot(x, y)
>     panel.loess(x, y)
>   }, ylim=c(0, 4), as.table=T)
> 
> 
> Error message is:
> 
> >Error in simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE, 
>  : 
> >        NA/NaN/Inf in foreign function call (arg 1)
> >In addition: There were 16 warnings (use warnings() to see them)
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 
> 

-- 
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-help mailing list