From p.dalgaard@biostat.ku.dk  Thu Feb 18 17:27:11 1999
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 18 Feb 1999 18:27:11 +0100
Subject: model.frame mangles time series (PR#121)
In-Reply-To: Thomas Lumley's message of Thu, 18 Feb 1999 08:52:15 -0800 (PST)
References: <Pine.GSO.4.10.9902180851110.2878-100000@wompom.biostat.washington.edu>
Message-ID: <x23e43lj0w.fsf@blueberry.kubism.ku.dk>

Thomas Lumley <thomas@biostat.washington.edu> writes:

> On 18 Feb 1999, Peter Dalgaard BSA wrote:
> 
> > 
> > (6) since [subset,] seems to work, perhaps do_subset is what should be
> > called from inside do_modelframe?
> 
> No, subset doesn't work -- it loses contrasts
> 
> R>  contrasts(df$x)
>   [,1] [,2]
> 1    1    0
> 2    0    1
> 3   -1   -1
> R> contrasts(df[1:5,]$x)
>   2 3
> 1 0 0
> 2 1 0
> 3 0 1

That can be fixed by a one-line change to [.factor :

> contrasts(df[1:3,]$x)
          .L   .Q         .C
1 -0.6708204  0.5 -0.2236068
2 -0.2236068 -0.5  0.6708204
3  0.2236068 -0.5 -0.6708204
4  0.6708204  0.5  0.2236068

I suspect that is the correct solution.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


model.frame mangles time series (PR#121)
Peter Dalgaard BSA