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,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 @@ -38,14 +38,14 @@ 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 <- subset(D1, select =c(-1,-5))

```

## Now run the PCA on the new data frame

```{r}
pca <- prcomp(D2, scale. = TRUE)
pca <- prcomp(D2, scale = TRUE)
```

## Although princomp does not generate the eigenvalues directly for us, we can print a list of the standard deviation of the variance accounted for by each component.
Expand All @@ -64,6 +64,7 @@ summary(pca)
#We can look at this to get an idea of which components we should keep and which we should drop

plot(pca, type = "lines")
##I would drop PC6 because it has the least amount of variance.
```

## Decide which components you would drop and remove them from your data set.
Expand All @@ -73,15 +74,17 @@ plot(pca, type = "lines")
```{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, progress = FALSE)

##Yes, I would've lost important information if I dropped PC6 as it's showing a strong correlation (especially compared with other variables) with regards to the mean_correct.

```
## Now print out the loadings for the components you generated:
Expand All @@ -95,20 +98,35 @@ 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?

##PC1 might be referring to the efforts put in by the students, displayed by the similar loading scores of problems_attempted, mean_hint, and mean_attempt. PC2 group has the highest loading scores for the prior_Percent_correct so this might be a group of those who taken the session before. PC3 has the highest confidence. PC4 is showing a negative relationship between the mean_attempt and prior_prob_count. PC5 might be those who are lacking confidence in the ability as displayed by mean_attempt. There is no clear pattern for PC6.


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


```
# Part III
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}

D5 <- read.csv("tc-program-combos.csv", header=TRUE)
D5 <- D5[,-1]
pca <- prcomp(D5, scale. = TRUE)
summary(pca)
plot(pca, type = "lines")
pca$rotation
abs(pca$rotation)
biplot(pca)


##Based on the plot, psychology courses such as Clinical Psychology, Psychology, Women and Gender in Psychology and Psychological Counseling, Counseling Psychology are directing in the same direction and can be grouped into one group. Another cluster is seen by courses such as English Education, Teaching English and Linguistics. Health Science courses such as Kinesiology, Physiology and Health Education, and Movement Science are also pointing in the same direction and are in the same group.

```






Loading