Q1: 8.1

covmt <- matrix(c(5,2,2,2), nrow = 2)
eig <- eigen(covmt)
eigval <- eig$values
eigvec <- eig$vectors
percent <- eigval[1]/sum(eigval)

Q2: 8.2

cormt <- diag(1/sqrt(diag(covmt)))%*%covmt%*%diag(1/sqrt(diag(covmt)))

\(\rho = diag(\Sigma)^{\frac{-1}{2}} ~ \Sigma ~ diag(\Sigma)^{\frac{-1}{2}} = \begin{pmatrix} 1.00 & 0.63 \\ 0.63 & 1.00 \\ \end{pmatrix}\)

(a)

eig <- eigen(cormt)
eigval <- eig$values
eigvec <- eig$vectors
percent <- eigval[1]/sum(eigval)
  • First Principle Component: \(\lambda_1 = 1.63\), \(Y_1 = -0.71Z_1 -0.71Z_2\)

  • Second Principle Component: \(\lambda_2 = 0.37\), \(Y_2 = 0.71Z_1 -0.71Z_2\)

  • Proprotion of variance explained by the first PC: \(\frac{\lambda_1}{\Sigma \lambda_i} = 81.62\)%

(b)

Principle components from 8.1 & 8.2 are different since they came from two different matrix (covariance matrix vs. correlation matrix). Mathmetically, the difference resulted from two different matrices have different eigenvalues and eigenvectors, hence different principle component. This difference reflects the fact that scaling has an effect on the principle component.

(c)

e_11 <- round(eigvec[1,1],3)
sqrt_eigen_1 <- round(sqrt(eigval[1]), 3)
v11 <- eigvec[1,1]*sqrt(eigval[1])

e_12 <- round(eigvec[2,1],2)
v12 <- eigvec[2,1]*sqrt(eigval[1])

e_21 <- round(eigvec[1,2],2)
sqrt_eigen_2 <- round(sqrt(eigval[2]), 2)
v21 <- eigvec[1,2]*sqrt(eigval[2])

\(\rho_{Y_i,~Z_k} = \frac{e_{ik} \sqrt{\lambda_i}} {\sqrt{\sigma_{kk}}}\)

\(\rho_{Y_1,~Z_1} = \frac{(-0.71)(1.28) }{\sqrt{1}} = -0.9\)

\(\rho_{Y_1,~Z_2} = -0.9\)

\(\rho_{Y_2,~Z_1} = 0.43\)


Q3: PCA with Covariance Matrix vs. Correlation Matrix

air<- read_table2("data/T1-5.dat", col_names = FALSE)
colnames(air) <- c("wind", "radiation", "CO", "NO", "NO2", "O3", "HC")
PCA_cov <- prcomp(air, scale=F)
PCA_cor <- prcomp(air, scale =T)
library(factoextra)
library(cowplot)

p_cov <- fviz_eig(PCA_cov, choice = "eigenvalue", main="PCA with S", geom = "line")
p_cor <- fviz_eig(PCA_cor, choice = "eigenvalue", main="PCA with R", geom = "line")

plot_grid(p_cov, p_cor, nrow = 1)

Principle Components: Covariance Matrix

kable(PCA_cov[["rotation"]], format = "markdown", align = ifelse(knitr::is_html_output(), "c", "l"), digits = 2)
PC1 PC2 PC3 PC4 PC5 PC6 PC7
wind -0.01 0.08 -0.03 0.92 0.34 -0.01 -0.17
radiation 0.99 0.12 -0.01 0.00 0.00 0.00 0.00
CO 0.01 -0.10 0.18 -0.14 0.65 0.56 0.44
NO 0.00 0.01 0.13 -0.33 0.64 -0.50 -0.46
NO2 0.02 -0.15 0.96 0.10 -0.21 0.01 -0.11
O3 0.11 -0.97 -0.17 0.06 0.00 -0.05 -0.07
HC 0.00 -0.02 0.09 0.11 0.06 -0.66 0.74

Principle Components: Correlation Matrix

