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
30 changes: 24 additions & 6 deletions assignment5.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ The data you will be using comes from the Assistments online intelligent tutorin

## Start by uploading the data
```{r}
D1 <-
library(dplyr)
library(tidyr)

D1 <- read.csv("Assistments-confidence.csv")

```

Expand All @@ -38,7 +41,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 @@ -66,22 +69,25 @@ summary(pca)
plot(pca, type = "lines")
```



## Decide which components you would drop and remove them from your data set.
## I will remove PCs after PC5 because they have variance less than 1.

## Part II

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

D3 <-
D3 <- pca$x[,1:5]

#Attach the variable "mean_correct" from your original data frame to D3.


D3 <- data.frame(D3,D1$mean_correct)

#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?


ggpairs(D3, progress = FALSE)
ggcorr(D3, method = c("everything", "pearson"))

```
## Now print out the loadings for the components you generated:
Expand All @@ -105,8 +111,20 @@ 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}
DF1 <- read.csv("tc-program-combos.csv")
ggcorr(DF1[,-1], method = c("everything", "pearson"))
DF2 <- DF1[,-1]
pca2 <- prcomp(DF2, scale. = TRUE)
pca2$sdev
pca2$sdev^2
summary(pca2)
DF3 <- pca2$x[,1:10]
plot(pca2, type = "lines")
loadings2 <- abs(pca2$rotation)
biplot(pca2)

```
## We coulad look at loadings2 dataframe and the biplot to see which programs are similar programs.



Expand Down
Loading