From ripley at stats.ox.ac.uk  Thu Jan 20 08:29:19 2011
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Thu, 20 Jan 2011 07:29:19 +0000 (GMT)
Subject: [Rd] buglet in weighted.residuals(mlmObject)
In-Reply-To: <77EB52C6DD32BA4D87471DCD70C8D70003D65407@NA-PA-VBE03.na.tibco.com>
References: <77EB52C6DD32BA4D87471DCD70C8D70003D65407@NA-PA-VBE03.na.tibco.com>
Message-ID: <alpine.LFD.2.00.1101200729060.27434@gannet.stats.ox.ac.uk>

Thanks: changed in R-patched.

On Wed, 19 Jan 2011, William Dunlap wrote:

> When weighted.residuals() is given a fitted model
> object with several responses (class mlm) and some
> zero weights it returns a vector instead of a matrix.
> It looks like it is doing
>   resids[ weights != 0 ]
> instead of
>   resids[ weights != 0, , drop=FALSE]
> in the multi-response case.
>
> E.g.,
>
>> d4 <- data.frame(y1=1:4, y2=2^(0:3), wt=log(1:4),
> fac=LETTERS[c(1,1,2,2)])
>> fit <- lm(data=d4, cbind(y1,y2)~fac, weights=wt)
>> weighted.residuals(fit) # expect 3x2 matrix
> [1]  1.407294e-16 -5.847465e-01  5.205496e-01  5.950102e-16
> -2.338986e+00
> [6]  2.082198e+00
>> weighted.residuals(fit, drop0=FALSE)
>             y1            y2
> 1  0.000000e+00  0.000000e+00
> 2  1.407294e-16  5.950102e-16
> 3 -5.847465e-01 -2.338986e+00
> 4  5.205496e-01  2.082198e+00
>
> This is in R 2.12.0.  I haven't upgraded yet.
>
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

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



[Rd] buglet in weighted.residuals(mlmObject)
Prof Brian Ripley