[R] Is there a non-parametric repeated-measures Anova in R ?

David Winsemius dwinsemius at comcast.net
Fri Jun 18 17:54:44 CEST 2010


On Jun 18, 2010, at 5:00 AM, Maciej Hoffman-Wecker wrote:

>
> I always wonder why no one of the real experts posts a reference to  
> E. Brunners work:
>
> Brunner, E., Domhof S. and Langer, F. (2002). Nonparametric Analysis  
> of Longitudinal Data in Factorial Designs. Wiley, New York.
>
> The german book is great:
>
> Brunner, E. und Langer, F. (1999). Nichtparametrische Analyse  
> longitudinaler Daten. Oldenbourg, München.

The author does not provide an English page for his R programs, but  
the R code for his non-parametric longitudinal analysis approach  
appears documented in English:

http://www.ams.med.uni-goettingen.de/amsneu/sasmakr-de.html
http://www.ams.med.uni-goettingen.de/amsneu/download/longit/ld.f1.r
http://www.ams.med.uni-goettingen.de/amsneu/download/longit/readme_ldf_f2.pdf
http://www.ams.med.uni-goettingen.de/amsneu/download/longit/ld.f2.r
http://www.ams.med.uni-goettingen.de/amsneu/download/longit/f1.ld.f1.r

>
> As far as I can remember it covers factorial designs as well.
>
> There is even r code, but you have to google for.
>
> I googled by myself and found this post:
>
> http://www.mail-archive.com/r-help@r-project.org/msg87977.html

(Which demonstrates among other things the lability of my long-term  
memory, as did Frank's note about the deficiencies of the rank  
transform approach, which I am reasonably sure he has also made to me  
before. Thanks to both of you for the reminder.)
-- 
David.

>
> Regards,
> Maciej
>
> -----Ursprüngliche Nachricht-----
>
>
> Message: 117
> Date: Thu, 17 Jun 2010 20:12:54 -0400
> From: David Winsemius <dwinsemius at comcast.net>
> To: Tal Galili <tal.galili at gmail.com>
> Cc: r-help at r-project.org
> Subject: Re: [R] Is there a non-parametric repeated-measures Anova in
> 	R ?
> Message-ID: <B48AA7EE-0FC2-4CDF-B021-6904123050EF at comcast.net>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>
>
> On Jun 16, 2010, at 1:43 PM, Tal Galili wrote:
>
>> Hello Jeremy,
>> Thank you for replying.
>>
>> I came across friedman test (I even wrote and published R code to
>> easily
>> perform a post-hoc analysis of friedman
>> test<http://www.r-statistics.com/2010/02/post-hoc-analysis-for-friedmans-test-r-code/
>>>
>> ).
>> But what I am after is *multi-way* repeated-measures anova.  Thank
>> you for
>> your reply which allowed me to clarify my intentions.
>
> Many years ago I remember reading advice in Conover and Iman's
> "Practical Non-Parametric Statistics" that one could apply a rank
> transformation to the dependent  and independent variables and then
> run a typical anova test. This is probably inferior in many ways to
> doing quantile regression (don't know if this has a repeated measures
> extension) or to the use of robust standard errors for examining
> inferential issues in regression models, but it certainly represents a
> useful consistency check when all you are worried about is influential
> points in a  skew distributions. I cannot comment on how it would
> theoretically behave in a repeated-measures analysis, but I suspect
> that there are readers of this list who can comment with greater
> authority, and I invite them to do so.
>
> -- 
> David.
>>
>> Best,
>> Tal
>>

