Re: [R] Getting Sphericity Tests for Within Subject Repeated Measure Anova (using car package)

2012-01-11 Thread maximilian.mueller
Dear John,

thanks for your help and sorry for answering this late. My question is a
follow up question of an older thread posted several mongths ago, but your
statement helped a lot.

Thanks,
Max



-
M a x i m i l i a n  M ue l l e r

PhD-Student
Department of Business Studies
Leuphana Universität Lüneburg

--
View this message in context: 
http://r.789695.n4.nabble.com/Getting-Sphericity-Tests-for-Within-Subject-Repeated-Measure-Anova-using-car-package-tp841030p4285034.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] Getting Sphericity Tests for Within Subject Repeated Measure Anova (using car package)

2012-01-04 Thread Michael Friendly

On 1/3/2012 9:36 PM, maximilian.mueller wrote:


Here is the syntax:


options(contrasts=c(contr.sum, contr.poly))
read.csv2(test21.csv) - dat3
mod3 - lm(cbind(umsatz_t1, umsatz_t2, umsatz_t3, umsatz_t4) +
cbind(ebitda_t1, ebitda_t2, ebitda_t3, ebitda_t4)

+   ~ 1, data=dat3)

idata3 - data.frame(Umsatz=factor(1:4), EBITDA=factor(1:4))
aov3 - Anova(mod3, idata=idata3, idesign= ~Umsatz+EBITDA, type=III)

Fehler in check.imatrix(X.design) :
  Terms in the intra-subject model matrix are not orthogonal.

summary(aov3, multivariate=F)


That's because you've defined two identical factor variables.

idata3- data.frame(Umsatz=factor(1:4), EBITDA=factor(1:4))


 idata3 - data.frame(Umsatz=factor(1:4), EBITDA=factor(1:4))
 idata3
  Umsatz EBITDA
1  1  1
2  2  2
3  3  3
4  4  4


If your data is a doubly-multivariate design with two repeated variables
Umsatz and EBIDTA crossed with 4 time points each, you might want to look
at the vignette HE Plots for Repeated Measures Designs in the heplots 
package for theory and examples


vignette(repeated, package=heplots)

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

__
R-help@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.


Re: [R] Getting Sphericity Tests for Within Subject Repeated Measure Anova (using car package)

2012-01-04 Thread John Fox
Dear Max,

I'm having a little trouble following what you did and am also confused by the 
subject of your posting. Is this a response to another message? Is it really 
about getting sphericity tests?

In addition:

(1) Why are you adding together the response matrices cbind(umsatz_t1, 
umsatz_t2, umsatz_t3, umsatz_t4) and cbind(ebitda_t1, ebitda_t2, ebitda_t3, 
ebitda_t4)?

(2) From the names of the responses, I imagine that you have two, crossed, 
repeated-measures factors: umsatz vs. ebita, and times 1 through 4. If that's 
correct, then the intra-subject data should look like

  idata3 - data.frame(
condition=rep(c(umsatz, ebita), each=5), 
time=ordered(rep(1:5, 2)))

and the intra-subject design should be ~condition*time.

Best,
 John


John Fox
Senator William McMaster
  Professor of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox




 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of maximilian.mueller
 Sent: January-03-12 9:36 PM
 To: r-help@r-project.org
 Subject: Re: [R] Getting Sphericity Tests for Within Subject Repeated
 Measure Anova (using car package)
 
 Hello everyone,
 
 I am also trying to do within subjects repeated measures anova
 followed by the test of sphericity (see sample dataset attached below)
 and I am facing some problems.
 
 I tried to assign the example to my research question, but could not
 really solve it.
 
 Here is the syntax:
 
  options(contrasts=c(contr.sum, contr.poly))
  read.csv2(test21.csv) - dat3
  mod3 - lm(cbind(umsatz_t1, umsatz_t2, umsatz_t3, umsatz_t4) +
  cbind(ebitda_t1, ebitda_t2, ebitda_t3, ebitda_t4)
 + ~ 1, data=dat3)
  idata3 - data.frame(Umsatz=factor(1:4), EBITDA=factor(1:4))
  aov3 - Anova(mod3, idata=idata3, idesign= ~Umsatz+EBITDA,
 type=III)
 Fehler in check.imatrix(X.design) :
   Terms in the intra-subject model matrix are not orthogonal.
  summary(aov3, multivariate=F)
 
 with the data set  dat3
 
  dat3
 umsatz_t1  umsatz_t2  umsatz_t3  umsatz_t4  ebitda_t1  ebitda_t2
 ebitda_t3
 1  0.10239021 0.18241379 0.28875806 0.28875806 0.07622154 0.05543311
 0.06776469
 2  0.10239021 1.21769038 0.05840222 0.05840222 0.04794192 0.04642960
 0.03727069
 3  0.05124775 0.65373713 0.25976771 0.25976771 0.04794192 0.04435191
 0.03167950
 4  0.10239021 0.18241379 0.28875806 0.28875806 0.07622154 0.05543311
 0.06776469
 5  0.10239021 1.21769038 0.05840222 1.21769038 0.04794192 0.04642960
 0.03727069
 6  0.06776469 0.28875806 0.06776469 0.65373713 0.07622154 0.18241379
 0.10239021
 7  0.03727069 0.05840222 0.03727069 0.18241379 0.04794192 0.25976771
 0.04794192
 8  0.03727069 0.25976771 0.06776469 1.21769038 0.04557920 0.65373713
 0.07622154
 9  0.06776469 0.28875806 0.06776469 0.28875806 0.07622154 0.18241379
 0.04794192
 10 0.03727069 0.05840222 0.03727069 0.05840222 0.04794192 0.04642960
 0.04557920
 11 0.25976771 0.05543311 0.03727069 0.05543311 0.07622154 0.06776469
 0.03167950
 12 0.28875806 0.04642960 0.07622154 0.04642960 0.04794192 0.03727069
 0.06776469
 13 0.05840222 0.18241379 0.04794192 0.25976771 0.07622154 0.03167950
 0.03727069
 14 0.06776469 1.21769038 0.07622154 0.28875806 0.04794192 0.06776469
 0.04642960
 15 0.03727069 0.28875806 0.03727069 0.03727069 0.06776469 0.03727069
 0.04435191
 16 0.04794192 0.04642960 0.04557920 0.04557920 0.06776469 0.28875806
 0.06776469
 17 0.07622154 0.06776469 0.03167950 0.07622154 0.03727069 0.05840222
 0.03727069
 18 0.04794192 0.04642960 0.03727069 0.04435191 0.07622154 0.03167950
 0.03727069
 19 0.04794192 0.04435191 0.03167950 0.05543311 0.04794192 0.06776469
 0.04642960
 ebitda_t4
 1  0.04642960
 2  0.04435191
 3  0.05543311
 4  0.04642960
 5  0.18241379
 6  0.25976771
 7  0.04794192
 8  0.07622154
 9  0.04794192
 10 0.04557920
 11 0.07622154
 12 0.04794192
 13 0.04557920
 14 0.03167950
 15 0.03167950
 16 0.65373713
 17 0.18241379
 18 0.04557920
 19 0.03167950
 
 
 Thanks four your help...
 
 Sincerely,
 Max
 
 
 
 -
 M a x i m i l i a n  M ue l l e r
 
 PhD-Student
 Department of Business Studies
 Leuphana Universität Lüneburg
 
 --
 View this message in context: http://r.789695.n4.nabble.com/Getting-
 Sphericity-Tests-for-Within-Subject-Repeated-Measure-Anova-using-car-
 package-tp841030p4259642.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@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.

__
R-help@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.


Re: [R] Getting Sphericity Tests for Within Subject Repeated Measure Anova (using car package)

2012-01-03 Thread maximilian.mueller
Hello everyone,

I am also trying to do within subjects repeated measures anova followed by
the
test of sphericity (see sample dataset attached below) and I am facing some
problems. 

I tried to assign the example to my research question, but could not really
solve it.

Here is the syntax:

 options(contrasts=c(contr.sum, contr.poly))
 read.csv2(test21.csv) - dat3
 mod3 - lm(cbind(umsatz_t1, umsatz_t2, umsatz_t3, umsatz_t4) +
 cbind(ebitda_t1, ebitda_t2, ebitda_t3, ebitda_t4)
+   ~ 1, data=dat3)
 idata3 - data.frame(Umsatz=factor(1:4), EBITDA=factor(1:4))
 aov3 - Anova(mod3, idata=idata3, idesign= ~Umsatz+EBITDA, type=III)
Fehler in check.imatrix(X.design) : 
  Terms in the intra-subject model matrix are not orthogonal.
 summary(aov3, multivariate=F) 

with the data set  dat3

 dat3