kable(PCA_cor[["rotation"]], format = "markdown", align = ifelse(knitr::is_html_output(), "c", "l"), digits=2)
PC1 PC2 PC3 PC4 PC5 PC6 PC7
wind -0.24 0.28 -0.64 0.17 -0.56 0.22 0.24
radiation 0.21 -0.53 -0.22 0.78 0.16 0.01 0.01
CO 0.55 -0.01 0.11 0.01 -0.57 0.11 -0.59
NO 0.38 0.43 0.41 0.29 0.06 0.45 0.46
NO2 0.50 0.20 -0.20 -0.04 -0.05 -0.74 0.34
O3 0.32 -0.57 -0.16 -0.51 -0.08 0.33 0.42
HC 0.32 0.31 -0.54 -0.14 0.57 0.27 -0.31

Interpretation

PCA with \(\mathbf{S}\)

The scree plot of PCA using \(\mathbf{S}\) indicates that only one principle component is important, which explains 87.29% of the total variance.

The first principle component obtained by covariance matrix explains nearly all the variation in the data, this is probably due to the large scale of the variable radiation compared to orther variables. A better explanation of PCA should rely on the correlation matrix in this case.

PCA with \(\mathbf{R}\)

According to the unity criterion and the scree plot (a not-so-obvious elbow at the forth PC), three principle components can well summarize the data, which explains 70.38% of the total variance.

The interpretation of the first principle component obtained by the correlation matricies is straightforward: the variable wind constrasts with other variables consist of pollutants, probably because strong wind blows away pollutants, i.e. wind and polutants have opposite effect on air polution.

Interpretation of the remaining two principle components requires extensive knowledge on air pollution.


Q4

sweet <- read_table2("data/T5-1.txt", col_names = FALSE)
colnames(sweet) <- c("sweet_rate", "sodium", "potassium")
source("multivariate_fc.R")
PCA <- prcomp(sweet, scale=F)
PCA_cor <- prcomp(sweet, scale=T)

p_cov <- scree_plot(PCA, "variance", addlabels=TRUE, main="Covariance matrix", sub_axis_name="", axis_limits = c(0,100))
p_cor <- scree_plot(PCA_cor, "variance", addlabels=TRUE, main="Correlation matrix",ylab = "", axis_limits = c(0,100))
cowplot::plot_grid(p_cov, p_cor, nrow = 1)

library(mat2tex)
kable(PCA[["rotation"]], format="markdown", align="c", digits = 2)
PC1 PC2 PC3
sweet_rate 0.05 -0.57 -0.82
sodium 1.00 0.05 0.02
potassium -0.03 0.82 -0.58
quantiles <- qnorm(p=seq(0.25,9.75, 0.5)/10) 
PC1 <- as.data.frame(PCA[["x"]][,1])
    PC1 <- cbind(rownames(PC1), PC1)
    colnames(PC1) <- c("ID", "PC1")
    PC1 <- PC1 %>% 
        arrange(PC1) %>% mutate(quantile=quantiles)
    
PC2 <- as.data.frame(PCA[["x"]][,2])
    PC2 <- cbind(rownames(PC2), PC2)
    colnames(PC2) <- c("ID", "PC2")
    PC2 <- PC2 %>% 
        arrange(PC2) %>% mutate(quantile=quantiles)
    
PC3 <- as.data.frame(PCA[["x"]][,3])
    PC3 <- cbind(rownames(PC3), PC3)
    colnames(PC3) <- c("ID", "PC3")
    PC3 <- PC3 %>% 
        arrange(PC3) %>% mutate(quantile=quantiles)
library(ggplot2)
library(scales)
library(cowplot)
library(latex2exp)

size <- 2.3 # dot label text-size
p1 <- ggplot(PC1, aes(x=quantiles, y=PC1))+
        geom_point(color=hue_pal()(3)[1])+
        geom_text(aes(label=ID),
                  hjust=-0.1, vjust=0, size = size)+
        scale_x_continuous(breaks = seq(-2,2, 0.5))+
        scale_y_continuous(breaks = seq(-35,35, 5))+
        labs(x=TeX("$q_{(j)}$"),
             y="PC1",
             title="PC1 Q-Q Plot")+ theme


