R-help to extra exercise on multivariate methods
# Read the data into a data frame, give names to the variables, and take a look at the data:
salsinol<-read.table("http://www.math.uio.no/avdc/kurs/STK4900/data/salsinol.dat")
names(salsinol)<-c("patient","group","day1","day2","day3","day4")
salsinol
# Check that the data correspond to those given op page 105 i BS
# (where you also find a description of the data)
# Attach the data frame:
attach(salsinol)
# Put the data together as multivariate responses:
resp<-cbind(salsinol$day1,salsinol$day2,salsinol$day3,salsinol$day4)
# QUESTION a)
# Perform multivariate analysis of variance by means of "aov" and display the results:
mod1<-aov(resp~factor(group))
mod1
summary(mod1)
# Study the results. What do they tell you?
# QUESTION b)
# # Perform multivariate analysis of variance by means of "manova" and display the results:
mod2<-manova(resp~factor(group))
mod2
summary(mod2, test="Wilks")
# Comment of differences between the two analyses.
# QUESTION c)
# Fit a linear model to the response at day 1 and look at the results:
mod3<-lm(day1~factor(group))
summary(mod3)
# Use the output to answer the questions in the exercise.
# Can you explain the result?
# QUESTION d)
# We now consider the measurement on day 1 as a covariate, and the measurements for the last three days as a multivariate response:
# Perform the commands:
resp2<-cbind(salsinol$day2,salsinol$day3,salsinol$day4)
mod4<-aov(resp2~factor(group)+day1)
mod5<-manova(resp2~factor(group)+day1)
# Inspect the results (using similar commands as above).
# What are the conclusions of the model fits? (cf. question e in the exercise)