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
24 changes: 20 additions & 4 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 = TRUE)

```

Expand All @@ -27,6 +27,8 @@ D1 <-

library(ggplot2)
library(GGally)
library(tidyr)
library(dplyr)

ggpairs(D1, 2:8, progress = FALSE) #ggpairs() draws a correlation plot between all the columns you identify by number (second option, you don't need the first column as it is the student ID) and progress = FALSE stops a progress bar appearing as it renders your plot

Expand All @@ -38,7 +40,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[,c(-1,-5)]

```

Expand Down Expand Up @@ -67,20 +69,23 @@ plot(pca, type = "lines")
```

## Decide which components you would drop and remove them from your data set.
I would drop and remove PC6 from the data set because it covers less than 10% of the variance.

## Part II

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

D3 <-
D3 <- data.frame(pca$x)

#Attach the variable "mean_correct" from your original data frame to D3.
D3$mean_correct <- 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, 2:6, progress = FALSE)
ggcorr(D3[,-1], methods = c("everything", "pearson"))


```
Expand All @@ -105,7 +110,18 @@ 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", header = TRUE)
df2 <- df1[,-1]
pca_tc <- prcomp(df2, scale. = TRUE)
pca_tc$sdev
pca_tc$sdev^2
summary(pca_tc)
plot(pca_tc, type = "lines")
pca_tc$rotation
loadings1 <- abs(pca$rotation)
biplot(pca)

#I think it is clear that relationships are exist between these programs. The programs are together with the similar fields of each other. For those that has correlated programs, they tend to move towards one direction.#
```


Expand Down
Loading