umsatz_t1  umsatz_t2  umsatz_t3  umsatz_t4  ebitda_t1  ebitda_t2 
ebitda_t3
1  0.10239021 0.18241379 0.28875806 0.28875806 0.07622154 0.05543311
0.06776469
2  0.10239021 1.21769038 0.05840222 0.05840222 0.04794192 0.04642960
0.03727069
3  0.05124775 0.65373713 0.25976771 0.25976771 0.04794192 0.04435191
0.03167950
4  0.10239021 0.18241379 0.28875806 0.28875806 0.07622154 0.05543311
0.06776469
5  0.10239021 1.21769038 0.05840222 1.21769038 0.04794192 0.04642960
0.03727069
6  0.06776469 0.28875806 0.06776469 0.65373713 0.07622154 0.18241379
0.10239021
7  0.03727069 0.05840222 0.03727069 0.18241379 0.04794192 0.25976771
0.04794192
8  0.03727069 0.25976771 0.06776469 1.21769038 0.04557920 0.65373713
0.07622154
9  0.06776469 0.28875806 0.06776469 0.28875806 0.07622154 0.18241379
0.04794192
10 0.03727069 0.05840222 0.03727069 0.05840222 0.04794192 0.04642960
0.04557920
11 0.25976771 0.05543311 0.03727069 0.05543311 0.07622154 0.06776469
0.03167950
12 0.28875806 0.04642960 0.07622154 0.04642960 0.04794192 0.03727069
0.06776469
13 0.05840222 0.18241379 0.04794192 0.25976771 0.07622154 0.03167950
0.03727069
14 0.06776469 1.21769038 0.07622154 0.28875806 0.04794192 0.06776469
0.04642960
15 0.03727069 0.28875806 0.03727069 0.03727069 0.06776469 0.03727069
0.04435191
16 0.04794192 0.04642960 0.04557920 0.04557920 0.06776469 0.28875806
0.06776469
17 0.07622154 0.06776469 0.03167950 0.07622154 0.03727069 0.05840222
0.03727069
18 0.04794192 0.04642960 0.03727069 0.04435191 0.07622154 0.03167950
0.03727069
19 0.04794192 0.04435191 0.03167950 0.05543311 0.04794192 0.06776469
0.04642960
ebitda_t4
1  0.04642960
2  0.04435191
3  0.05543311
4  0.04642960
5  0.18241379
6  0.25976771
7  0.04794192
8  0.07622154
9  0.04794192
10 0.04557920
11 0.07622154
12 0.04794192
13 0.04557920
14 0.03167950
15 0.03167950
16 0.65373713
17 0.18241379
18 0.04557920
19 0.03167950
 

Thanks four your help...

Sincerely, 
Max



-
M a x i m i l i a n  M ue l l e r

PhD-Student
Department of Business Studies
Leuphana Universität Lüneburg

--
View this message in context: 
http://r.789695.n4.nabble.com/Getting-Sphericity-Tests-for-Within-Subject-Repeated-Measure-Anova-using-car-package-tp841030p4259642.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] Getting Sphericity Tests for Within Subject Repeated Measure Anova (using car package)

2009-11-10 Thread Mike Lawrence
Check out the reshape package for transforming data from long to wide
and vice versa.

Yet I still don't know what problem you've encountered with ezANOVA.
Using the data you just sent, where Day now has 3 levels, I reformat
back to the presumably original long format and find that ezANOVA
returns the same sphericity tests as John's solution (which is
expected because ezANOVA is a wrapper to Anova):

library(ez)
a = read.table( 'Sergios_wide_data.txt' , header=T )
b = melt.data.frame( data=a , id.vars=c('subject','treatment') ,
variable_name='day' )
ezANOVA( data=b , dv=.(value) , sid=.(subject) , within=.(treatment,day) )



On Mon, Nov 9, 2009 at 10:20 PM, Sergios (Sergey) Charntikov
sergios...@gmail.com wrote:
 Thank you very much.  Finally got it to work.  However, I had to recode it 
 from:
 columns: subject/treatment/DV (where all my response data was in one
 DV column) to columns: subject/treatment/day1/day2/day3/ (where my
 response data is now in three different columns).

 Is there a way to do that without hand recoding (cutting and pasting
 in spreadsheet) by hand? Thank you for your help.  Glad it works as
 is.


 Sincerely,

 Sergios Charntikov (Sergey), MA

 Behavioral Neuropharmacology Lab
 Department of Psychology
 University of Nebraska-Lincoln
 Lincoln, NE 68588-0308  USA





 On Mon, Nov 9, 2009 at 7:12 PM, John Fox j...@mcmaster.ca wrote:
 Dear Sergios,

 Why don't you try what I suggested originally? Adapted to this data set,

 mod - lm(cbind(day1, day2, day3) ~ Treatment, data=Dataset)
 idata - data.frame(Day=factor(1:3))
 summary(Anova(mod, idata=idata, idesign=~Day))

 Peter Dalgaard also pointed toward an article that describes how to do the
 same thing with anova().

 Regards,
  John

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On
 Behalf Of Sergios (Sergey) Charntikov
 Sent: November-09-09 7:13 PM
 To: Mike Lawrence
 Cc: r-help@r-project.org
 Subject: Re: [R] Getting Sphericity Tests for Within Subject Repeated
 Measure
 Anova (using car package)

 Hi Mike,

 I tried to run my data in SPSS and it works fine without any problems,
 plug
 in my levels, plug in my covariate (since it is all within) and get my
 Mauchly Tests.

 I tried to rearrange the data so it looks like this

 subj/treatment/day1/day2/day3

 subject    treatment    day1    day2    day3
 1    1    8    8    8
 1    2    5    7    5
 2    1    7    4    4
 2    2    4    5    7
 3    1    8    6    4
 3    2    5    2    4
 4    1    2    9    4
 4    2    1    9    1
 5    1    4    8    1
 5    2    7    8    2
 6    1    4    7    2
 6    2    4    5    2


 When I try mlmfit - lm(Dataset~1), I get invalid type (list) for
 variable
 'Dataset

 When I try

 mod - lm(cbind(day1, day2, day3) ~ Treatment, data=Dataset)

 idata- data.frame(factor(rep(c(Dataset$day1, Dataset$day2,
 Dataset$day3))),
 ordered(Dataset$Treatment))

 Anova(mod, idata=idata, idesign=~Dataset$Treatment)

 I get: Terms in the intra-subject model matrix are not orthogonal.

 When I try is.matrix(Dataset) - I get no.

 My original mock Dataset (attached in txt) is below.  Maybe I am not
 coding
 it right? I would hate to recode all my data for SPSS, since at the end I
 would need to show that Sphericity was not violated.

 Subj  Trtmt   Sessn   Response

 1     N       1       5

 1     D       1       6

 1     N       2       4

 1     D       2       7

 2     N       1       8

 2     D       1       9

 2     N       2       2

 2     D       2       1

 3     N       1       4

 3     D       1       5

 3     N       2       6

 3     D       2       2

 4     N       1       5

 4     D       1       6

 4     N       2       4

 4     D       2       7

 5     N       1       8

 5     D       1       9

 5     N       2       2

 5     D       2       1

 6     N       1       4

 6     D       1       5

 6     N       2       6

 6     D       2       2




 Sincerely,

 Sergios Charntikov (Sergey), MA

 Behavioral Neuropharmacology Lab
 Department of Psychology
 University of Nebraska-Lincoln
 Lincoln, NE 68588-0308  USA



 On Mon, Nov 9, 2009 at 5:29 PM, Mike Lawrence mike.lawre...@dal.ca
 wrote:
 
  No luck as in...? What error did you encounter?
 
  In your example data set, you only have 2 levels of each within-Ss
  factor, in which case you shouldn't expect to obtain tests of
  sphericity; as far as I understand it, sphericity necessarily holds
  when for repeated measures with only 2 levels and tests are really
  only possible for repeated measures with 3 or more levels.
 
  I think it's analogous to how you don't need to test homogeneity of
  variance when performing a paired t-test; the test ends up
  representing the pairs as single distribution of difference scores
  with a single variance.
 
  Mike
 
  On Mon, Nov 9, 2009 at 5:30 PM, Sergios (Sergey) Charntikov
  sergios...@gmail.com wrote:
   Tried EZanova, no luck with my particular dataset

Re: [R] Getting Sphericity Tests for Within Subject Repeated Measure Anova (using car package)

2009-11-10 Thread Mike Lawrence
Oops, I see now that despite repeated subject names, treatment is a
between-Ss variable, so you need to use this to get the equivalent of
Anova:

library(ez)
a = read.table( 'Sergios_wide_data.txt' , header=T )
b = melt.data.frame( data=a , id.vars=c('subject','treatment') ,
variable_name='day' )
b$subject=paste(b$subject,b$treatment) #create unique sids
ezANOVA( data=b , dv=.(value) , sid=.(subject) , within=.(day) ,
between=.(treatment) )