p2 <- ggplot(PC2, aes(x=quantiles, y=PC2))+
        geom_point(color=hue_pal()(3)[2])+
        geom_text(aes(label=ID),
                  hjust=-0.1, vjust=0, size = size)+
        scale_x_continuous(breaks = seq(-2,2, 0.5))+
        scale_y_continuous(breaks = seq(-4.5,3.5, 0.5))+
        labs(x=TeX("$q_{(j)}$"),
             y="PC2",
             title="PC2 Q-Q Plot")+ theme

p3 <- ggplot(PC3, aes(x=quantiles, y=PC3))+
        geom_point(color=hue_pal()(3)[3])+
        geom_text(aes(label=ID),
                  hjust=-0.1, vjust=0, size = size)+
        scale_x_continuous(breaks = seq(-2,2, 0.5))+
        scale_y_continuous(breaks = seq(-2,2, 0.5))+
        labs(x=TeX("$q_{(j)}$"),
             y="PC3",
             title="PC3 Q-Q Plot")+ theme

plot_grid(p1, p2, p3, nrow = 1)

Suspect Observations?

From the three Q-Q plots above, there seems no obvious deviation from the straight lines, and threr are no unique points that deviate from the main data in all three Q-Q plots. For detecting suspect observations, more techniques are needed.


Q5

fp <- read_table2("data/FOODP.txt", col_names = FALSE, 
    skip = 5)[1:24, -1]
colnames(fp) <- c("city", paste("food",1:5,sep=""))

(a) Scree Plot, PCs, Interpretation

library(factoextra) # For Visualizing MvA
PCA <- prcomp(fp[,-1], scale=T)
# fviz_eig(PCA)

eigva <- as_data_frame(PCA[["sdev"]]^2)
scree <- cbind(1:5 , eigva)
scree <- cbind(scree, "a")
colnames(scree) <- c("PC", "var", "a")

ggplot(scree, aes(x = PC, y = var, group = a)) +
    geom_point() + geom_line() +
    scale_y_continuous(
        sec.axis = sec_axis(~ . / sum(eigva) * 100,
                            name = "Variance Accounted (%)")
                   )+
    labs(x="Principle Components",
         y=latex2exp::TeX("$\\hat{\\lambda_i}$"),
         title="Scree Plot")    

pc <- PCA[["rotation"]]
kable(round(pc,3),"markdown", align = ifelse(knitr::is_html_output(), "c", "l"))
PC1 PC2 PC3 PC4 PC5
food1 -0.51 0.06 -0.40 -0.53 -0.54
food2 -0.52 -0.28 -0.41 0.07 0.69
food3 -0.40 0.10 0.77 -0.43 0.24
food4 -0.29 0.88 -0.07 0.37 0.05
food5 -0.48 -0.38 0.28 0.62 -0.41

Interpretation

By either the “elbow” of the scree plot or the unity criterion, the first principle component is sufficient, which explains 48.79% of the total variance.

The data can be greatly reduced to 1 variable by the first principle component, and the “weight” of the first principle component on each variable have the same sign, indicating the price of each food has similar effect on the variation of the data.

(b) The First Two principal component scores

# PCA[["x"]] returns the "rotated" score(pc score) of the original data
pc_score12 <- as.data.frame(PCA[["x"]][,1:2])
pc_score12 <- cbind(fp$city, pc_score12) %>% rename(city=`fp$city`)

kable(pc_score12, align="c",digits = 2, format ="markdown")
city PC1 PC2
Anchorage -4.58 0.53
Atlanta -0.32 -0.08
Baltimore -0.36 -1.10
Boston -0.57 -1.62
Buffalo 2.64 -1.17
Chicago -0.51 1.29
Cincinnati -0.27 -0.79
Cleveland 0.74 0.27
Dallas -0.38 0.92
Detroit 0.20 -1.53
Honolulu -2.80 0.91
Houston 0.46 1.34
Kansas_City 0.42 -0.39
Los_Angeles 1.55 1.17
Milwaukee 1.28 0.54
Minneapolis 0.73 -0.60
New_York -1.29 -0.92
Philadelphia -2.10 -0.80
Pittsburgh 0.32 -1.08
St_Louis 1.25 0.02
San_Diego 2.12 0.68
San_Francisco 0.71 1.32
Seattle 1.00 0.34
Washington -0.25 0.74