>>
>>
>> On Wed, Jun 16, 2010 at 8:30 PM, Jeremy Miles
>> <jeremy.miles at gmail.com>wrote:
>>
>>> It's possible to use the ordinal regression model if your data are
>>> ordered categories.  The standard non-parametric test is the  
>>> Friedman
>>> test.
>>>
>>> ?friedman.test
>>>
>>> Jeremy
>>>
>>>
>>> On 16 June 2010 10:22, Tal Galili <tal.galili at gmail.com> wrote:
>>>> Hello Prof. Harrell and dear R-help mailing list,
>>>>
>>>> I wish to perform a non-parametric repeated measures anova.
>>>>
>>>> If what I read online is true, this could be achieved using a mixed
>>> Ordinal
>>>> Regression model (a.k.a: Proportional Odds Model).
>>>> I found two packages that seems relevant, but couldn't find any
>>>> vignette
>>> on
>>>> the subject:
>>>> http://cran.r-project.org/web/packages/repolr/
>>>> http://cran.r-project.org/web/packages/ordinal/
>>>>
>>>> So being new to the subject matter, I was hoping for some
>>>> directions from
>>>> people here.
>>>>
>>>> Are there any tutorials/suggested-reading on the subject?  Even
>>>> better,
>>> can
>>>> someone suggest a simple example code for how to run and analyse
>>>> this in
>>> R
>>>> (e.g: "non-parametric repeated measures anova") ?
>>>>
>>>> I waited a week to repost this question.  If I should have waited
>>>> longer,
>>> or
>>>> not repost this at all - then I am truly sorry.
>>>>
>>>> Thanks for any help,
>>>> Tal
>>> --
>>> Jeremy Miles
>>> Psychology Research Methods Wiki:  
>>> www.researchmethodsinpsychology.com
>>>
>
> David Winsemius, MD
> West Hartford, CT
>
> ------------------------------
>
> Message: 118
> Date: Thu, 17 Jun 2010 18:32:33 -0700
> From: "Rex C. Eastbourne" <rex.eastbourne at gmail.com>
> To: r-help at r-project.org
> Subject: [R] Drawing paths through a grid
> Message-ID:
> 	<AANLkTimbItr_efpYalgJxPGBJL2sSWj6YfenACv89IzL at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> I would like to draw a set of points that are equally spaced in a 2-D
> grid. Then I would like to draw lines that illustrate different
> directed paths through subsets of points. Imagine that the points
> correspond to booths in a conference center, and I want to show the
> various paths people took to visit the booths (using color to
> highlight different types of paths). An example path might be: [(1,1),
> (1,3), (3, 3)].
>
> Note: I would like to also make the size of the points in the grid
> variable (they correspond to the sizes of the booth).
>
> Can anyone suggest a way to do this in R? (Or to suggest another
> software package.)
>
> Thanks,
> Rex
>
>
>
> ------------------------------
>
> Message: 119
> Date: Thu, 17 Jun 2010 18:06:05 -0500
> From: David LeBauer <dlebauer at illinois.edu>
> To: r-help at r-project.org
> Subject: [R] is there a function to find the quantile of the mean of a
> 	vector?
> Message-ID:
> 	<AANLkTikFOYCypEsExyvN2kwXH1wUhjaXc9b_Y2Q8mSUg at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Hello,
>
> I am interested in finding the quantile of the mean of a vector,
> something analogous to using the pnorm(), but for an mcmc chain
> instead of a distribution with known parameters.
>
> One approach would be to write a function that finds the index of x_i
> that minimizes (x-mean(x))^2
>
> I suspect there is a function available to do this, but I can't find  
> it?
>
> Thank you,
>
> David
>
>
>
> ------------------------------
>
> Message: 120
> Date: Thu, 17 Jun 2010 23:15:31 -0400
> From: Jorge Ivan Velez <jorgeivanvelez at gmail.com>
> To: David LeBauer <dlebauer at illinois.edu>
> Cc: r-help at r-project.org
> Subject: Re: [R] is there a function to find the quantile of the mean
> 	of a	vector?
> Message-ID:
> 	<AANLkTinNoj5zxzFpea_eb5ZwC--mgux31950Ou0Bi0La at mail.gmail.com>
> Content-Type: text/plain
>
> Hi David,
>
> You might try:
>
>> set.seed(1)
>> x <- runif(10, 3, 7)
>> x
> [1] 4.062035 4.488496 5.291413 6.632831 3.806728 6.593559 6.778701  
> 5.643191
> 5.516456 3.247145
>> (x-mean(x))^2
> [1] 1.308783661 0.514892188 0.007285983 2.035688832 1.958118177  
> 1.925165288
> 2.473214156
> [8] 0.191087609 0.096348590 3.837329960
>> which.min((x-mean(x))^2)
> [1] 3
>> x[which.min((x-mean(x))^2)]
> [1] 5.291413
>> which.min(scale(x, scale = FALSE)**2)
> [1] 3
>
> See ?which.min and ?scale for more information.
>
> HTH,
> Jorge
>
>
> On Thu, Jun 17, 2010 at 7:06 PM, David LeBauer <> wrote:
>
>> Hello,
>>
>> I am interested in finding the quantile of the mean of a vector,
>> something analogous to using the pnorm(), but for an mcmc chain
>> instead of a distribution with known parameters.
>>
>> One approach would be to write a function that finds the index of x_i
>> that minimizes (x-mean(x))^2
>>
>> I suspect there is a function available to do this, but I can't  
>> find it?
>>
>> Thank you,
>>
>> David
> ------------------------------
>
> Message: 121
> Date: Fri, 18 Jun 2010 00:03:18 -0400
> From: David Winsemius <dwinsemius at comcast.net>
> To: weller <weller.emmons at gmail.com>
> Cc: r-help at r-project.org
> Subject: Re: [R] Multiple ecdf plots?
> Message-ID: <A5D54844-67B3-43E1-B1C6-DC437D248FEA at comcast.net>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>
>
> On Jun 17, 2010, at 4:46 PM, weller wrote:
>
>>
>> I have a csv file that has approximately 50k rows.  In the first  
>> value of
>> each row, a file name is listed, and there are 162 different file  
>> names.  At
>> the end of each row, there is a number value.  What I would like to  
>> be able
>> to do is for the 162 different files (or we could call them  
>> categories), is
>> compute the ecdf for the values within that category.  Then plot  
>> the ecdf
>> for each file on the same graph.  Essentially, it would look  
>> something like
>> http://www-stat.stanford.edu/~jtaylo/courses/stats202/R/chap3_data_exploration/iris_ecdf.png
>> ,
>> but instead of the 3 lines, it would show 162.  They don't have to be
>> different colors, and the number of records in each file category
>> changes.
>> I was considering using a  matrix and adding to it via a loop, but
>> couldn't
>> quite get it to work. This is what I have right now.
>>
>> thwop <- read.csv("real_unmod_estimated_pI.csv", header=TRUE)
>> filelist <- levels(thwop$Source)
>> rig=matrix(nrows=162)
>>
>> for (i in filelist)
>> {
>>  thug <- subset(thwop,  == i)
>>  rig[i,length(ecdf(thug$Estimated.pI))]=ecdf(thug$Source)
>> }
>> rig
>
> Perhaps:
>
> plot(x=0, y=min(thwop$estimated.pI), xlim=c(min(thwop$estimated.pI),
> max(thwop$estimated.pI) ), ylim=c(0.0, 1.0), xlab="", ylab="")
>
> tapply(thwop$estimated.pI, thwop$Source, function(x) { par(new=TRUE) ;
> plot(ecdf(x), verticals=TRUE, xlim=c(min(thwop$estimated.pI),  
> max(thwop
> $estimated.pI, xaxt=FALSE) )) })
>
> (It is going to be a mess.)
>
>
>
>>
>> Any help would be appreciated
>
>
> ------------------------------
>
> Message: 122
> Date: Thu, 17 Jun 2010 23:09:00 -0500
> From: Frank E Harrell Jr <f.harrell at Vanderbilt.Edu>
> To: David Winsemius <dwinsemius at comcast.net>
> Cc: r-help at r-project.org
> Subject: Re: [R] Is there a non-parametric repeated-measures Anova in
> 	R ?
> Message-ID: <4C1AF15C.40606 at vanderbilt.edu>
> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed
>
> On 06/17/2010 07:12 PM, David Winsemius wrote:
>>
>> On Jun 16, 2010, at 1:43 PM, Tal Galili wrote:
>>
>>> Hello Jeremy,
>>> Thank you for replying.
>>>
>>> I came across friedman test (I even wrote and published R code to  
>>> easily
>>> perform a post-hoc analysis of friedman
>>> test<http://www.r-statistics.com/2010/02/post-hoc-analysis-for-friedmans-test-r-code/ 
>>> >
>>>
>>> ).
>>> But what I am after is *multi-way* repeated-measures anova. Thank  
>>> you for
>>> your reply which allowed me to clarify my intentions.
>>
>> Many years ago I remember reading advice in Conover and Iman's
>> "Practical Non-Parametric Statistics" that one could apply a rank
>> transformation to the dependent and independent variables and then  
>> run a
>> typical anova test. This is probably inferior in many ways to doing
>> quantile regression (don't know if this has a repeated measures
>> extension) or to the use of robust standard errors for examining
>> inferential issues in regression models, but it certainly  
>> represents a
>> useful consistency check when all you are worried about is  
>> influential
>> points in a skew distributions. I cannot comment on how it would
>> theoretically behave in a repeated-measures analysis, but I suspect  
>> that
>> there are readers of this list who can comment with greater  
>> authority,
>> and I invite them to do so.
>>
>
> David - the rank transform method doesn't handle interactions  
> properly,
> among other problems.  The proportional odds model is the logical
> extension of the Wilcoxon-Kruskal-Wallis approach.  It relies only on
> the rank of Y and reduces to the regular nonparametric tests as  
> special
> cases.
>
> Frank
> -- 
> Frank E Harrell Jr   Professor and Chairman        School of Medicine
>                      Department of Biostatistics   Vanderbilt  
> University
>
>
>
> ------------------------------
>
> Message: 123
> Date: Fri, 18 Jun 2010 16:02:35 +1200
> From: John Williams <john.williams at otago.ac.nz>
> To: <deschamps.aline at yahoo.fr>
> Cc: R Help <r-help at r-project.org>
> Subject: Re: [R] Design of experiments for Choice-Based Conjoint
> 	Analysis (CBC)
> Message-ID: <4C1AEFDB.7070002 at otago.ac.nz>
> Content-Type: text/plain; charset="iso-8859-1"; Format="flowed"
>
> Hi,
>
> You might find the attached article useful.  I am facing the same
> problems that you appear to be facing, and I found this article to  
> be a
> great help.
>
> I've also attached a small script I wrote to replicate the analyses
> presented in the paper. I can't reproduce the second analysis though,
> and I can't figure out what's wrong with my code.
>
> HTH,
>
> John.
>
> P.S.  Is anyone else lurking interested in Discrete Choice Experiments
> and/or MaxDiff (Best/Worst) scaling.  Perhaps we could form a wee SIG?
>
> Cheers,
>
> John
>
> P.S.  While there is no single function to do CBC/DCE in R, it doesn't
> seem too hard.  The only step for which there is no single function is
> aggregating the design matrix and data.  I've named my script/function
> MktRoll after the SAS macro that does that same job  (among many other
> things, I'm sure).  It's just a quick hack, though!
>
> While it seems to be relatively straightforward in R, I have yet to
> actually implement a design and gather and analyse the data  
> though ... ;-)
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: DCE with R.pdf
> Type: application/pdf
> Size: 934195 bytes
> Desc: not available
> URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100618/a8d2f366/attachment.pdf 
> >
> -------------- next part --------------
> An embedded and charset-unspecified text was scrubbed...
> Name: MktRoll.R
> URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100618/a8d2f366/attachment.pl 
> >
>
> ------------------------------

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list