[R] Problems with rlm
Ed Hagen
e.hagen at biologie.hu-berlin.de
Wed Apr 7 19:50:47 CEST 2004
Erin Hodgess wrote:
> Please don't use c as a vector name. There is a function c and
> that function gets overwritten.
Thanks for that tip. I was actually using different variable names in
my script, but simplified them for the posting. I just tried it using
the names 'cpavg' and 'havg'. The first time I called rlm it worked,
but I got the following errors the second and third time I ran it:
> out <- rlm(havg ~ cpavg)
Error: cannot allocate vector of size 4178828 Kb
> out <- rlm(havg ~ cpavg)
Error in model.matrix.default(mt, mf, contrasts) :
negative length vectors are not allowed
Liaw, Andy wrote:
> You have not given us nearly enough info.
> What OS / R version / MASS version (you are using MASS, no?) are you
> using?
WinXP Pro 2002. Service Pack 1. 512K RAM. R v. 1.8.1. MASS v. 7.1-11.
AMD Athlon XP 2600+, 1.91. GHz.
> Do you have lots of other stuff in the workspace when
> you tried to run this?
Yes. A lot of stuff is needed to produce the variables CPRATIO and HEIGHTZ
> What does gc() tell you?
After running the script, but before running the code in question:
used (Mb) gc trigger (Mb)
Ncells 720521 19.3 1073225 28.7
Vcells 209563 1.6 786432 6.0
gc() called during and after running the code in question:
> d2 <- na.omit(data.frame(CPRATIO, HEIGHTZ, FAMILYID))
> cavg <- tapply(d2$CPRATIO, d2$FAMILYID, mean)
> havg <- tapply(d2$HEIGHTZ, d2$FAMILYID, mean)
> gc()
used (Mb) gc trigger (Mb)
Ncells 720802 19.3 1166886 31.2
Vcells 210286 1.7 786432 6.0
> out <- rlm(havg ~ cavg)
Error in model.matrix.default(mt, mf, contrasts) :
cannot allocate vector of length 2146959361
> gc()
used (Mb) gc trigger (Mb)
Ncells 720819 19.3 1166886 31.2
Vcells 210334 1.7 786432 6.0
As I noted in my first posting, rlm works fine with CPRATIO and HEIGHTZ,
which are much larger datasets, if that's any clue (though even CPRATIO
and HEIGHTZ are still quite small: 85 cases each). After running the
main script, I ran
> out <- rlm(HEIGHTZ ~ CPRATIO)
about 20 consecutive times with no problems. Yet running rlm with the
smaller havg and cavg immediately produces errors, and R will usually
crash after the second or third attempt.
Many thanks for the quick responses,
Ed.
--
Edward H. Hagen Institute for Theoretical Biology
phone: +49/30 2093-8649 Humboldt-Universität zu Berlin
fax: +49/30 2093-8801 Invalidenstraße 43
http://itb.biologie.hu-berlin.de/~hagen 10115 Berlin, Germany
More information about the R-help
mailing list