[R] repeated measures aov with weights

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Dec 17 11:02:02 CET 2008

```Weights are not supported: multistratum aov is designed for balanced
designs and uses projection for which weighting is inappropriate.

On Wed, 17 Dec 2008, Ingmar Visser wrote:

> Dear R-help,
>
> I'm facing a problem with defining a repeated measures anova with
> weighted data.
> Here's the code to reproduce the problem:
>
> # generate some data
> seed=11
> rtrep <- data.frame(rt=rnorm(100),ti=rep(1:5,20),subj=gl
> (20,5,100),we=runif(100))
>
> # model with within factor for subjects/repeated measurements, no
> problem
> aov(rt~ti + Error(subj/ti),data=rtrep)
>
> #model with weights and subj as between factor, ie ignoring repeated
> measures,
> #again, no problem
> aov(rt~ti+subj,data=rtrep,weights=we)
>
> #combination of above two: repeated measures AND weights
> aov(rt~ti + Error(subj/ti),data=rtrep,weights=we)
>
> The latter model gives an error (see report below), but only after
> fitting it, ie the error is produced by the
> print and summary methods of the aov objects.
>
> Any guidance is appreciated, best, Ingmar
>
>
>
>
>
> Error produced in printing the fitted aov object:
>
> Call:
> aov(formula = rt ~ ti + Error(subj/ti), data = rtrep, weights = we)
> Note: The results below are on the weighted scale
>
> Grand Mean: 0.112081
>
> Stratum 1: subj
>
> Terms:
>                        ti Residuals
> Sum of Squares   2.002826 10.869940
> Deg. of Freedom         1        18
>
> Residual standard error: 0.7771007
> Estimated effects are balanced
>
> Stratum 2: subj:ti
>
> Terms:
>                       ti Residuals
> Sum of Squares  0.382535  5.540047
> Deg. of Freedom        1        19
>
> Residual standard error: 0.5399828
> Estimated effects are balanced
>
> Stratum 3: Within
> Error in print.aov(xi, ...) :
>   dims [product 60] do not match the length of object [100]
> In addition: Warning message:
> In resid * wt^0.5 :
>   longer object length is not a multiple of shorter object length
>
>
> Ingmar Visser
> Department of Psychology, University of Amsterdam
> 1018 WB Amsterdam
> The Netherlands
> t: +31-20-5256723
>
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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

```