On Tue, Nov 10, 2009 at 6:47 AM, Mike Lawrence mike.lawre...@dal.ca wrote:
 Check out the reshape package for transforming data from long to wide
 and vice versa.

 Yet I still don't know what problem you've encountered with ezANOVA.
 Using the data you just sent, where Day now has 3 levels, I reformat
 back to the presumably original long format and find that ezANOVA
 returns the same sphericity tests as John's solution (which is
 expected because ezANOVA is a wrapper to Anova):

 library(ez)
 a = read.table( 'Sergios_wide_data.txt' , header=T )
 b = melt.data.frame( data=a , id.vars=c('subject','treatment') ,
 variable_name='day' )
 ezANOVA( data=b , dv=.(value) , sid=.(subject) , within=.(treatment,day) )



 On Mon, Nov 9, 2009 at 10:20 PM, Sergios (Sergey) Charntikov
 sergios...@gmail.com wrote:
 Thank you very much.  Finally got it to work.  However, I had to recode it 
 from:
 columns: subject/treatment/DV (where all my response data was in one
 DV column) to columns: subject/treatment/day1/day2/day3/ (where my
 response data is now in three different columns).

 Is there a way to do that without hand recoding (cutting and pasting
 in spreadsheet) by hand? Thank you for your help.  Glad it works as
 is.


 Sincerely,

 Sergios Charntikov (Sergey), MA

 Behavioral Neuropharmacology Lab
 Department of Psychology
 University of Nebraska-Lincoln
 Lincoln, NE 68588-0308  USA





 On Mon, Nov 9, 2009 at 7:12 PM, John Fox j...@mcmaster.ca wrote:
 Dear Sergios,

 Why don't you try what I suggested originally? Adapted to this data set,

 mod - lm(cbind(day1, day2, day3) ~ Treatment, data=Dataset)
 idata - data.frame(Day=factor(1:3))
 summary(Anova(mod, idata=idata, idesign=~Day))

 Peter Dalgaard also pointed toward an article that describes how to do the
 same thing with anova().

 Regards,
  John

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On
 Behalf Of Sergios (Sergey) Charntikov
 Sent: November-09-09 7:13 PM
 To: Mike Lawrence
 Cc: r-help@r-project.org
 Subject: Re: [R] Getting Sphericity Tests for Within Subject Repeated
 Measure
 Anova (using car package)

 Hi Mike,

 I tried to run my data in SPSS and it works fine without any problems,
 plug
 in my levels, plug in my covariate (since it is all within) and get my
 Mauchly Tests.

 I tried to rearrange the data so it looks like this

 subj/treatment/day1/day2/day3

 subject    treatment    day1    day2    day3
 1    1    8    8    8
 1    2    5    7    5
 2    1    7    4    4
 2    2    4    5    7
 3    1    8    6    4
 3    2    5    2    4
 4    1    2    9    4
 4    2    1    9    1
 5    1    4    8    1
 5    2    7    8    2
 6    1    4    7    2
 6    2    4    5    2


 When I try mlmfit - lm(Dataset~1), I get invalid type (list) for
 variable
 'Dataset

 When I try

 mod - lm(cbind(day1, day2, day3) ~ Treatment, data=Dataset)

 idata- data.frame(factor(rep(c(Dataset$day1, Dataset$day2,
 Dataset$day3))),
 ordered(Dataset$Treatment))

 Anova(mod, idata=idata, idesign=~Dataset$Treatment)

 I get: Terms in the intra-subject model matrix are not orthogonal.

 When I try is.matrix(Dataset) - I get no.

 My original mock Dataset (attached in txt) is below.  Maybe I am not
 coding
 it right? I would hate to recode all my data for SPSS, since at the end I
 would need to show that Sphericity was not violated.

 Subj  Trtmt   Sessn   Response

 1     N       1       5

 1     D       1       6

 1     N       2       4

 1     D       2       7

 2     N       1       8

 2     D       1       9

 2     N       2       2

 2     D       2       1

 3     N       1       4

 3     D       1       5

 3     N       2       6

 3     D       2       2

 4     N       1       5

 4     D       1       6

 4     N       2       4

 4     D       2       7

 5     N       1       8

 5     D       1       9

 5     N       2       2

 5     D       2       1

 6     N       1       4

 6     D       1       5

 6     N       2       6

 6     D       2       2




 Sincerely,

 Sergios Charntikov (Sergey), MA

 Behavioral Neuropharmacology Lab
 Department of Psychology
 University of Nebraska-Lincoln
 Lincoln, NE 68588-0308  USA



 On Mon, Nov 9, 2009 at 5:29 PM, Mike Lawrence mike.lawre...@dal.ca
 wrote:
 
  No luck as in...? What error did you encounter?
 
  In your example data set, you only have 2 levels of each within-Ss
  factor, in which case you shouldn't expect to obtain tests of
  sphericity; as far as I understand it, sphericity necessarily

Re: [R] Getting Sphericity Tests for Within Subject Repeated Measure Anova (using car package)

2009-11-10 Thread Sergios (Sergey) Charntikov
Thank you.  I think that this is what I was looking for.  I am getting
the hang of it with my data.  Thank you all.


Sincerely,

Sergios Charntikov (Sergey), MA

Behavioral Neuropharmacology Lab
Department of Psychology
University of Nebraska-Lincoln
Lincoln, NE 68588-0308  USA




On Tue, Nov 10, 2009 at 6:14 AM, Mike Lawrence mike.lawre...@dal.ca wrote:
 Oops, I see now that despite repeated subject names, treatment is a
 between-Ss variable, so you need to use this to get the equivalent of
 Anova:

 library(ez)
 a = read.table( 'Sergios_wide_data.txt' , header=T )
 b = melt.data.frame( data=a , id.vars=c('subject','treatment') ,
 variable_name='day' )
 b$subject=paste(b$subject,b$treatment) #create unique sids
 ezANOVA( data=b , dv=.(value) , sid=.(subject) , within=.(day) ,
 between=.(treatment) )




 On Tue, Nov 10, 2009 at 6:47 AM, Mike Lawrence mike.lawre...@dal.ca wrote:
 Check out the reshape package for transforming data from long to wide
 and vice versa.

 Yet I still don't know what problem you've encountered with ezANOVA.
 Using the data you just sent, where Day now has 3 levels, I reformat
 back to the presumably original long format and find that ezANOVA
 returns the same sphericity tests as John's solution (which is
 expected because ezANOVA is a wrapper to Anova):

 library(ez)
 a = read.table( 'Sergios_wide_data.txt' , header=T )
 b = melt.data.frame( data=a , id.vars=c('subject','treatment') ,
 variable_name='day' )
 ezANOVA( data=b , dv=.(value) , sid=.(subject) , within=.(treatment,day) )



 On Mon, Nov 9, 2009 at 10:20 PM, Sergios (Sergey) Charntikov
 sergios...@gmail.com wrote:
 Thank you very much.  Finally got it to work.  However, I had to recode it 
 from:
 columns: subject/treatment/DV (where all my response data was in one
 DV column) to columns: subject/treatment/day1/day2/day3/ (where my
 response data is now in three different columns).

 Is there a way to do that without hand recoding (cutting and pasting
 in spreadsheet) by hand? Thank you for your help.  Glad it works as
 is.


 Sincerely,

 Sergios Charntikov (Sergey), MA

 Behavioral Neuropharmacology Lab
 Department of Psychology
 University of Nebraska-Lincoln
 Lincoln, NE 68588-0308  USA





 On Mon, Nov 9, 2009 at 7:12 PM, John Fox j...@mcmaster.ca wrote:
 Dear Sergios,

 Why don't you try what I suggested originally? Adapted to this data set,

 mod - lm(cbind(day1, day2, day3) ~ Treatment, data=Dataset)
 idata - data.frame(Day=factor(1:3))
 summary(Anova(mod, idata=idata, idesign=~Day))

 Peter Dalgaard also pointed toward an article that describes how to do the
 same thing with anova().

 Regards,
  John

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On
 Behalf Of Sergios (Sergey) Charntikov
 Sent: November-09-09 7:13 PM
 To: Mike Lawrence
 Cc: r-help@r-project.org
 Subject: Re: [R] Getting Sphericity Tests for Within Subject Repeated
 Measure
 Anova (using car package)

 Hi Mike,

 I tried to run my data in SPSS and it works fine without any problems,
 plug
 in my levels, plug in my covariate (since it is all within) and get my
 Mauchly Tests.

 I tried to rearrange the data so it looks like this

 subj/treatment/day1/day2/day3

 subject    treatment    day1    day2    day3
 1    1    8    8    8
 1    2    5    7    5
 2    1    7    4    4
 2    2    4    5    7
 3    1    8    6    4
 3    2    5    2    4
 4    1    2    9    4
 4    2    1    9    1
 5    1    4    8    1
 5    2    7    8    2
 6    1    4    7    2
 6    2    4    5    2


 When I try mlmfit - lm(Dataset~1), I get invalid type (list) for
 variable
 'Dataset

 When I try

 mod - lm(cbind(day1, day2, day3) ~ Treatment, data=Dataset)

 idata- data.frame(factor(rep(c(Dataset$day1, Dataset$day2,
 Dataset$day3))),
 ordered(Dataset$Treatment))

 Anova(mod, idata=idata, idesign=~Dataset$Treatment)

 I get: Terms in the intra-subject model matrix are not orthogonal.

 When I try is.matrix(Dataset) - I get no.

 My original mock Dataset (attached in txt) is below.  Maybe I am not
 coding
 it right? I would hate to recode all my data for SPSS, since at the end I
 would need to show that Sphericity was not violated.

 Subj  Trtmt   Sessn   Response

 1     N       1       5

 1     D       1       6

 1     N       2       4

 1     D       2       7

 2     N       1       8

 2     D       1       9

 2     N       2       2

 2     D       2       1

 3     N       1       4

 3     D       1       5

 3     N       2       6

 3     D       2       2

 4     N       1       5

 4     D       1       6

 4     N       2       4

 4     D       2       7

 5     N       1       8

 5     D       1       9

 5     N       2       2

 5     D       2       1

 6     N       1       4

 6     D       1       5

 6     N       2       6

 6     D       2       2




 Sincerely,

 Sergios Charntikov (Sergey), MA

 Behavioral Neuropharmacology Lab
 Department of Psychology
 University

Re: [R] Getting Sphericity Tests for Within Subject Repeated Measure Anova (using car package) (Adjusted Dataset)

2009-11-09 Thread John Fox
Dear Segios,

For repeated-measures designs, the Anova() function requires a multivariate
linear model fit to the wide version of the data set, in which each of the
repeated measures appears as a separate variable. It is necessary that you
have the same occasions observed for all subjects. For your scaled-down
example, you'd have two response variables named, e.g., Sessn1 and Sessn2.
Then you'd fit the multivariate linear model as mod - lm(cbind(Sessn1,
Sessn2) ~ Trtmnt, data=Dataset). The idata data frame could simply be idata
- data.frame(Sessn=factor(1:2)). Then you could get the MANOVA and
repeated-measure ANOVA, including sphericity test, etc., as
summary(Anova(mod, idata=idata, idesign=~Sessn)).

I hope this helps,
 John


John Fox
Senator William McMaster 
  Professor of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
web: socserv.mcmaster.ca/jfox


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On
 Behalf Of Sergios (Sergey) Charntikov
 Sent: November-09-09 1:18 PM
 To: r-help@r-project.org
 Subject: [R] Getting Sphericity Tests for Within Subject Repeated Measure
 Anova (using car package) (Adjusted Dataset)
 
 [corrected dataset below]
 
 
 Hello everyone,
 
 I am trying to do within subjects repeated measures anova followed by the
 test of sphericity (sample dataset below).
 I am able to get either mixed model or linear model anova and TukeyHSD,
but
 have no luck with Repeated-Measures Assuming Sphericity or Separate
 Sphericity Tests.
 I am trying to follow example from car package, but it seems that I am
