Re: R-alpha: weights in glm

Thomas Lumley (thomas@biostat.washington.edu)
Tue, 17 Dec 1996 08:11:26 -0800 (PST)


Date: Tue, 17 Dec 1996 08:11:26 -0800 (PST)
From: Thomas Lumley <thomas@biostat.washington.edu>
To: r-testers <r-testers@stat.math.ethz.ch>
Subject: Re: R-alpha: weights in glm
In-Reply-To: <9612170857.AA05559@alpha.luc.ac.be>

On Tue, 17 Dec 1996, Jim Lindsey wrote:

> 1. When I try to use weights in glm, I get the message
> Error in numeric(nr): negative length vectors are not allowed.
> I have not been able to trace this down.

It seems to work for me, though I have to specify na.action.
[There is a problem with na.action, resulting from an incompatible 
improvement in the handling of options since 0.12.  In the past, 
options("na.action") returned a one-element list; it now returns the 
element. The fix to this is to change the default na.action in 
model.frame. A patch for this is at the end of this message. ]

R> glm(y~x,data=a,na.action=na.omit)

Call:  glm(y ~ x, data = a, na.action = na.omit) 

Coefficients:
(Intercept)            x  
    -0.4133       0.0483  

Degrees of Freedom: 10 Total; 8 Residual
Null Deviance: 9.595 
Residual Deviance: 9.589 
R> glm(y~x,data=a,na.action=na.omit,weights=w)

Call:  glm(y ~ x, data = a, na.action = na.omit, weights = w) 

Coefficients:
(Intercept)            x  
    -0.6144       0.2812  

Degrees of Freedom: 10 Total; 8 Residual
Null Deviance: 22.74 
Residual Deviance: 22.15 

thomas lumley
UW biostatistics


___________________PATCH_________________________________

*** models.orig Tue Dec 17 08:04:05 1996
--- models      Tue Dec 17 08:06:49 1996
***************
*** 128,134 ****
  
  "model.frame" <- 
  function (formula, data=sys.frame(sys.parent()), subset=NULL,
!       na.action=eval(as.name(options("na.action")$na.action)),
        S.style.names=F, use.data=F, process.offsets=T, ...)
  {
        if (!missing(data) || is.null(formula$model.frame)) {
--- 128,134 ----
  
  "model.frame" <- 
  function (formula, data=sys.frame(sys.parent()), subset=NULL,
!       na.action=get(options("na.action"),mode="function"),
        S.style.names=F, use.data=F, process.offsets=T, ...)
  {
        if (!missing(data) || is.null(formula$model.frame)) {

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- For info or help, send "info" or "help",
To [un]subscribe, send "[un]subscribe"
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-