R-beta: more glm bugs
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Mon Jan 26 18:38:04 CET 1998
Thomas Lumley <thomas at biostat.washington.edu> writes:
>
> On Mon, 26 Jan 1998, Jim Lindsey wrote:
>
> > 1. At least on my computer, fitting a saturated gamma model with glm
> > gives a core dump:
> > glm(rgamma(20,1,1)~gl(20,1,20), family=Gamma)
>
> I can't reproduce this problem on 0.50-a4, 0.60 or 0.61.1.
Nor can I (RedHat Linux 4.2)
> > 2. Factor variables are not vectors!!
> > is.vector(gl(20,2,40)) gives FALSE
>
> Even stranger
> R> is.vector(factor(1:3))
> [1] FALSE
> R> is.factor(factor(1:3))
> [1] TRUE
> R> is.vector(as.vector(factor(1:3)))
> [1] TRUE
> R> is.factor(as.vector(factor(1:3)))
> [1] TRUE
> so that factor variables *can* be vectors, but aren't naturally.
The bottom line seems to be this:
> g<-1:3
> class(g)<-"junk"
> is.vector(g)
[1] FALSE
So vectors can't have attributes. Those are getting stripped off by
as.vector(), so in some sense something is making sense... does look
like a bit strange, BUT:
S-PLUS : Copyright (c) 1988, 1996 MathSoft, Inc.
S : Copyright AT&T.
Version 3.4 Release 1 for Sun SPARC, SunOS 5.3 : 1996
Working data will be in .Data
> g<-1:3
> class(g)<-"junk"
> is.vector(g)
[1] F
> is.vector(unclass(g))
[1] T
> g<-factor(1:3)
> is.vector(g)
[1] F
> is.vector(as.vector(g))
[1] T
I.e., exactly the same. And to top it off:
> is.vector(gl(20,2,40))
[1] F
er, that's cheating! There's no 'gl' function in S-plus, but:
> gl
function(n, k, length, labels = 1:n, ordered = FALSE)
factor(rep(rep(1:n, rep(k, n)), length = length), labels = labels)
(apparently I hacked one up at some earlier point while trying to run
R's glm+lm demo through Splus...)
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list