简体   繁体   中英

manova () in R with between and within subject factors

I am using stats() 3.5.2 to run a manova with:

  • participant 1:20
  • gender as between subject factor
  • group as within subject factor
  • anxiety as dependent measure
  • BAC as dependent measures

The dataset follow:

treat4 = data.frame (
   participant = rep(1:20,3),
   gender = factor (rep(c(rep("male", 10), rep ("female", 10)),3)),
   group = factor (c(rep("control",20), rep("run",20), rep("party",20))),
   anxiety = round(c(rnorm(20, mean=55, sd=5),rnorm(20, mean=20, sd=5),rnorm(20, mean=75, sd=5))),
   BAC = round(c(rep(0.01,20), rep(0.01,20), rnorm(20, mean= 0.09, sd=0.01)),2))

I apply the manova () function and summarize as follows:

mod = manova(cbind(anxiety,BAC) ~ gender + Error(group),data=treat4)
summary (mod)

This is what I get:

Error: group
          Df Pillai approx F num Df den Df Pr(>F)
Residuals  2                                     

Error: Within
          Df   Pillai approx F num Df den Df Pr(>F)
gender     1 0.013447  0.37482      2     55 0.6892
Residuals 56 

There are a couple of issues:

1) Gender seems to be accounted as within-subjects factor

2) I don't get any statistics for the group factor

Any help?

if anxiety and BAC are your dependent variables, you place them on the left side of tilda (~) with cbind, to indicate multivariate response, and use Error() to specify the within group effect (or random effect). The rest on the right side of tilda (~) are your between group effect (or fixed effect):

manova(cbind(anxiety,BAC) ~ gender + Error(group),data=treat4)

Call:
manova(cbind(anxiety, BAC) ~ gender + Error(group), data = treat4)

Grand Means:
    anxiety         BAC 
49.96666667  0.03766667 

Stratum 1: group

Terms:
                 Residuals
anxiety           33156.63
BAC             0.09185333
Deg. of Freedom          2

Residual standard errors: 128.7568 0.2143051

Stratum 2: Within

Terms:
                   gender Residuals
anxiety            8.0667 1527.2333
BAC                0.0000    0.0034
Deg. of Freedom         1        56

Residual standard errors: 5.222262 0.007807201
Estimated effects are balanced

Thanks @StupidWolf for your answer.

However, when I apply summary () to the model:

summary(manova(cbind(anxiety,BAC) ~ gender + Error(group),data=treat4))

I get the following:

Error: group
          Df Pillai approx F num Df den Df Pr(>F)
Residuals  2                                     

Error: Within
          Df   Pillai approx F num Df den Df Pr(>F)
gender     1 0.039097   1.1189      2     55  0.334
Residuals 56  

There are a couple of issues:

1) Gender seems to be accounted as within-subjects factor

2) I don't get any statistics for the group factor

I know this comes a bit late but I faced the same issue and I think you can simply solve it this way:

summary(manova(cbind(anxiety,BAC) ~ gender + group + Error(factor(participant)),data=treat4))

Basically, you need to add group as an IV (by doing "+ group"). Then you use the "Error()" to indicate how it needs to identify unique subjects, it needs to do this by the participant number, rather than by the group. Don't forget to make the partcipant into a factor, otherwise it causes problems!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM