Dear all, how can I calculate the global variance of repeated measurements? can I simply use the var() function or shall i use more sophisticated tools such as aov()? and in the latter case, how can i extract the variance value? I am providing an example. Thank you. best regards luigi
>>> samp <- c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5) clock <- rep(1:5,5) targ <- c(rep("A", 5), rep("B", 5), rep("A", 5), rep("A", 5), rep("B", 5)) fluo <- c(-0.012, -0.01, -0.008, -0.002, -0.001, -0.007, -0.008, -0.009, -0.009, -0.012, -0.002, -0.003, -0.003, 0.001, 0.002, -0.006, -0.001, 0.001, 0.002, 0.002, -0.002, -0.003, -0.003, -0.002, -0.001) my.data <- data.frame(samp, clock, targ, fluo, stringsAsFactors = FALSE) # variance individual measurement sub <- subset(my.data, samp == 1) plot(sub$flu ~ sub$clock) abline(lm(sub$flu ~ sub$clock)) for (i in 2:nrow(sub)) { X <- subset(sub, clock <= i) V <- var(X$fluo) cat("variance at clock ", i, " = ", V, "\n", sep="") } # variance multiple measurements sub <- subset(my.data, targ == 'A') plot(sub$flu ~ sub$clock) abline(lm(sub$flu ~ sub$clock)) for (i in 2:max(sub$clock)) { X <- subset(sub, clock <= i) V <- var(X$fluo) cat("variance at clock ", i, " = ", V, "\n", sep="") } ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.