not
 getting something right.
 
  Dataset$Sessn - as.factor(Dataset$Sessn)
 
  LinearModel.1 - lm(Response ~ Sessn*Trtmt, data=Dataset)
 
  summary(LinearModel.1)
 
 All, good so far, but I have problem understanding idata= and idesign=
 functions pertaining to my example.  Session is my repeated measure (Sessn
1
 and Sessn 2 = two sessions, in reality I have more) and it is already
 stacked. Any help or guidance on this matter.
 
 Thank you, my mock dataset is below.  Each subject has two levels of
 treatment throughout four calendar days which are recoded to Session 1 and
 Session 2 in order to compare treatments by the first and subsequent days
of
 exposure (Treatment x Session; my DV is Response; Session is repeated).
 
 Subj  Trtmt  Sessn  Response
 1 N 1 5
 1 D 1 6
 1 N 2 4
 1 D 2 7
 2 N 1 8
 2 D 1 9
 2 N 2 2
 2 D 2 1
 3 N 1 4
 3 D 1 5
 3 N 2 6
 3 D 2 2
 4 N 1 5
 4 D 1 6
 4 N 2 4
 4 D 2 7
 5 N 1 8
 5 D 1 9
 5 N 2 2
 5 D 2 1
 6 N 1 4
 6 D 1 5
 6 N 2 6
 6 D 2 2
 
 
 
 Sincerely,
 
 Sergios Charntikov (Sergey), MA
 
 Behavioral Neuropharmacology Lab
 Department of Psychology
 University of Nebraska-Lincoln
 Lincoln, NE 68588-0308  USA
 
 sergioschr-at-gmail-dot-com
 
   [[alternative HTML version deleted]]
 
 __
 R-help@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.

__
R-help@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.


Re: [R] Getting Sphericity Tests for Within Subject Repeated Measure Anova (using car package) (Adjusted Dataset)

2009-11-09 Thread Sergios (Sergey) Charntikov
Based on what you suggested I did the following:


1. Dataset$Sessn - as.factor(Dataset$Sessn)
2. mod - lm(cbind(Sessn==1, Sessn==2) ~ Trtmt, data=Dataset)
3. idata - data.frame(Sessn=factor(1:2))
4. Anova(mod, idata=idata, idesign=~Sessn))
ERROR:  The error SSP matrix is apparently of deficient rank = 0  1

I have noticed that my DV (Response) is not in play in the coding above.
Then I have modified it to:

mod2 - lm(*Response*~(cbind(Sessn==1, Sessn==2)) * Trtmt, data=Dataset)
idata2 - data.frame(Sessn=factor(1:2))
Anova(mod, idata=idata2, idesign=~Sessn)
ERROR: The error SSP matrix is apparently of deficient rank = 0  1

Then I have modified it to:

mod2 - lm(Response~(cbind(Sessn==1, Sessn==2)) * Trtmt, data=Dataset)
idata2 - data.frame(Sessn=factor(1:2))
Anova(mod, idata=idata2, idesign=~*(cbind(Sessn==1, Sessn==2)) * Trtmt*)
ERROR:  object 'Trtmt' not found

Then I have modified it to:

mod2 - lm(Response~(cbind(Sessn==1, Sessn==2)) * Trtmt, data=Dataset)
idata2 - data.frame(Sessn=factor(1:2))
Anova(mod, idata=idata2, idesign=~(cbind(Sessn==1, Sessn==2)) * *
Dataset$Trtmt*)
ERROR:  variable lengths differ (found for 'Dataset$Trtmt') [THIS IS THE
ERROR THAT I HAVE BEEN
GETTING WITH MY ACTUAL DATASET FOLLOWING CAR PACKAGE RECOMMENDATIONS)

Any idea what am I doing wrong?  I have attached my mock data for
convenience in csv.


Sincerely,

Sergios Charntikov (Sergey), MA

Behavioral Neuropharmacology Lab
Department of Psychology
University of Nebraska-Lincoln
Lincoln, NE 68588-0308  USA

sergios...@gmail.com
www.unl.edu/psychoneuropharm/


On Mon, Nov 9, 2009 at 12:33 PM, John Fox j...@mcmaster.ca wrote:

 Dear Segios,

 For repeated-measures designs, the Anova() function requires a multivariate
 linear model fit to the wide version of the data set, in which each of
 the
 repeated measures appears as a separate variable. It is necessary that you
 have the same occasions observed for all subjects. For your scaled-down
 example, you'd have two response variables named, e.g., Sessn1 and Sessn2.
 Then you'd fit the multivariate linear model as mod - lm(cbind(Sessn1,
 Sessn2) ~ Trtmnt, data=Dataset). The idata data frame could simply be idata
 - data.frame(Sessn=factor(1:2)). Then you could get the MANOVA and
 repeated-measure ANOVA, including sphericity test, etc., as
 summary(Anova(mod, idata=idata, idesign=~Sessn)).

 I hope this helps,
  John

 
 John Fox
 Senator William McMaster
  Professor of Social Statistics
 Department of Sociology
 McMaster University
 Hamilton, Ontario, Canada
 web: socserv.mcmaster.ca/jfox


  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On
  Behalf Of Sergios (Sergey) Charntikov
  Sent: November-09-09 1:18 PM
  To: r-help@r-project.org
  Subject: [R] Getting Sphericity Tests for Within Subject Repeated Measure
  Anova (using car package) (Adjusted Dataset)
 
  [corrected dataset below]
 
 
  Hello everyone,
 
  I am trying to do within subjects repeated measures anova followed by the
  test of sphericity (sample dataset below).
  I am able to get either mixed model or linear model anova and TukeyHSD,
 but
  have no luck with Repeated-Measures Assuming Sphericity or Separate
  Sphericity Tests.
  I am trying to follow example from car package, but it seems that I am
 not
  getting something right.
 
   Dataset$Sessn - as.factor(Dataset$Sessn)
 
   LinearModel.1 - lm(Response ~ Sessn*Trtmt, data=Dataset)
 
   summary(LinearModel.1)
 
  All, good so far, but I have problem understanding idata= and
 idesign=
  functions pertaining to my example.  Session is my repeated measure
 (Sessn
 1
  and Sessn 2 = two sessions, in reality I have more) and it is already
  stacked. Any help or guidance on this matter.
 
  Thank you, my mock dataset is below.  Each subject has two levels of
  treatment throughout four calendar days which are recoded to Session 1
 and
  Session 2 in order to compare treatments by the first and subsequent days
 of
  exposure (Treatment x Session; my DV is Response; Session is repeated).
 
  Subj  Trtmt  Sessn  Response
  1 N 1 5
  1 D 1 6
  1 N 2 4
  1 D 2 7
  2 N 1 8
  2 D 1 9
  2 N 2 2
  2 D 2 1
  3 N 1 4
  3 D 1 5
  3 N 2 6
  3 D 2 2
  4 N 1 5
  4 D 1 6
  4 N 2 4
  4 D 2 7
  5 N 1 8
  5 D 1 9
  5 N 2 2
  5 D 2 1
  6 N 1 4
  6 D 1 5
  6 N 2 6
  6 D 2 2
 
 
 
  Sincerely,
 
  Sergios Charntikov (Sergey), MA
 
  Behavioral Neuropharmacology Lab
  Department of Psychology
  University of Nebraska-Lincoln
  Lincoln, NE 68588-0308  USA
 
  sergioschr-at-gmail-dot-com
 
[[alternative HTML version deleted]]
 
  __
  

Re: [R] Getting Sphericity Tests for Within Subject Repeated Measure Anova (using car package)

2009-11-09 Thread Mike Lawrence
Have you tried ezANOVA from the ez pacakge? It attempts to provide a
simple user interface to car's ANOVA (and when that fails, aov).

On Mon, Nov 9, 2009 at 1:44 PM, Sergios (Sergey) Charntikov
sergios...@gmail.com wrote:
 Hello everyone,

 I am trying to do within subjects repeated measures anova followed by the
 test of sphericity (sample dataset below).
 I am able to get either mixed model or linear model anova and TukeyHSD, but
 have no luck with Repeated-Measures Assuming Sphericity or Separate
 Sphericity Tests.
 I am trying to follow example from car package, but it seems that I am not
 getting something right.

 Dataset$Sessn - as.factor(Dataset$Sessn)

 LinearModel.1 - lm(Response ~ Sessn*Trtmt, data=Dataset)

 summary(LinearModel.1)

 All, good so far, but I have problem understanding idata= and idesign=
 functions pertaining to my example.  Session is my repeated measure (Sessn 1
 and Sessn 2 = two sessions, in reality I have more) and it is already
 stacked. Any help or guidance on this matter.

 Thank you, my mock dataset is below.  Each subject has two levels of
 treatment throughout four calendar days which are recoded to Session 1 and
 Session 2 in order to compare treatments by the first and subsequent days of
 exposure (Treatment x Session; my DV is Response; Session is repeated).

    Subj Trtmt Sessn Response  1 N 1 5  1 D 1 6  1 N 2 4  1 D 2 7  2 N 1 8
 2 D 1 9  2 N 2 2  2 D 2 1  3 N 1 4  3 D 1 5  3 N 2 6  3 D 2 2  4 N 1 5  4 D
 1 6  4 N 2 4  4 D 2 7  5 N 1 8  5 D 1 9  5 N 2 2  5 D 2 1  6 N 1 4  6 D 1 5
 6 N 2 6  6 D 2 2

 Sincerely,

 Sergios Charntikov (Sergey), MA

 Behavioral Neuropharmacology Lab
 Department of Psychology
 University of Nebraska-Lincoln
 Lincoln, NE 68588-0308  USA

 sergioschr-at-gmail-dot-com

        [[alternative HTML version deleted]]

 __
 R-help@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.





-- 
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University

Looking to arrange a meeting? Check my public calendar:
http://tr.im/mikes_public_calendar

~ Certainty is folly... I think. ~

__
R-help@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.


Re: [R] Getting Sphericity Tests for Within Subject Repeated Measure Anova (using car package)

