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
35 changes: 29 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")

```

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[,c(-1,-5)]

```

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

## Decide which components you would drop and remove them from your data set.
I will include the first 4 principal components as they explained almost 80% of
variance in the data and drop the last 2 components.

## 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, progress = FALSE)


# No I would not lost important information about the mean_correct if some components are dropped.
```
## Now print out the loadings for the components you generated:

Expand All @@ -92,9 +95,13 @@ 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

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

# The first principal component represents mostly 3 variables which are mean_attempt, mean_hint and problems_attempted. The second principal component represents almost two variables which are prior_prob_count and prior_percent_correct. The third principal component represents also two variables which are mean_confidence and prior_prob_count. The fourth component also represents two variables which are mean_confidence and prior_prob_count. The last two components are less influential.



#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,10 +112,26 @@ 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")
```


```{r}
pca2 <- prcomp(T[,-1], scale. = TRUE)
summary(pca2)
plot(pca2, type = "lines")
```



```{r}
loadings2 <- abs(pca2$rotation)
```

The first principal component represents multiple majors which are School.Principals, Private.School.Leadership, Politics, Leadership, Change.Leadership, Education.Policy, Economics.and.Education, Cooperation.and.Conflict.Resolution and Arts.Administration.
The relationship between these majors is that leadership position in Educational institutions require such majors.

The second principal component represents also multiple majors which are Physiology, Behavior.Analysis, Clinical.Psychology, Nursing, Health.Education, Kinesiology, Neuroscience, Physical.Education and Psychology. Those majors are related to each other and students who like the health sector go for those majors.

The third principal component represents also multiple majors which are Communication.Media.and.Learning.Technologies, Measurement..Evaluation.and.Statistics, Mathematics, Learning.Analytics, Instructional.Technology.and.Media, Education.Technology, Design.and.Development.of.Digital.Games, Creative.Technologies and Cognitive.Science. Those majors represents students who are interested in technology, data and quantitative analysis.

Loading