Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 29 additions & 10 deletions assignment5.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The data you will be using comes from the Assistments online intelligent tutorin

## Start by uploading the data
```{r}
D1 <-
D1<-read.csv("Assistments-confidence.csv" , header = T)

```

Expand All @@ -38,7 +38,7 @@ ggcorr(D1[,-1], method = c("everything", "pearson")) #ggcorr() doesn't have an e
## Create a new data frame with the mean_correct variable removed, we want to keep that variable intact. The other variables will be included in our PCA.

```{r}
D2 <-
D2<-D1[,-5]

```

Expand Down Expand Up @@ -67,35 +67,43 @@ plot(pca, type = "lines")
```

## Decide which components you would drop and remove them from your data set.
```{r}
PCAdata<-data.frame(pca$x)
```

## Part II


```{r}
#Now, create a data frame of the transformed data from your pca.

D3 <-

#Attach the variable "mean_correct" from your original data frame to D3.
D3<-PCAdata[,1:5]

#Attach the variable "mean_correct" from your original data frame to D3.Now re-run your correlation plots between the transformed data and mean_correct. If you had dropped some components would you have lost important infomation about mean_correct?

D4<-cbind(D3,D1[5])
ggpairs(D4, 1:6, progress = FALSE)
ggcorr(D4, method = c("everything", "pearson"))
pca$rotation
#Examine the eigenvectors, notice that they are a little difficult to interpret. It is much easier to make sense of them if we make them proportional within each component

#Now re-run your correlation plots between the transformed data and mean_correct. If you had dropped some components would you have lost important infomation about mean_correct?
loadings <- abs(pca$rotation) #abs() will make all eigenvectors positive

#Now examine your components and try to come up with substantive descriptions of what some might represent?

#You can generate a biplot to help you, though these can be a bit confusing. They plot the transformed data by the first two components. Therefore, the axes represent the direction of maximum variance accounted for. Then mapped onto this point cloud are the original directions of the variables, depicted as red arrows. It is supposed to provide a visualization of which variables "go together". Variables that possibly represent the same underlying construct point in the same direction.
biplot(pca)

```
## Now print out the loadings for the components you generated:


```{r}
pca$rotation

#Examine the eigenvectors, notice that they are a little difficult to interpret. It is much easier to make sense of them if we make them proportional within each component

loadings <- abs(pca$rotation) #abs() will make all eigenvectors positive

#Now examine your components and try to come up with substantive descriptions of what some might represent?

#You can generate a biplot to help you, though these can be a bit confusing. They plot the transformed data by the first two components. Therefore, the axes represent the direction of maximum variance accounted for. Then mapped onto this point cloud are the original directions of the variables, depicted as red arrows. It is supposed to provide a visualization of which variables "go together". Variables that possibly represent the same underlying construct point in the same direction.

biplot(pca)

Expand All @@ -105,6 +113,17 @@ biplot(pca)
Also in this repository is a data set collected from TC students (tc-program-combos.csv) that shows how many students thought that a TC program was related to andother TC program. Students were shown three program names at a time and were asked which two of the three were most similar. Use PCA to look for components that represent related programs. Explain why you think there are relationships between these programs.

```{r}
#T<-read.csv("tc-program-combos.csv")
# library(ggplot2)
# library(GGally)
# ggpairs(T, 2:68, progress = FALSE)
# ggcorr(T[,-1], method = c("everything", "pearson"))
# pca1 <- prcomp(T[-1], scale. = TRUE)
# pca1$sdev
# pca1$sdev^2
# summary(pca1)
# plot(pca1, type = "lines")


```

Expand Down
Loading