R Code for Canonical Correlation Analysis
-
Upload
jose-luis-jurado-zurita -
Category
Documents
-
view
218 -
download
0
Transcript of R Code for Canonical Correlation Analysis
-
8/14/2019 R Code for Canonical Correlation Analysis
1/10
##############################################
# R Code for canonical correlation analysis #
##############################################
# We will use the built-in iris data set.
# We will consider the entire data set (all three species)
attach(iris)
# We will standardize the variables first
# by dividing by each column's standard deviation:
# (we will remove column 5, the species labels)
iris.std
-
8/14/2019 R Code for Canonical Correlation Analysis
2/10
# u1 = 0.92*Sepal.Length - 0.39*Sepal.Width
# v1 = 0.94*Petal.Length - 0.33*Petal.Width
# Plotting the first set of canonical variables:
u1
-
8/14/2019 R Code for Canonical Correlation Analysis
3/10
colnames(xrels)
-
8/14/2019 R Code for Canonical Correlation Analysis
4/10
.098,.308,-.27,-.183),
ncol=4, byrow=T)
R21
-
8/14/2019 R Code for Canonical Correlation Analysis
5/10
P.value
-
8/14/2019 R Code for Canonical Correlation Analysis
6/10
#### Testing about x2 in the model:
## Full model:
my.n
-
8/14/2019 R Code for Canonical Correlation Analysis
7/10
pt.est
# A point prediction for this site is:
# predicted CPU time = 151.8 hours, predicted disk input/output capacity
= 349.6.
middle.mat
-
8/14/2019 R Code for Canonical Correlation Analysis
8/10
my.ys
-
8/14/2019 R Code for Canonical Correlation Analysis
9/10
# Recall the variables:
# X1 = Sales growth
# X2 = Sales profitability
# X3 = New account sales
# X4 = Creativity Test
# X5 = Mechanical Reasoning Test
# X6 = Abstract Reasoning Test# X7 = Mathematics Test
# X8 = Historical Facts Test
# X9 = Sports Trivia Test
# X10 = Music Trivia Test
# We will try to predict the "performance" variables (x1, x2, x3) using
the
# "test score" variables (x4, x5, ..., x10).
# Fitting the multivariate linear regression model:
sales.mod.1
-
8/14/2019 R Code for Canonical Correlation Analysis
10/10
X.mat.redu