(c) Scatter Plot: PC1 vs. PC2

ggplot(pc_score12, aes(x=PC1, y=PC2))+
    geom_point()+
    geom_text(aes(label=city),
              hjust=-0.1, vjust=0, size = 3)+
    scale_x_continuous(limits = c(-4.6, 2.9), breaks = seq(-4.5,3, 0.5))+
    scale_y_continuous(limits = c(-1.7, 1.5), breaks = seq(-1.75,1.5, 0.25))+
    geom_segment(x=3,y=1.1,
                 xend=-4.6, yend=-0.5)+
    labs(title="Scatter Plot of PC1 & PC2",
         x="Principle Component 1",
         y="Principle Component 2")

Two clusters seems to be identified on the scatter plot, ignoring Buffalo.

(d) Food Price in Different Cities

## Max PC score: cheapest food price
cheap <- pc_score12$city[pc_score12$PC1 == max(pc_score12$PC1)]

## min PC score
expense <- pc_score12$city[pc_score12$PC1 == min(pc_score12$PC1)]

Using principle component 1 as indicator, since it has the same sign on all “weighted” food price, and it’s the most important principle component in explaining the variability of the data, the x-axis of the scatter above showed that Buffalo has the cheapest food price, and Anchorage has the most expensive food price.


Q6

var_content <- read_delim("data/var_masst.txt", 
    ";", escape_double = FALSE, col_names = FALSE, 
    trim_ws = TRUE)
colnames(var_content) <- NULL

response <- read.table("C:/Users/user/local_depend/1062_class/Multivariate_Analysis/HW2/data/masst.txt", quote="\"", comment.char="", na.strings=".", stringsAsFactors=FALSE) %>%
    drop_na()
PCA <- prcomp(response, scale = TRUE)

std_pc <- PCA[["sdev"]] 
# std(sqrt(eigenvalue) of corr matrix) of PCs

(a)

Weight of the First 5 Pricinple Components on each Variable

# First 5 PCs
pc5 <- as.data.frame(PCA[["rotation"]][,1:5]) 

styled_pc5 <- round(pc5,3) %>%
    mutate(
        PC1 = cell_spec(PC1, "html", color = ifelse(PC1 < 0, "red", "blue")),
        PC2 = cell_spec(PC2, "html", color = ifelse(PC2 < 0, "red", "blue")),
        PC3 = cell_spec(PC3, "html", color = ifelse(PC3 < 0, "red", "blue")),
        PC4 = cell_spec(PC4, "html", color = ifelse(PC4 < 0, "red", "blue")),
        PC5 = cell_spec(PC5, "html", color = ifelse(PC5 < 0, "red", "blue"))
                        )

loadings <- kable(styled_pc5, "markdown", escape = F, align="c", row.names = T) %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"), full_width = F)
loadings %>%
  kableExtra::landscape()
PC1 PC2 PC3 PC4 PC5
1 0.147 -0.092 0.024 -0.429 0.28
2 -0.26 0.126 -0.084 0.214 -0.311
3 -0.315 0.03 -0.059 0.12 -0.123
4 0.055 -0.116 -0.17 -0.375 0.15
5 0.38 -0.071 -0.133 -0.184 0.085
6 -0.122 -0.519 -0.235 0.002 -0.005
7 0.013 -0.218 0.3 -0.216 -0.447
8 -0.072 0.234 -0.393 -0.027 -0.195
9 0.24 0.055 -0.221 -0.324 -0.271
10 0.283 -0.13 -0.106 0.185 -0.128
11 -0.045 0.123 -0.498 0.012 0.073
12 -0.341 0.146 0.063 -0.345 -0.101
13 -0.363 0.134 -0.045 -0.298 0.079
14 0.027 0.225 -0.358 -0.117 -0.335
15 0.271 0.019 -0.007 -0.206 -0.231
16 0.177 -0.045 -0.122 0.127 -0.185
17 -0.209 -0.463 -0.188 0.024 0.016
18 -0.256 0.088 -0.017 -0.259 0.226
19 -0.181 -0.47 -0.222 -0.019 -0.09
20 -0.093 -0.117 0.318 -0.213 -0.413

