[R-SIG-Mac] predict.lm error

Robert Chatfield chatfield at alumni.rice.edu
Wed Aug 13 18:20:54 CEST 2008


I was simply following the instructions given (in the R2.5.1 release,  
I guess).

There was a request for the email about the routine.

I did not try to run the segment autonomously.

In fact, it was easier to find that I was making several mistaken
assumptions about the arguments to qqplot and predict,
specifically using "data =" rather than "newdata =" though
_perhaps_ qqplot could catch some of resulting mess.

If you would like further emails when a problem has
been resolved, it would be great to read that such email is
encouraged.  I just did not want further spam (such as this one!)

thank you!  Bob

PS:  NASA is trying to put institutional barriers to things like
updating R as you suggest, but I will do all I can.  It is important
to speak out against central-point-failure regimes of "computer
software security" in all large organizations.   These put updating
in the hands of those who have no experience with the packages
that scientists use.  "Do it with Excel" would be the reply to request,
or the request would be delayed until it could be billed to my  
resources.
This condition is all to common, ... sigh.

Glad that R is so distributed !  Thanks.

On Aug 13, 2008, at 12:46 AM, Prof Brian Ripley wrote:

> Please, R 2.5.1 is long obsolete.  As the R posting guide says,  
> update your R *before* posting.  At this point (with pre-releases of  
> R 2.7.2 imminent), please try a daily build of R-patched.
>
> It seems a problem with the quartz() device, and that has been  
> completely rewitten since.
>
> Your code is not directly reproducible: it is unhelpful not to give  
> an example which can just be pasted in.
>
> On Tue, 12 Aug 2008, Robert Chatfield wrote:
>
>> qqplot(z,z.predict$fit)
>> 2008-08-12 16:59:58.105 R[3203] *** Assertion failure in -
>> [RDeviceView lockFocus], AppKit.subproj/NSView.m:3248
>> 2008-08-12 16:59:58.105 R[3203] *** REngine.runREPL: caught ObjC
>> exception in the main loop!
>> *** Please report the following error on r-sig-mac at r-project.org
>> along with the full description of how to reproduce it:
>> *** reason: lockFocus sent to a view whose window is deferred and
>> does not yet have a corresponding platform window
>> *** name: NSInternalInconsistencyException, info: (null)
>> *** Version: R 2.5.1 (42083) R.app R 2.5.1 GUI 1.20 (4535)/i386
>> Consider saving your work soon in case this problem leads to a full
>> crash.
>>
>>
>> context:  Trying to understand the meaning of predict in the case of
>> predict.lm
>>
>> error occurs with qqplot(z,z.predict$fit)  of very much different
>> length vectors (z a matrix)
>>
>> predict.lm is supplied 40000 x,y pairs  for a two-parameter  
>> regression,
>> but
>>
>> length(z.predict$fit) is only 4912
>>
>> Code follows here
>>
>> #
>> x.jH.min = 10^x.ljH.min
>> x.jH.max=  10^x.ljH.max
>> y.NO.min=10^y.lNO.min
>> y.NO.max=10^y.lNO.max
>> #
>> x.jH.set = seq(x.jH.min, x.jH.max, by=x.jH.max/200)
>> y.NO.set = seq(y.NO.min, y.NO.max, by=y.NO.max/200)
>> #
>> n.x.jH.set = length(x.jH.set)
>> n.y.NO.set = length(y.NO.set)
>> x.d = vector(mode="numeric",length=n.x.jH.set*n.y.NO.set)
>> y.d = vector(mode="numeric",length=n.x.jH.set*n.y.NO.set)
>> length(x.d)
>> #
>> z = matrix(nrow=length(x.jH.set),ncol=length(y.NO.set))
>> dim(z)
>> z=matrix(nrow=n.x.jH.set,ncol=n.y.NO.set)
>> dim(z)
>> ind.d = 1
>> for ( xi  in seq(1,n.x.jH.set) ) {
>> 	xx = x.jH.set[xi]
>> 	for ( yi in seq(1,n.y.NO.set) ) {
>> 		yy = y.NO.set[yi]
>> 		z[xi,yj] = 10^(coefficients(logfit.wt.lm)[1] + coefficients
>> (logfit.wt.lm)[2]*log10(xx) + coefficients(logfit.wt.lm) 
>> [3]*log10(yy))
>> 		x.d[ind.d] = xx
>> 		y.d[ind.d] = yy
>> 		ind.d = ind.d + 1
>> 		}
>> 	}
>> ########################################################################
>> ############
>> #
>> xy.d = data.frame(cbind(x.d,y.d))
>> names(xy.d)=c("x","y")
>>
>> z.predict=predict(logfit.wt.lm,data=xy.d,se.fit = TRUE)
>>
>>
>>
>> ASSUMPTIONS
>> ...where these condistions are more or less all you need to run the
>> code snippet.
>> > length(x.d)
>> [1] 40000
>> > x.ljH.min
>> [1] 7.75
>> > x.ljH.max
>> [1] 10.25
>> > y.lNO.min
>> [1] 9.75
>> > y.lNO.max
>> [1] 12.25
>> >
>>
>> > coefficients(logfit.wt.lm
>> + )
>> (Intercept)  l.j.HCHO.m      l.NO.m
>> -0.4214285   0.4190370   0.5483868
>> >
>> 	[[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-SIG-Mac mailing list
>> R-SIG-Mac at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>>
>
> -- 
> 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-SIG-Mac mailing list