An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20081217/0f682503/attachment.pl>
repeated measures aov with weights
5 messages · Ingmar Visser, Brian Ripley
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
Roetersstraat 15
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
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20081217/f174f89c/attachment.pl>
On Wed, 17 Dec 2008, Ingmar Visser wrote:
I see, I was afraid for an answer along these lines as my problem now turns into a stat problem (-;Any suggestions on how to analyze such data as given below with weights AND at the same time taking into account that there are repeated measurements?
It matters what you mean by 'weights'. If they are case weights, repeat the cases. If they are inverse-variance weights, you can use package lme4. List R-sig-mixed-modles might be more appropriate if you want more detailed help.
Best, Ingmar
On 17 Dec 2008, at 11:02, Prof Brian Ripley wrote:
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
Roetersstraat 15
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 Ingmar Visser Department of Psychology, University of Amsterdam Roetersstraat 15 1018 WB Amsterdam The Netherlands t: +31-20-5256723
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
On Wed, 17 Dec 2008, Ingmar Visser wrote:
I see, I was afraid for an answer along these lines as my problem now turns into a stat problem (-;Any suggestions on how to analyze such data as given
You mean, you were afraid that the help page was correct?
Weights can be specified by a 'weights' argument, but should not
be used with an 'Error' term, and are incompletely supported
(e.g., not by 'model.tables').
RTFM time ....
below with weights AND at the same time
taking into account that there are repeated measurements?
Best, Ingmar
On 17 Dec 2008, at 11:02, Prof Brian Ripley wrote:
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
Roetersstraat 15
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 Ingmar Visser Department of Psychology, University of Amsterdam Roetersstraat 15 1018 WB Amsterdam The Netherlands t: +31-20-5256723
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