Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submitting Assignment 5 - Xiaojia Liu #204

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
36 changes: 33 additions & 3 deletions assignment5.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ The data you will be using comes from the Assistments online intelligent tutorin

## Start by uploading the data
```{r}
D1 <-
library(readr)
D1 <- read_csv("Assistments-confidence.csv")
View(D1)

```

Expand All @@ -38,7 +40,10 @@ 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 <-

library(dplyr)
D2 <- select(D1, -mean_correct,-id)
View(D2)

```

Expand Down Expand Up @@ -73,10 +78,14 @@ plot(pca, type = "lines")
```{r}
#Now, create a data frame of the transformed data from your pca.

D3 <-
D3 <- data.frame(pca$x)
D4 <- data.frame(D3, D1$mean_correct)
View(D4)

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

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


#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?
Expand All @@ -95,6 +104,13 @@ 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?

#1) PC1 represents the relationship for hints and problems attempt.
#2) PC2 represents how much knowledge the students had in prior related to the percentage of the correctness for the prior problem.
#3) PC3 represents how much the confidence the students had will impact on the count of the problem attempted.
#4) PC4 represents how much practice the students had before will impact on their confidence.
#5) PC5 represents the attempt and problems attempted, which does not highly correlated with correctness.


#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 +121,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}
library(readr)
data <- read.csv("tc-program-combos.csv")
View(data)

ggcorr(data[,-1], method = c("everything", "pearson"))

data2 <- data[,-1]
pca2 <- prcomp(data2, scale. = TRUE)
pca2$sdev
pca2$sdev^2
summary(pca2)

plot(pca2, type = "lines")


```

Expand Down
Loading