Math 3772 Exercises 4
This question is to be done in R.
(a)Read in the cork data from the module web site (see Section 3.11 in the Lecture Notes)and represent the data in R as a matrix X (28×4).There are 4 variables, north,east,south and west.Using matrix operations (see Section 4.11),construct a new data matrix Y (28×3)with new variables,
north+south -east -west,
north -south
east -west.
(b)Compute the mean vectors and the variance and correlation matrices of X and Y. Using suitable plots,comment explicitly on each of the following issues:
(i)the difference in mean bark thickness in the four directions
(ii)the randomness of the data,
(iii)the univariate normality of each variable,and
(iv)the bivariate normality of each pair of variables.
Hint:Some useful commands in R:
cork=read.table("cork.txt",
header=TRUE)#so cork is a data frame.
attach(cork)#vectors north,east,south,and west are now defined
stem(north)#stem and leaf plot of a vector
hist(north)#histogram of a vector
boxplot(north,south,east,west)#boxplots of one or more vectors
pairs(cork)#bivariate plot of the data
corkm=as.matrix(cork)#corkm is a 28 by 4 data matrix
matplot(corkm,col=1)#plot of each variable vs 1:n