[R] Question on function "glm.fit"

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Tue Nov 9 20:05:53 CET 1999


"DEVAS, Vipul" <Vipul.Devas at rp-rorer.com> writes:

> I have a code that contains function "glm.fit" and it works in S-PLUS.  But
> this same code (with some minor changes) does not work in R.  I am supplying
> the part of the code.  Can somebody help with this problem?
> The code
> ***************************************************
> x1 <- seq(from=-1,to=2, length=20)
> x2 <- (rep(1:5,4))/4
> x <- cbind(1,x1,x2)
> y <- c(0,1,1,1,1,1,0,0,1,1,1,0,1,0,1,1,1,1,1,1)
> glm.fit(x,y,fam=binomial(link=logit))$coeff
> *********************************************************

Aha! We've had a similar report but with no reproduction instructions.
Thank you very much for the clear example.

The thing that happens is that your x has no dimnames, but is a
matrix, so xnames and xxnames inside glm.fit are NULL and when you get
to 

    names(fit$effects) <- c(xxnames[seq(fit$rank)], rep("", nobs - 
        fit$rank))

everything comes to a screeching halt. If you add column names, things
are OK:

> colnames(x)<-1:3
> glm.fit(x,y,fam=binomial(link=logit))$coeff
          1           2           3 
-0.08959875  0.44189065  1.45697672 

I'm not really sure whether there's a bug in cbind, glm.fit, or both...

-- 
   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