Percentage of Variance Accounted

\(\hat{\lambda_1}\) = 2.94, \(\hat{\lambda_2}\) = 2.1, \(\hat{\lambda_3}\) = 2.04, \(\hat{\lambda_4}\) = 1.66, \(\hat{\lambda_5}\) = 1.19.

per_5pc <- sum(std_pc[1:5]^2)/sum(std_pc^2)

The percentage of total variance accounted by the first 5 PCs is 49.64%.

(b)

t <- var_content %>% 
kable(format = "html", align="l") %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"), full_width = F)
if (knitr::is_html_output()) {t}
X1 If the energy shortage gets any worse, the country will be in bad shape.
X2 The worst of the energy crisis has passed.
X3 Science and technology will be able to resolve the energy crisis without conservation.
X4 Saving energy requires you to make major sacrifices.
X5 The energy crisis is for real.
X6 Utility companies should be allowed to burn cheaper fuel even though this would cause more pollution.
X7 The petroleum companies have not done all they can to solve the energy problem.
X8 Congress has done all it can to solve the energy problem.
X9 Rationing of energy resources will be necessary for at least the next five years.
X10 Conserving electricity will save me money in the long run.
X11 The natural gas companies have done all they can to solve the energy problem.
X12 My electricity bill would be the same no matter what I did.
X13 There is not much an average citizen can do to save electricity.
X14 President Carter has done all he can to solve the energy problem.
X15 At this point in time our traditional energy resources (coal, oil, natural gas, etc.) are insufficient to continue energy consumption at the present rate.
X16 It would be easy for me to cut down on the use of electricity in my home.
X17 We should forget about reducing pollution until our energy problems are solved.
X18 My personal conservation efforts have little impact on total consumption of energy.
X19 Because of the abundance of coal, industries should be encouraged to switch to coal as a fuel despite the air pollution it causes.
X20 The electric companies have not done all they can to solve the energy problem.
BrBG <- colorRampPalette(c("purple","blue","white", "red", "orange"))
hm <- function(data) {
    heatmaply::heatmaply(round(cor(data),2), margins = c(50, 50),
          k_col = 2, k_row = 2,
          colors = BrBG,
          dendrogram = "none",
          label_names=c("row", "column", "Corr."),
          column_text_angle = 60,
          fontsize_row=5, fontsize_col=5,
          limits = c(-1,1))
}
factoextra::fviz_eig(PCA, choice = "variance", main="First 5 PCs", geom = "line", ncp=8, addlabels=T)+ scale_y_continuous(limits = c(4, 16))

First PC

h <- hm(response[,c(which(pc5$PC1>0), which(pc5$PC1<0))])
if (knitr::is_html_output()) {h}
t <- var_content[which(pc5$PC1>0),] %>% 
kable(format = "html", align="l") %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"), full_width = F)
if (knitr::is_html_output()) {t}
X1 If the energy shortage gets any worse, the country will be in bad shape.
X4 Saving energy requires you to make major sacrifices.
X5 The energy crisis is for real.
X7 The petroleum companies have not done all they can to solve the energy problem.
X9 Rationing of energy resources will be necessary for at least the next five years.
X10 Conserving electricity will save me money in the long run.
X14 President Carter has done all he can to solve the energy problem.
X15 At this point in time our traditional energy resources (coal, oil, natural gas, etc.) are insufficient to continue energy consumption at the present rate.
X16 It would be easy for me to cut down on the use of electricity in my home.

contrasts

t <- var_content[which(pc5$PC1<0),] %>% 
kable(format = "html", align="l") %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"), full_width = F)
if (knitr::is_html_output()) {t}
X2 The worst of the energy crisis has passed.
X3 Science and technology will be able to resolve the energy crisis without conservation.
X6 Utility companies should be allowed to burn cheaper fuel even though this would cause more pollution.
X8 Congress has done all it can to solve the energy problem.
X11 The natural gas companies have done all they can to solve the energy problem.
X12 My electricity bill would be the same no matter what I did.
X13 There is not much an average citizen can do to save electricity.
X17 We should forget about reducing pollution until our energy problems are solved.
X18 My personal conservation efforts have little impact on total consumption of energy.
X19 Because of the abundance of coal, industries should be encouraged to switch to coal as a fuel despite the air pollution it causes.
X20 The electric companies have not done all they can to solve the energy problem.

