Data Analysis – Linear Regression

Read in data and set up factors:

Measure <- factor(LETTERS[1:6])
Measure
# [1] A B C D E F
# Levels: A B C D E F
pat_dat <-scan("tmp.patient_t1")
# Read 42 items
# pat_dat
# [1]  2.97 -6.54  1.17  0.20  0.66 -0.59  1.62 -8.20 -1.11  0.14  1.98  2.14 1.41 -7.68  0.79 -0.16 -0.70 -1.24  
# [19] 1.11 -3.52  3.21 -0.02 -0.28  1.04 1.67 -6.24  1.36  0.35  0.74  1.09  0.07 -0.73  1.32 -0.41 -0.57  0.62
# [37]  1.96 -1.07  2.78  0.97  0.57  0.05
Patient<-factor(c(rep(1,6), rep(2,6), rep(3,6), rep(4,6), rep(5,6), rep(6,6), rep(7,6)))
# Patient
# [1] 1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 3 4 4 4 4 4 4 5 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7
# Levels: 1 2 3 4 5 6 7

Make a data frame:

pat.df <-data.frame(Measure,Patient,pat_dat)
pat.df
   Measure Patient pat_dat
1        A       1    2.97
2        B       1   -6.54
3        C       1    1.17
4        D       1    0.20
5        E       1    0.66
6        F       1   -0.59
7        A       2    1.62
8        B       2   -8.20
9        C       2   -1.11
10       D       2    0.14
11       E       2    1.98
12       F       2    2.14
13       A       3    1.41
14       B       3   -7.68
15       C       3    0.79
16       D       3   -0.16
...

Transcript

Now, before you begin an ANOVA, you have to set up your -- read in your data and set up factors - which are the basis of your data. So, in this case, we have the 6 measurements, and we have 7 patients.