[R] variance of repeated measurements
Jeff Newmiller
jdnewmil at dcn.davis.CA.us
Mon Nov 16 18:54:48 CET 2015
I think your imprecise use of statistical methods is getting you into trouble. A literal interpretation of your question would lead to var(my.data$fluo), but whether that number would be meaningful would depend on what you did with it (I doubt much good would come from using it directly). Unfortunately such concerns are off-topic here (consider discussing at stats.stackexchange.com).
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
On November 16, 2015 9:10:29 AM PST, Luigi Marongiu <marongiu.luigi at gmail.com> wrote:
>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 at 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.
More information about the R-help
mailing list