The first PC group variables as:

  • The variables 1, 4, 5, 7, 9, 10, 14, 15, 16 seem to reflect the trade-offs between cutting down energy usage and solving energy crysis.

  • The variables 2, 3, 6, 8, 11, 12, 13, 17, 18, 19, 20 seem to reflect 2 attitudes:
    1. Little can be done to change the energy crysis.
    2. Favor solving energy crysis at the cost of pollution.

Second PC

h <- hm(response[,c(which(pc5$PC2>0), which(pc5$PC2<0))])
if (knitr::is_html_output()) {h}
t <- var_content[which(pc5$PC2>0),] %>% 
kable(format = "html", align="l") %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"), full_width = F)
if (knitr::is_html_output()) {t}
X2 The worst of the energy crisis has passed.
X3 Science and technology will be able to resolve the energy crisis without conservation.
X8 Congress has done all it can to solve the energy problem.
X9 Rationing of energy resources will be necessary for at least the next five years.
X11 The natural gas companies have done all they can to solve the energy problem.
X12 My electricity bill would be the same no matter what I did.
X13 There is not much an average citizen can do to save electricity.
X14 President Carter has done all he can to solve the energy problem.
X15 At this point in time our traditional energy resources (coal, oil, natural gas, etc.) are insufficient to continue energy consumption at the present rate.
X18 My personal conservation efforts have little impact on total consumption of energy.

contrasts

t <- var_content[which(pc5$PC2<0),] %>% 
kable(format = "html", align="l") %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"), full_width = F)
if (knitr::is_html_output()) {t}
X1 If the energy shortage gets any worse, the country will be in bad shape.
X4 Saving energy requires you to make major sacrifices.
X5 The energy crisis is for real.
X6 Utility companies should be allowed to burn cheaper fuel even though this would cause more pollution.
X7 The petroleum companies have not done all they can to solve the energy problem.
X10 Conserving electricity will save me money in the long run.
X16 It would be easy for me to cut down on the use of electricity in my home.
X17 We should forget about reducing pollution until our energy problems are solved.
X19 Because of the abundance of coal, industries should be encouraged to switch to coal as a fuel despite the air pollution it causes.
X20 The electric companies have not done all they can to solve the energy problem.

The second PC group variables as:

  • The variables 2, 3, 8, 9, 11, 12, 13, 14, 15, 18 mostly reflect the attitude that little can be done to solve the energy crysis.

  • The variables 1, 4, 5, 6, 7, 10, 16, 17, 19, 20 seem to reflect that the energy crysis is changable despite some sacrifices such as pollution.

Third, Forth, and Fifth PC

The third, forth, and fifth PC are not obvious and easy to interpret, and in fact, they account for only 10%, 8%, and 6% of total variance, respectively.

Third PC

h <- hm(response[,c(which(pc5$PC3>0), which(pc5$PC3<0))])
if (knitr::is_html_output()) {h}
t <- var_content[which(pc5$PC3>0),] %>% 
kable(format = "html", align="l") %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"), full_width = F)
if (knitr::is_html_output()) {t}
X1 If the energy shortage gets any worse, the country will be in bad shape.
X7 The petroleum companies have not done all they can to solve the energy problem.
X12 My electricity bill would be the same no matter what I did.
X20 The electric companies have not done all they can to solve the energy problem.

contrasts

t <- var_content[which(pc5$PC3<0),] %>% 
kable(format = "html", align="l") %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"), full_width = F)
if (knitr::is_html_output()) {t}
X2 The worst of the energy crisis has passed.
X3 Science and technology will be able to resolve the energy crisis without conservation.
X4 Saving energy requires you to make major sacrifices.
X5 The energy crisis is for real.
X6 Utility companies should be allowed to burn cheaper fuel even though this would cause more pollution.
X8 Congress has done all it can to solve the energy problem.
X9 Rationing of energy resources will be necessary for at least the next five years.
X10 Conserving electricity will save me money in the long run.
X11 The natural gas companies have done all they can to solve the energy problem.
X13 There is not much an average citizen can do to save electricity.
X14 President Carter has done all he can to solve the energy problem.
X15 At this point in time our traditional energy resources (coal, oil, natural gas, etc.) are insufficient to continue energy consumption at the present rate.
X16 It would be easy for me to cut down on the use of electricity in my home.
X17 We should forget about reducing pollution until our energy problems are solved.
X18 My personal conservation efforts have little impact on total consumption of energy.
X19 Because of the abundance of coal, industries should be encouraged to switch to coal as a fuel despite the air pollution it causes.

Forth PC

h <- hm(response[,c(which(pc5$PC4>0), which(pc5$PC4<0))])
if (knitr::is_html_output()) {h}
t <- var_content[which(pc5$PC4>0),] %>% 
kable(format = "html", align="l") %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"), full_width = F)
if (knitr::is_html_output()) {t}
X2 The worst of the energy crisis has passed.
X3 Science and technology will be able to resolve the energy crisis without conservation.
X6 Utility companies should be allowed to burn cheaper fuel even though this would cause more pollution.
X10 Conserving electricity will save me money in the long run.
X11 The natural gas companies have done all they can to solve the energy problem.
X16 It would be easy for me to cut down on the use of electricity in my home.
X17 We should forget about reducing pollution until our energy problems are solved.

contrasts

t <- var_content[which(pc5$PC4<0),] %>% 
kable(format = "html", align="l") %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"), full_width = F)
if (knitr::is_html_output()) {t}
X1 If the energy shortage gets any worse, the country will be in bad shape.
X4 Saving energy requires you to make major sacrifices.
X5 The energy crisis is for real.
X7 The petroleum companies have not done all they can to solve the energy problem.
X8 Congress has done all it can to solve the energy problem.
X9 Rationing of energy resources will be necessary for at least the next five years.
X12 My electricity bill would be the same no matter what I did.
X13 There is not much an average citizen can do to save electricity.
X14 President Carter has done all he can to solve the energy problem.
X15 At this point in time our traditional energy resources (coal, oil, natural gas, etc.) are insufficient to continue energy consumption at the present rate.
X18 My personal conservation efforts have little impact on total consumption of energy.
X19 Because of the abundance of coal, industries should be encouraged to switch to coal as a fuel despite the air pollution it causes.
X20 The electric companies have not done all they can to solve the energy problem.

Fifth PC

h <- hm(response[,c(which(pc5$PC5>0), which(pc5$PC5<0))])
if (knitr::is_html_output()) {h}
t <- var_content[which(pc5$PC5>0),] %>% 
kable(format = "html", align="l") %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"), full_width = F)
if (knitr::is_html_output()) {t}
X1 If the energy shortage gets any worse, the country will be in bad shape.
X4 Saving energy requires you to make major sacrifices.
X5 The energy crisis is for real.
X11 The natural gas companies have done all they can to solve the energy problem.
X13 There is not much an average citizen can do to save electricity.
X17 We should forget about reducing pollution until our energy problems are solved.
X18 My personal conservation efforts have little impact on total consumption of energy.

contrasts

t <- var_content[which(pc5$PC5<0),] %>% 
kable(format = "html", align="l") %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"), full_width = F)
if (knitr::is_html_output()) {t}
X2 The worst of the energy crisis has passed.
X3 Science and technology will be able to resolve the energy crisis without conservation.
X6 Utility companies should be allowed to burn cheaper fuel even though this would cause more pollution.
X7 The petroleum companies have not done all they can to solve the energy problem.
X8 Congress has done all it can to solve the energy problem.
X9 Rationing of energy resources will be necessary for at least the next five years.
X10 Conserving electricity will save me money in the long run.
X12 My electricity bill would be the same no matter what I did.
X14 President Carter has done all he can to solve the energy problem.
X15 At this point in time our traditional energy resources (coal, oil, natural gas, etc.) are insufficient to continue energy consumption at the present rate.
X16 It would be easy for me to cut down on the use of electricity in my home.
X19 Because of the abundance of coal, industries should be encouraged to switch to coal as a fuel despite the air pollution it causes.
X20 The electric companies have not done all they can to solve the energy problem.