Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

hi could you please help me these following questions: it\'s math but using R pr

ID: 3686369 • Letter: H

Question

hi could you please help me these following questions: it's math but using R programing : if you could help to get codes I will be apriciate
thank you ::;;
A, ..... generate a simulated data set with 20 observation in each of the classes (60 absevations total) and 50 variables.
hint: in R you can use rnorm () or runif () to generate data for their corresponding distributions. be sure you add a mean shift to the absevations in each class so there are three distinct classes.

B, ....perform PCA on 60 absevations and plot the first two principal component score vectors. Use a different color to indicate the observation in each of the three classes. Do this until you see a separation in the three classes. Explain how you were able to get this separation.

.

Explanation / Answer

Answer for Part A:

#for the response variable y (60 values - 3 classes 1,2,3 - 20 observations per class)

y <- rep(c(1,2,3),20 )

#for the matrix of variables x

#you need a matrix of 50 variables i.e. 50 columns and 60 rows i.e. 60x50 dimensions (=3000 table cells)

x <- matrix( rnorm(3000), ncol=50 )

#bind the 2 - y will be the first column

mymatrix <- cbind(y,x)

> dim(x) #60 rows , 50 columns

[1] 60 50

> dim(mymatrix) #60 rows, 51 columns after the addition of the y variable

[1] 60 51