MANOVA Analysis of Time Series Data: Difference between revisions
(Created page with "Analyses of multiple (rather than repeated) measures for an individual should be carried out using MANOVA. It turns out it's fairly simple to do in R. =Read in Table= Assume...") |
|||
Line 15: | Line 15: | ||
The first thing to point out is that you need to have sufficient samples for the number of columns. If you are comparing 64 time points for two groups, you will need 128 (? I should know this maybe) samples, or else R will complain. | The first thing to point out is that you need to have sufficient samples for the number of columns. If you are comparing 64 time points for two groups, you will need 128 (? I should know this maybe) samples, or else R will complain. | ||
Assuming you have sufficient data, the MANOVA is easy. The first column is your grouping variable. The rest of the columns, T01 to TNN are your time points. Rather than type them all out when calling the manova function, you can just refer to them by index: | Assuming you have sufficient data, the MANOVA is easy. The first column is your grouping variable. The rest of the columns, T01 to TNN are your time points. Rather than type them all out when calling the manova function, you can just refer to them by index: | ||
fit=manova(as.matrix(dat[,2:65]) ~ X, data=dat) | > fit=manova(as.matrix(dat[,2:65]) ~ X, data=dat) | ||
Here, I am running the MANOVA on all 64 time points. Since column 1 is my grouping variable, X, the 64 variables are in columns 2 to 65. | Here, I am running the MANOVA on all 64 time points. Since column 1 is my grouping variable, X, the 64 variables are in columns 2 to 65. | ||
It's trivially easy to analyze a smaller window: | It's trivially easy to analyze a smaller window: | ||
fit=manova(as.matrix(dat[,24:26]) ~ X, data=dat) | > fit=manova(as.matrix(dat[,24:26]) ~ X, data=dat) | ||
=Get the MANOVA Results= | =Get the MANOVA Results= |
Revision as of 13:37, 28 September 2018
Analyses of multiple (rather than repeated) measures for an individual should be carried out using MANOVA. It turns out it's fairly simple to do in R.
Read in Table
Assume you have your data structured as follows:
X T01 T02 T03 ... TNN a .33 .38 .43 .78 a .32 .39 .47 .80 b .36 .41 .44 .77 b .31 .35 .40 .81
Read the data into a data frame:
dat=read.table('training_accuracy.txt', header=TRUE, sep='\t')
Run the MANOVA
The first thing to point out is that you need to have sufficient samples for the number of columns. If you are comparing 64 time points for two groups, you will need 128 (? I should know this maybe) samples, or else R will complain. Assuming you have sufficient data, the MANOVA is easy. The first column is your grouping variable. The rest of the columns, T01 to TNN are your time points. Rather than type them all out when calling the manova function, you can just refer to them by index:
> fit=manova(as.matrix(dat[,2:65]) ~ X, data=dat)
Here, I am running the MANOVA on all 64 time points. Since column 1 is my grouping variable, X, the 64 variables are in columns 2 to 65. It's trivially easy to analyze a smaller window:
> fit=manova(as.matrix(dat[,24:26]) ~ X, data=dat)
Get the MANOVA Results
> summary(fit) Df Pillai approx F num Df den Df Pr(>F) X 1 0.56045 1.2551 64 63 0.1841