2009-11-09 Thread Sergios (Sergey) Charntikov
Tried EZanova, no luck with my particular dataset.


Sincerely,

Sergios Charntikov (Sergey), MA

Behavioral Neuropharmacology Lab
Department of Psychology
University of Nebraska-Lincoln
Lincoln, NE 68588-0308  USA




On Mon, Nov 9, 2009 at 2:25 PM, Mike Lawrence mike.lawre...@dal.ca wrote:

 Have you tried ezANOVA from the ez pacakge? It attempts to provide a
 simple user interface to car's ANOVA (and when that fails, aov).

 On Mon, Nov 9, 2009 at 1:44 PM, Sergios (Sergey) Charntikov
 sergios...@gmail.com wrote:
  Hello everyone,
 
  I am trying to do within subjects repeated measures anova followed by the
  test of sphericity (sample dataset below).
  I am able to get either mixed model or linear model anova and TukeyHSD,
 but
  have no luck with Repeated-Measures Assuming Sphericity or Separate
  Sphericity Tests.
  I am trying to follow example from car package, but it seems that I am
 not
  getting something right.
 
  Dataset$Sessn - as.factor(Dataset$Sessn)
 
  LinearModel.1 - lm(Response ~ Sessn*Trtmt, data=Dataset)
 
  summary(LinearModel.1)
 
  All, good so far, but I have problem understanding idata= and
 idesign=
  functions pertaining to my example.  Session is my repeated measure
 (Sessn 1
  and Sessn 2 = two sessions, in reality I have more) and it is already
  stacked. Any help or guidance on this matter.
 
  Thank you, my mock dataset is below.  Each subject has two levels of
  treatment throughout four calendar days which are recoded to Session 1
 and
  Session 2 in order to compare treatments by the first and subsequent days
 of
  exposure (Treatment x Session; my DV is Response; Session is repeated).
 
 Subj Trtmt Sessn Response  1 N 1 5  1 D 1 6  1 N 2 4  1 D 2 7  2 N 1 8
  2 D 1 9  2 N 2 2  2 D 2 1  3 N 1 4  3 D 1 5  3 N 2 6  3 D 2 2  4 N 1 5  4
 D
  1 6  4 N 2 4  4 D 2 7  5 N 1 8  5 D 1 9  5 N 2 2  5 D 2 1  6 N 1 4  6 D 1
 5
  6 N 2 6  6 D 2 2
 
  Sincerely,
 
  Sergios Charntikov (Sergey), MA
 
  Behavioral Neuropharmacology Lab
  Department of Psychology
  University of Nebraska-Lincoln
  Lincoln, NE 68588-0308  USA
 
  sergioschr-at-gmail-dot-com
 
 [[alternative HTML version deleted]]
 
  __
  R-help@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.
 
 



 --
 Mike Lawrence
 Graduate Student
 Department of Psychology
 Dalhousie University

 Looking to arrange a meeting? Check my public calendar:
 http://tr.im/mikes_public_calendar

 ~ Certainty is folly... I think. ~


[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Getting Sphericity Tests for Within Subject Repeated Measure Anova (using car package) (Adjusted Dataset)

2009-11-09 Thread Peter Dalgaard

Sergios (Sergey) Charntikov wrote:

Based on what you suggested I did the following:


1. Dataset$Sessn - as.factor(Dataset$Sessn)
2. mod - lm(cbind(Sessn==1, Sessn==2) ~ Trtmt, data=Dataset)
3. idata - data.frame(Sessn=factor(1:2))
4. Anova(mod, idata=idata, idesign=~Sessn))
ERROR:  The error SSP matrix is apparently of deficient rank = 0  1

I have noticed that my DV (Response) is not in play in the coding above.
Then I have modified it to:

mod2 - lm(*Response*~(cbind(Sessn==1, Sessn==2)) * Trtmt, data=Dataset)
idata2 - data.frame(Sessn=factor(1:2))
Anova(mod, idata=idata2, idesign=~Sessn)
ERROR: The error SSP matrix is apparently of deficient rank = 0  1

Then I have modified it to:

mod2 - lm(Response~(cbind(Sessn==1, Sessn==2)) * Trtmt, data=Dataset)
idata2 - data.frame(Sessn=factor(1:2))
Anova(mod, idata=idata2, idesign=~*(cbind(Sessn==1, Sessn==2)) * Trtmt*)
ERROR:  object 'Trtmt' not found

Then I have modified it to:

mod2 - lm(Response~(cbind(Sessn==1, Sessn==2)) * Trtmt, data=Dataset)
idata2 - data.frame(Sessn=factor(1:2))
Anova(mod, idata=idata2, idesign=~(cbind(Sessn==1, Sessn==2)) * *
Dataset$Trtmt*)
ERROR:  variable lengths differ (found for 'Dataset$Trtmt') [THIS IS THE
ERROR THAT I HAVE BEEN
GETTING WITH MY ACTUAL DATASET FOLLOWING CAR PACKAGE RECOMMENDATIONS)




Any idea what am I doing wrong?  I have attached my mock data for
convenience in csv.


Either you forgot, or your mailer did not say that it is a text file, 
and the mailing list software consequently scrubbed it...


I think what you need is an analysis of 6 observations with a 
2x2==4-dimensional response. You may want to look at my paper in R News 
2007-2. The reacttime example used there is pretty similar. You're not 
going to get much sphericity testing when all factors have only two 
levels, though.




Sincerely,

Sergios Charntikov (Sergey), MA

Behavioral Neuropharmacology Lab
Department of Psychology
University of Nebraska-Lincoln
Lincoln, NE 68588-0308  USA

sergios...@gmail.com
www.unl.edu/psychoneuropharm/


On Mon, Nov 9, 2009 at 12:33 PM, John Fox j...@mcmaster.ca wrote:


Dear Segios,

For repeated-measures designs, the Anova() function requires a multivariate
linear model fit to the wide version of the data set, in which each of
the
repeated measures appears as a separate variable. It is necessary that you
have the same occasions observed for all subjects. For your scaled-down
example, you'd have two response variables named, e.g., Sessn1 and Sessn2.
Then you'd fit the multivariate linear model as mod - lm(cbind(Sessn1,
Sessn2) ~ Trtmnt, data=Dataset). The idata data frame could simply be idata
- data.frame(Sessn=factor(1:2)). Then you could get the MANOVA and
repeated-measure ANOVA, including sphericity test, etc., as
summary(Anova(mod, idata=idata, idesign=~Sessn)).

I hope this helps,
 John


John Fox
Senator William McMaster
 Professor of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
web: socserv.mcmaster.ca/jfox



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]

On

Behalf Of Sergios (Sergey) Charntikov
Sent: November-09-09 1:18 PM
To: r-help@r-project.org
Subject: [R] Getting Sphericity Tests for Within Subject Repeated Measure
Anova (using car package) (Adjusted Dataset)

[corrected dataset below]


Hello everyone,

I am trying to do within subjects repeated measures anova followed by the
test of sphericity (sample dataset below).
I am able to get either mixed model or linear model anova and TukeyHSD,

but

have no luck with Repeated-Measures Assuming Sphericity or Separate
Sphericity Tests.
I am trying to follow example from car package, but it seems that I am

not

getting something right.


Dataset$Sessn - as.factor(Dataset$Sessn)
LinearModel.1 - lm(Response ~ Sessn*Trtmt, data=Dataset)
summary(LinearModel.1)

All, good so far, but I have problem understanding idata= and

idesign=

functions pertaining to my example.  Session is my repeated measure

(Sessn
1

and Sessn 2 = two sessions, in reality I have more) and it is already
stacked. Any help or guidance on this matter.

Thank you, my mock dataset is below.  Each subject has two levels of
treatment throughout four calendar days which are recoded to Session 1

and

Session 2 in order to compare treatments by the first and subsequent days

of

exposure (Treatment x Session; my DV is Response; Session is repeated).

Subj  Trtmt  Sessn  Response
1 N 1 5
1 D 1 6
1 N 2 4
1 D 2 7
2 N 1 8
2 D 1 9
2 N 2 2
2 D 2 1
3 N 1 4
3 D 1 5
3 N 2 6
3 D 2 2
4 N 1 5
4 D 1 6
4 N 2 4
4 D 2 7
5 N 1 8
5 D 1 9
5 N 2 2
5 D 2 1
6 N 1 4
6 D 1 5
6 N 2 6
6 D 2 

Re: [R] Getting Sphericity Tests for Within Subject Repeated Measure Anova (using car package)

2009-11-09 Thread Mike Lawrence
No luck as in...? What error did you encounter?

In your example data set, you only have 2 levels of each within-Ss
factor, in which case you shouldn't expect to obtain tests of
sphericity; as far as I understand it, sphericity necessarily holds
when for repeated measures with only 2 levels and tests are really
only possible for repeated measures with 3 or more levels.

I think it's analogous to how you don't need to test homogeneity of
variance when performing a paired t-test; the test ends up
representing the pairs as single distribution of difference scores
with a single variance.

Mike

