0

I perform repeated measure Anova, I have any variables(4 or more) and when I do it, I must conduct Anova for each variables separately. it's inconvenient for me, for example here code rep.anova for 2 variables - tember_body and SAD (i have 8 measures)

library("car")
tabl20=read.csv("path to dataset",sep=";",dec=",")
ageLevels <- c(1, 2, 3,4,5,6,7,8)
ageFactor <- as.factor(ageLevels)
ageFrame <- data.frame(ageFactor)
ageBind <- cbind(tabl20$temper_body_v0,
                 tabl20$temper_body_v1,
                 tabl20$temper_body_v2,
                 tabl20$temper_body_v3,
                 tabl20$temper_body_v4,
                 tabl20$temper_body_v5,
                 tabl20$temper_body_v6,
                 tabl20$temper_body_v7)
ageModel <- lm(ageBind ~ 1)
analysis <- Anova(ageModel, idata = ageFrame, idesign = ~ageFactor)
summary(analysis)
######
tabl20=read.csv("path to data",sep=";",dec=",")
ageLevels <- c(1, 2, 3,4,5,6,7,8)
ageFactor <- as.factor(ageLevels)
ageFrame <- data.frame(ageFactor)
ageBind <- cbind(tabl20$SAD_v0,
                 tabl20$SAD_v1,
                 tabl20$SAD_v2,
                 tabl20$SAD_v3,
                 tabl20$SAD_v4,
                 tabl20$SAD_v5,
                 tabl20$SAD_v6,
                 tabl20$SAD_v7)

ageModel <- lm(ageBind ~ 1)
analysis <- Anova(ageModel, idata = ageFrame, idesign = ~ageFactor)
summary(analysis)

How to perform rep.measure anova for all variables, for all at once, and not doing for each var analysis separately.

Andrew Brēza
  • 7,705
  • 3
  • 34
  • 40
psysky
  • 3,037
  • 5
  • 28
  • 64
  • 1
    It appears that it would be matter of constructing a dynamic formula to run *ANOVA* on whatever combination of variables you want. I would suggest that you post some sample data or reproduce your example using `mtcars` data so it will be easier to contribute potential solutions. – Konrad Jan 22 '16 at 12:04
  • Thank you, how i can attach my dataset, it's small? – psysky Jan 22 '16 at 12:10
  • Have a look at [this discussion](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example), it's full of examples on how to produce a reproducible question. – Konrad Jan 22 '16 at 12:12

1 Answers1

0

i found answer ,perhaps it is useful to someone

library(car) 
tabl20=read.csv("c:/path/,sep=";",dec=",") 
ageLevels <- c(1, 2, 3,4,5,6,7,8) 
ageFactor <- as.factor(ageLevels) 
ageFrame <- data.frame(ageFactor) 

tabl20 <- tabl20[, order(names(tabl20))] 

measures <- function(data = tabl20, n = 4) { 
  list <- list(n) 
  for(i in 0:3) {list[[i+1]] <- as.matrix(cbind(data[, 8*i + 1:8])) 
  } 
  list 
} 

measures_list <- measures() 

models <- lapply( 
  measures_list, function(x) { 
    ageModel <- lm(x ~ 1) 
    Anova(ageModel, idata = ageFrame, idesign = ~ageFactor) 
  } )

but i don't know how perform plots for all variables

if i do so plot(models)

i get this error

Error in xy.coords(x, y, xlabel, ylabel, log) : 
  'x' is a list, but does not have components 'x' and 'y'

maybe anyone promt me , how create plot for all vars

psysky
  • 3,037
  • 5
  • 28
  • 64