On Mon, Nov 9, 2009 at 5:30 PM, Sergios (Sergey) Charntikov
sergios...@gmail.com wrote:
 Tried EZanova, no luck with my particular dataset.


 Sincerely,

 Sergios Charntikov (Sergey), MA

 Behavioral Neuropharmacology Lab
 Department of Psychology
 University of Nebraska-Lincoln
 Lincoln, NE 68588-0308  USA




 On Mon, Nov 9, 2009 at 2:25 PM, Mike Lawrence mike.lawre...@dal.ca wrote:

 Have you tried ezANOVA from the ez pacakge? It attempts to provide a
 simple user interface to car's ANOVA (and when that fails, aov).

 On Mon, Nov 9, 2009 at 1:44 PM, Sergios (Sergey) Charntikov
 sergios...@gmail.com wrote:
  Hello everyone,
 
  I am trying to do within subjects repeated measures anova followed by
  the
  test of sphericity (sample dataset below).
  I am able to get either mixed model or linear model anova and TukeyHSD,
  but
  have no luck with Repeated-Measures Assuming Sphericity or Separate
  Sphericity Tests.
  I am trying to follow example from car package, but it seems that I am
  not
  getting something right.
 
  Dataset$Sessn - as.factor(Dataset$Sessn)
 
  LinearModel.1 - lm(Response ~ Sessn*Trtmt, data=Dataset)
 
  summary(LinearModel.1)
 
  All, good so far, but I have problem understanding idata= and
  idesign=
  functions pertaining to my example.  Session is my repeated measure
  (Sessn 1
  and Sessn 2 = two sessions, in reality I have more) and it is already
  stacked. Any help or guidance on this matter.
 
  Thank you, my mock dataset is below.  Each subject has two levels of
  treatment throughout four calendar days which are recoded to Session 1
  and
  Session 2 in order to compare treatments by the first and subsequent
  days of
  exposure (Treatment x Session; my DV is Response; Session is repeated).
 
     Subj Trtmt Sessn Response  1 N 1 5  1 D 1 6  1 N 2 4  1 D 2 7  2 N 1
  8
  2 D 1 9  2 N 2 2  2 D 2 1  3 N 1 4  3 D 1 5  3 N 2 6  3 D 2 2  4 N 1 5
   4 D
  1 6  4 N 2 4  4 D 2 7  5 N 1 8  5 D 1 9  5 N 2 2  5 D 2 1  6 N 1 4  6 D
  1 5
  6 N 2 6  6 D 2 2
 
  Sincerely,
 
  Sergios Charntikov (Sergey), MA
 
  Behavioral Neuropharmacology Lab
  Department of Psychology
  University of Nebraska-Lincoln
  Lincoln, NE 68588-0308  USA
 
  sergioschr-at-gmail-dot-com
 
         [[alternative HTML version deleted]]
 
  __
  R-help@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.
 
 



 --
 Mike Lawrence
 Graduate Student
 Department of Psychology
 Dalhousie University

 Looking to arrange a meeting? Check my public calendar:
 http://tr.im/mikes_public_calendar

 ~ Certainty is folly... I think. ~





-- 
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University

Looking to arrange a meeting? Check my public calendar:
http://tr.im/mikes_public_calendar

~ Certainty is folly... I think. ~

__
R-help@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.


Re: [R] Getting Sphericity Tests for Within Subject Repeated Measure Anova (using car package)

2009-11-09 Thread Sergios (Sergey) Charntikov
Hi Mike,

I tried to run my data in SPSS and it works fine without any problems,
plug in my levels, plug in my covariate (since it is all within) and
get my Mauchly Tests.

I tried to rearrange the data so it looks like this

subj/treatment/day1/day2/day3

subject    treatment    day1    day2    day3
1    1    8    8    8
1    2    5    7    5
2    1    7    4    4
2    2    4    5    7
3    1    8    6    4
3    2    5    2    4
4    1    2    9    4
4    2    1    9    1
5    1    4    8    1
5    2    7    8    2
6    1    4    7    2
6    2    4    5    2


When I try mlmfit - lm(Dataset~1), I get invalid type (list) for
variable 'Dataset

When I try

mod - lm(cbind(day1, day2, day3) ~ Treatment, data=Dataset)

idata- data.frame(factor(rep(c(Dataset$day1, Dataset$day2, Dataset$day3))),
ordered(Dataset$Treatment))

Anova(mod, idata=idata, idesign=~Dataset$Treatment)

I get: Terms in the intra-subject model matrix are not orthogonal.

When I try is.matrix(Dataset) - I get no.

My original mock Dataset (attached in txt) is below.  Maybe I am not
coding it right? I would hate to recode all my data for SPSS, since at
the end I would need to show that Sphericity was not violated.

SubjTrtmt   Sessn   Response

1   N   1   5

1   D   1   6

1   N   2   4

1   D   2   7

2   N   1   8

2   D   1   9

2   N   2   2

2   D   2   1

3   N   1   4

3   D   1   5

3   N   2   6

3   D   2   2

4   N   1   5

4   D   1   6

4   N   2   4

4   D   2   7

5   N   1   8

5   D   1   9

5   N   2   2

5   D   2   1

6   N   1   4

6   D   1   5

6   N   2   6

6   D   2   2




Sincerely,

Sergios Charntikov (Sergey), MA

Behavioral Neuropharmacology Lab
Department of Psychology
University of Nebraska-Lincoln
Lincoln, NE 68588-0308  USA



On Mon, Nov 9, 2009 at 5:29 PM, Mike Lawrence mike.lawre...@dal.ca wrote:

 No luck as in...? What error did you encounter?

 In your example data set, you only have 2 levels of each within-Ss
 factor, in which case you shouldn't expect to obtain tests of
 sphericity; as far as I understand it, sphericity necessarily holds
 when for repeated measures with only 2 levels and tests are really
 only possible for repeated measures with 3 or more levels.

 I think it's analogous to how you don't need to test homogeneity of
 variance when performing a paired t-test; the test ends up
 representing the pairs as single distribution of difference scores
 with a single variance.

 Mike

 On Mon, Nov 9, 2009 at 5:30 PM, Sergios (Sergey) Charntikov
 sergios...@gmail.com wrote:
  Tried EZanova, no luck with my particular dataset.
 
 
  Sincerely,
 
  Sergios Charntikov (Sergey), MA
 
  Behavioral Neuropharmacology Lab
  Department of Psychology
  University of Nebraska-Lincoln
  Lincoln, NE 68588-0308  USA
 
 
 
 
  On Mon, Nov 9, 2009 at 2:25 PM, Mike Lawrence mike.lawre...@dal.ca wrote:
 
  Have you tried ezANOVA from the ez pacakge? It attempts to provide a
  simple user interface to car's ANOVA (and when that fails, aov).
 
  On Mon, Nov 9, 2009 at 1:44 PM, Sergios (Sergey) Charntikov
  sergios...@gmail.com wrote:
   Hello everyone,
  
   I am trying to do within subjects repeated measures anova followed by
   the
   test of sphericity (sample dataset below).
   I am able to get either mixed model or linear model anova and TukeyHSD,
   but
   have no luck with Repeated-Measures Assuming Sphericity or Separate
   Sphericity Tests.
   I am trying to follow example from car package, but it seems that I am
   not
   getting something right.
  
   Dataset$Sessn - as.factor(Dataset$Sessn)
  
   LinearModel.1 - lm(Response ~ Sessn*Trtmt, data=Dataset)
  
   summary(LinearModel.1)
  
   All, good so far, but I have problem understanding idata= and
   idesign=
   functions pertaining to my example.  Session is my repeated measure
   (Sessn 1
   and Sessn 2 = two sessions, in reality I have more) and it is already
   stacked. Any help or guidance on this matter.
  
   Thank you, my mock dataset is below.  Each subject has two levels of
   treatment throughout four calendar days which are recoded to Session 1
   and
   Session 2 in order to compare treatments by the first and subsequent
   days of
   exposure (Treatment x Session; my DV is Response; Session is repeated).
  
      Subj Trtmt Sessn Response  1 N 1 5  1 D 1 6  1 N 2 4  1 D 2 7  2 N 1
   8
   2 D 1 9  2 N 2 2  2 D 2 1  3 N 1 4  3 D 1 5  3 N 2 6  3 D 2 2  4 N 1 5
    4 D
   1 6  4 N 2 4  4 D 2 7  5 N 1 8  5 D 1 9  5 N 2 2  5 D 2 1  6 N 1 4  6 D
   1 5
   6 N 2 6  6 D 2 2
  
   Sincerely,
  
   Sergios Charntikov (Sergey), MA
  
   Behavioral Neuropharmacology Lab
   Department of Psychology
   University of Nebraska-Lincoln
   Lincoln, NE 68588-0308  USA
  

Re: [R] Getting Sphericity Tests for Within Subject Repeated Measure Anova (using car package)

2009-11-09 Thread John Fox
Dear Sergios,

Why don't you try what I suggested originally? Adapted to this data set,

mod - lm(cbind(day1, day2, day3) ~ Treatment, data=Dataset)
idata - data.frame(Day=factor(1:3))
summary(Anova(mod, idata=idata, idesign=~Day))

Peter Dalgaard also pointed toward an article that describes how to do the
same thing with anova().

Regards,
 John

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On
 Behalf Of Sergios (Sergey) Charntikov
 Sent: November-09-09 7:13 PM
 To: Mike Lawrence
 Cc: r-help@r-project.org
 Subject: Re: [R] Getting Sphericity Tests for Within Subject Repeated
Measure
 Anova (using car package)
 
 Hi Mike,
 
 I tried to run my data in SPSS and it works fine without any problems,
plug
 in my levels, plug in my covariate (since it is all within) and get my
 Mauchly Tests.
 
 I tried to rearrange the data so it looks like this
 
 subj/treatment/day1/day2/day3
 
 subject    treatment    day1    day2    day3
 1    1    8    8    8
 1    2    5    7    5
 2    1    7    4    4
 2    2    4    5    7
 3    1    8    6    4
 3    2    5    2    4
 4    1    2    9    4
 4    2    1    9    1
 5    1    4    8    1
 5    2    7    8    2
 6    1    4    7    2
 6    2    4    5    2
 
 
 When I try mlmfit - lm(Dataset~1), I get invalid type (list) for
variable
 'Dataset
 
 When I try
 
 mod - lm(cbind(day1, day2, day3) ~ Treatment, data=Dataset)
 
 idata- data.frame(factor(rep(c(Dataset$day1, Dataset$day2,
Dataset$day3))),
 ordered(Dataset$Treatment))
 
 Anova(mod, idata=idata, idesign=~Dataset$Treatment)
 
 I get: Terms in the intra-subject model matrix are not orthogonal.
 
 When I try is.matrix(Dataset) - I get no.
 
 My original mock Dataset (attached in txt) is below.  Maybe I am not
coding
 it right? I would hate to recode all my data for SPSS, since at the end I
 would need to show that Sphericity was not violated.
 
 Subj  Trtmt   Sessn   Response
 
 1 N   1   5
 
 1 D   1   6
 
 1 N   2   4
 
 1 D   2   7
 
 2 N   1   8
 
 2 D   1   9
 
 2 N   2   2
 
 2 D   2   1
 
 3 N   1   4
 
 3 D   1   5
 
 3 N   2   6
 
 3 D   2   2
 
 4 N   1   5
 
 4 D   1   6
 
 4 N   2   4
 
 4 D   2   7
 
 5 N   1   8
 
 5 D   1   9
 
 5 N   2   2
 
 5 D   2   1
 
 6 N   1   4
 
 6 D   1   5
 
 6 N   2   6
 
 6 D   2   2
 
 
 
 
 Sincerely,
 
 Sergios Charntikov (Sergey), MA
 
 Behavioral Neuropharmacology Lab
 Department of Psychology
 University of Nebraska-Lincoln
 Lincoln, NE 68588-0308  USA
 
 
 
 On Mon, Nov 9, 2009 at 5:29 PM, Mike Lawrence mike.lawre...@dal.ca
wrote:
 
  No luck as in...? What error did you encounter?
 
  In your example data set, you only have 2 levels of each within-Ss
  factor, in which case you shouldn't expect to obtain tests of
  sphericity; as far as I understand it, sphericity necessarily holds
  when for repeated measures with only 2 levels and tests are really
  only possible for repeated measures with 3 or more levels.
 
  I think it's analogous to how you don't need to test homogeneity of
  variance when performing a paired t-test; the test ends up
  representing the pairs as single distribution of difference scores
  with a single variance.
 
  Mike
 
  On Mon, Nov 9, 2009 at 5:30 PM, Sergios (Sergey) Charntikov
  sergios...@gmail.com wrote:
   Tried EZanova, no luck with my particular dataset.
  
  
   Sincerely,
  
   Sergios Charntikov (Sergey), MA
  
   Behavioral Neuropharmacology Lab
   Department of Psychology
   University of Nebraska-Lincoln
   Lincoln, NE 68588-0308  USA
  
  
  
  
   On Mon, Nov 9, 2009 at 2:25 PM, Mike Lawrence mike.lawre...@dal.ca
 wrote:
  
   Have you tried ezANOVA from the ez pacakge? It attempts to provide
   a simple user interface to car's ANOVA (and when that fails, aov).
  
   On Mon, Nov 9, 2009 at 1:44 PM, Sergios (Sergey) Charntikov
   sergios...@gmail.com wrote:
Hello everyone,
   
I am trying to do within subjects repeated measures anova
followed by the test of sphericity (sample dataset below).
I am able to get either mixed model or linear model anova and
TukeyHSD, but have no luck with Repeated-Measures Assuming
Sphericity or Separate Sphericity Tests.
I am trying to follow example from car package, but it seems
that I am not getting something right.
   
Dataset$Sessn - as.factor(Dataset$Sessn)
   
LinearModel.1 - lm(Response ~ Sessn*Trtmt, data=Dataset)
   
summary(LinearModel.1)
   
All, good so far, but I have problem understanding idata= and
idesign=
functions pertaining to my example.  Session is my repeated
measure (Sessn 1 and Sessn 2 = two sessions, in reality I have
more) and it is already stacked. Any help or guidance

Re: [R] Getting Sphericity Tests for Within Subject Repeated Measure Anova (using car package)

2009-11-09 Thread Sergios (Sergey) Charntikov
Thank you very much.  Finally got it to work.  However, I had to recode it from:
columns: subject/treatment/DV (where all my response data was in one
DV column) to columns: subject/treatment/day1/day2/day3/ (where my
response data is now in three different columns).

Is there a way to do that without hand recoding (cutting and pasting
in spreadsheet) by hand? Thank you for your help.  Glad it works as
is.


Sincerely,

Sergios Charntikov (Sergey), MA

Behavioral Neuropharmacology Lab
Department of Psychology
University of Nebraska-Lincoln
Lincoln, NE 68588-0308  USA





On Mon, Nov 9, 2009 at 7:12 PM, John Fox j...@mcmaster.ca wrote:
 Dear Sergios,

 Why don't you try what I suggested originally? Adapted to this data set,

 mod - lm(cbind(day1, day2, day3) ~ Treatment, data=Dataset)
 idata - data.frame(Day=factor(1:3))
 summary(Anova(mod, idata=idata, idesign=~Day))

 Peter Dalgaard also pointed toward an article that describes how to do the
 same thing with anova().

 Regards,
  John

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On
 Behalf Of Sergios (Sergey) Charntikov
 Sent: November-09-09 7:13 PM
 To: Mike Lawrence
 Cc: r-help@r-project.org
 Subject: Re: [R] Getting Sphericity Tests for Within Subject Repeated
 Measure
 Anova (using car package)

 Hi Mike,

 I tried to run my data in SPSS and it works fine without any problems,
 plug
 in my levels, plug in my covariate (since it is all within) and get my
 Mauchly Tests.

 I tried to rearrange the data so it looks like this

 subj/treatment/day1/day2/day3

 subject    treatment    day1    day2    day3
 1    1    8    8    8
 1    2    5    7    5
 2    1    7    4    4
 2    2    4    5    7
 3    1    8    6    4
 3    2    5    2    4
 4    1    2    9    4
 4    2    1    9    1
 5    1    4    8    1
 5    2    7    8    2
 6    1    4    7    2
 6    2    4    5    2


 When I try mlmfit - lm(Dataset~1), I get invalid type (list) for
 variable
 'Dataset

 When I try

 mod - lm(cbind(day1, day2, day3) ~ Treatment, data=Dataset)

 idata- data.frame(factor(rep(c(Dataset$day1, Dataset$day2,
 Dataset$day3))),
 ordered(Dataset$Treatment))

 Anova(mod, idata=idata, idesign=~Dataset$Treatment)

 I get: Terms in the intra-subject model matrix are not orthogonal.

 When I try is.matrix(Dataset) - I get no.

 My original mock Dataset (attached in txt) is below.  Maybe I am not
 coding
 it right? I would hate to recode all my data for SPSS, since at the end I
 would need to show that Sphericity was not violated.

 Subj  Trtmt   Sessn   Response

 1     N       1       5

 1     D       1       6

 1     N       2       4

 1     D       2       7

 2     N       1       8

 2     D       1       9

 2     N       2       2

 2     D       2       1

 3     N       1       4

 3     D       1       5

 3     N       2       6

 3     D       2       2

 4     N       1       5

 4     D       1       6

 4     N       2       4

 4     D       2       7

 5     N       1       8

 5     D       1       9

 5     N       2       2

 5     D       2       1

 6     N       1       4

 6     D       1       5

 6     N       2       6

 6     D       2       2




 Sincerely,

 Sergios Charntikov (Sergey), MA

 Behavioral Neuropharmacology Lab
 Department of Psychology
 University of Nebraska-Lincoln
 Lincoln, NE 68588-0308  USA



 On Mon, Nov 9, 2009 at 5:29 PM, Mike Lawrence mike.lawre...@dal.ca
 wrote:
 
  No luck as in...? What error did you encounter?
 
  In your example data set, you only have 2 levels of each within-Ss
  factor, in which case you shouldn't expect to obtain tests of
  sphericity; as far as I understand it, sphericity necessarily holds
  when for repeated measures with only 2 levels and tests are really
  only possible for repeated measures with 3 or more levels.
 
  I think it's analogous to how you don't need to test homogeneity of
  variance when performing a paired t-test; the test ends up
  representing the pairs as single distribution of difference scores
  with a single variance.
 
  Mike
 
  On Mon, Nov 9, 2009 at 5:30 PM, Sergios (Sergey) Charntikov
  sergios...@gmail.com wrote:
   Tried EZanova, no luck with my particular dataset.
  
  
   Sincerely,
  
   Sergios Charntikov (Sergey), MA
  
   Behavioral Neuropharmacology Lab
   Department of Psychology
   University of Nebraska-Lincoln
   Lincoln, NE 68588-0308  USA
  
  
  
  
   On Mon, Nov 9, 2009 at 2:25 PM, Mike Lawrence mike.lawre...@dal.ca
 wrote:
  
   Have you tried ezANOVA from the ez pacakge? It attempts to provide
   a simple user interface to car's ANOVA (and when that fails, aov).
  
   On Mon, Nov 9, 2009 at 1:44 PM, Sergios (Sergey) Charntikov
   sergios...@gmail.com wrote:
Hello everyone,
   
I am trying to do within subjects repeated measures anova
followed by the test of sphericity (sample dataset below).
I am able to get either mixed model or linear model anova and
TukeyHSD

Re: [R] Getting Sphericity Tests for Within Subject Repeated Measure Anova (using car package)

2009-11-09 Thread Ista Zahn
Yes, reshaping data is straightforward in R. No need to copy/paste in
a spreadsheet.
See ?reshape and/or the melt/cast functions in the reshape package.

-Ista

On Mon, Nov 9, 2009 at 9:20 PM, Sergios (Sergey) Charntikov
sergios...@gmail.com wrote:
 Thank you very much.  Finally got it to work.  However, I had to recode it 
 from:
 columns: subject/treatment/DV (where all my response data was in one
 DV column) to columns: subject/treatment/day1/day2/day3/ (where my
 response data is now in three different columns).

 Is there a way to do that without hand recoding (cutting and pasting
 in spreadsheet) by hand? Thank you for your help.  Glad it works as
 is.


 Sincerely,

 Sergios Charntikov (Sergey), MA

 Behavioral Neuropharmacology Lab
 Department of Psychology
 University of Nebraska-Lincoln
 Lincoln, NE 68588-0308  USA





 On Mon, Nov 9, 2009 at 7:12 PM, John Fox j...@mcmaster.ca wrote:
 Dear Sergios,

 Why don't you try what I suggested originally? Adapted to this data set,

 mod - lm(cbind(day1, day2, day3) ~ Treatment, data=Dataset)
 idata - data.frame(Day=factor(1:3))
 summary(Anova(mod, idata=idata, idesign=~Day))

 Peter Dalgaard also pointed toward an article that describes how to do the
 same thing with anova().

 Regards,
  John

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On
 Behalf Of Sergios (Sergey) Charntikov
 Sent: November-09-09 7:13 PM
 To: Mike Lawrence
 Cc: r-help@r-project.org
 Subject: Re: [R] Getting Sphericity Tests for Within Subject Repeated
 Measure
 Anova (using car package)

 Hi Mike,

 I tried to run my data in SPSS and it works fine without any problems,
 plug
 in my levels, plug in my covariate (since it is all within) and get my
 Mauchly Tests.

 I tried to rearrange the data so it looks like this

 subj/treatment/day1/day2/day3

 subject    treatment    day1    day2    day3
 1    1    8    8    8
 1    2    5    7    5
 2    1    7    4    4
 2    2    4    5    7
 3    1    8    6    4
 3    2    5    2    4
 4    1    2    9    4
 4    2    1    9    1
 5    1    4    8    1
 5    2    7    8    2
 6    1    4    7    2
 6    2    4    5    2


 When I try mlmfit - lm(Dataset~1), I get invalid type (list) for
 variable
 'Dataset

 When I try

 mod - lm(cbind(day1, day2, day3) ~ Treatment, data=Dataset)

 idata- data.frame(factor(rep(c(Dataset$day1, Dataset$day2,
 Dataset$day3))),
 ordered(Dataset$Treatment))

 Anova(mod, idata=idata, idesign=~Dataset$Treatment)

 I get: Terms in the intra-subject model matrix are not orthogonal.

 When I try is.matrix(Dataset) - I get no.

 My original mock Dataset (attached in txt) is below.  Maybe I am not
 coding
 it right? I would hate to recode all my data for SPSS, since at the end I
 would need to show that Sphericity was not violated.

 Subj  Trtmt   Sessn   Response

 1     N       1       5

 1     D       1       6

 1     N       2       4

 1     D       2       7

 2     N       1       8

 2     D       1       9

 2     N       2       2

 2     D       2       1

 3     N       1       4

 3     D       1       5

 3     N       2       6

 3     D       2       2

 4     N       1       5

 4     D       1       6

 4     N       2       4

 4     D       2       7

 5     N       1       8

 5     D       1       9

 5     N       2       2

 5     D       2       1

 6     N       1       4

 6     D       1       5

 6     N       2       6

 6     D       2       2




 Sincerely,

 Sergios Charntikov (Sergey), MA

 Behavioral Neuropharmacology Lab
 Department of Psychology
 University of Nebraska-Lincoln
 Lincoln, NE 68588-0308  USA



 On Mon, Nov 9, 2009 at 5:29 PM, Mike Lawrence mike.lawre...@dal.ca
 wrote:
 
  No luck as in...? What error did you encounter?
 
  In your example data set, you only have 2 levels of each within-Ss
  factor, in which case you shouldn't expect to obtain tests of
  sphericity; as far as I understand it, sphericity necessarily holds
  when for repeated measures with only 2 levels and tests are really
  only possible for repeated measures with 3 or more levels.
 
  I think it's analogous to how you don't need to test homogeneity of
  variance when performing a paired t-test; the test ends up
  representing the pairs as single distribution of difference scores
  with a single variance.
 
  Mike
 
  On Mon, Nov 9, 2009 at 5:30 PM, Sergios (Sergey) Charntikov
  sergios...@gmail.com wrote:
   Tried EZanova, no luck with my particular dataset.
  
  
   Sincerely,
  
   Sergios Charntikov (Sergey), MA
  
   Behavioral Neuropharmacology Lab
   Department of Psychology
   University of Nebraska-Lincoln
   Lincoln, NE 68588-0308  USA
  
  
  
  
   On Mon, Nov 9, 2009 at 2:25 PM, Mike Lawrence mike.lawre...@dal.ca
 wrote:
  
   Have you tried ezANOVA from the ez pacakge? It attempts to provide
   a simple user interface to car's ANOVA (and when that fails, aov).
  
   On Mon, Nov 9, 2009 at 1:44 PM, Sergios (Sergey) Charntikov

Re: [R] Getting Sphericity Tests for Within Subject Repeated Measure Anova (using car package)

2009-11-09 Thread Sergios (Sergey) Charntikov
Thank you very much for all your help.  This helped a lot. Very
constructive input.

Sincerely,

Sergios Charntikov (Sergey), MA

Behavioral Neuropharmacology Lab
Department of Psychology
University of Nebraska-Lincoln
Lincoln, NE 68588-0308  USA





On Mon, Nov 9, 2009 at 9:53 PM, Ista Zahn istaz...@gmail.com wrote:
 Yes, reshaping data is straightforward in R. No need to copy/paste in
 a spreadsheet.
 See ?reshape and/or the melt/cast functions in the reshape package.

 -Ista

 On Mon, Nov 9, 2009 at 9:20 PM, Sergios (Sergey) Charntikov
 sergios...@gmail.com wrote:
 Thank you very much.  Finally got it to work.  However, I had to recode it 
 from:
 columns: subject/treatment/DV (where all my response data was in one
 DV column) to columns: subject/treatment/day1/day2/day3/ (where my
 response data is now in three different columns).

 Is there a way to do that without hand recoding (cutting and pasting
 in spreadsheet) by hand? Thank you for your help.  Glad it works as
 is.


 Sincerely,

 Sergios Charntikov (Sergey), MA

 Behavioral Neuropharmacology Lab
 Department of Psychology
 University of Nebraska-Lincoln
 Lincoln, NE 68588-0308  USA





 On Mon, Nov 9, 2009 at 7:12 PM, John Fox j...@mcmaster.ca wrote:
 Dear Sergios,

 Why don't you try what I suggested originally? Adapted to this data set,

 mod - lm(cbind(day1, day2, day3) ~ Treatment, data=Dataset)
 idata - data.frame(Day=factor(1:3))
 summary(Anova(mod, idata=idata, idesign=~Day))

 Peter Dalgaard also pointed toward an article that describes how to do the
 same thing with anova().

 Regards,
  John

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On
 Behalf Of Sergios (Sergey) Charntikov
 Sent: November-09-09 7:13 PM
 To: Mike Lawrence
 Cc: r-help@r-project.org
 Subject: Re: [R] Getting Sphericity Tests for Within Subject Repeated
 Measure
 Anova (using car package)

 Hi Mike,

 I tried to run my data in SPSS and it works fine without any problems,
 plug
 in my levels, plug in my covariate (since it is all within) and get my
 Mauchly Tests.

 I tried to rearrange the data so it looks like this

 subj/treatment/day1/day2/day3

 subject    treatment    day1    day2    day3
 1    1    8    8    8
 1    2    5    7    5
 2    1    7    4    4
 2    2    4    5    7
 3    1    8    6    4
 3    2    5    2    4
 4    1    2    9    4
 4    2    1    9    1
 5    1    4    8    1
 5    2    7    8    2
 6    1    4    7    2
 6    2    4    5    2


 When I try mlmfit - lm(Dataset~1), I get invalid type (list) for
 variable
 'Dataset

 When I try

 mod - lm(cbind(day1, day2, day3) ~ Treatment, data=Dataset)

 idata- data.frame(factor(rep(c(Dataset$day1, Dataset$day2,
 Dataset$day3))),
 ordered(Dataset$Treatment))

 Anova(mod, idata=idata, idesign=~Dataset$Treatment)

 I get: Terms in the intra-subject model matrix are not orthogonal.

 When I try is.matrix(Dataset) - I get no.

 My original mock Dataset (attached in txt) is below.  Maybe I am not
 coding
 it right? I would hate to recode all my data for SPSS, since at the end I
 would need to show that Sphericity was not violated.

 Subj  Trtmt   Sessn   Response

 1     N       1       5

 1     D       1       6

 1     N       2       4

 1     D       2       7

 2     N       1       8

 2     D       1       9

 2     N       2       2

 2     D       2       1

 3     N       1       4

 3     D       1       5

 3     N       2       6

 3     D       2       2

 4     N       1       5

 4     D       1       6

 4     N       2       4

 4     D       2       7

 5     N       1       8

 5     D       1       9

 5     N       2       2

 5     D       2       1

 6     N       1       4

 6     D       1       5

 6     N       2       6

 6     D       2       2




 Sincerely,

 Sergios Charntikov (Sergey), MA

 Behavioral Neuropharmacology Lab
 Department of Psychology
 University of Nebraska-Lincoln
 Lincoln, NE 68588-0308  USA



 On Mon, Nov 9, 2009 at 5:29 PM, Mike Lawrence mike.lawre...@dal.ca
 wrote:
 
  No luck as in...? What error did you encounter?
 
  In your example data set, you only have 2 levels of each within-Ss
  factor, in which case you shouldn't expect to obtain tests of
  sphericity; as far as I understand it, sphericity necessarily holds
  when for repeated measures with only 2 levels and tests are really
  only possible for repeated measures with 3 or more levels.
 
  I think it's analogous to how you don't need to test homogeneity of
  variance when performing a paired t-test; the test ends up
  representing the pairs as single distribution of difference scores
  with a single variance.
 
  Mike
 
  On Mon, Nov 9, 2009 at 5:30 PM, Sergios (Sergey) Charntikov
  sergios...@gmail.com wrote:
   Tried EZanova, no luck with my particular dataset.
  
  
   Sincerely,
  
   Sergios Charntikov (Sergey), MA
  
   Behavioral Neuropharmacology Lab
   Department of Psychology
   University of Nebraska-Lincoln