Skip to content

Instantly share code, notes, and snippets.

@sasa1977
Created March 22, 2018 12:02
Show Gist options
  • Save sasa1977/6ac46e3c784d2be23cd15928b0e32839 to your computer and use it in GitHub Desktop.
Save sasa1977/6ac46e3c784d2be23cd15928b0e32839 to your computer and use it in GitHub Desktop.
library(MASS)
n_correlated = 99
correlation = 1
correlated_data <- mvrnorm(
n_correlated,
mu = c(0,0),
Sigma = matrix(c(1, correlation, correlation, 1), ncol = 2),
empirical = TRUE
)
data_with_outlier = rbind(correlated_data, c(1, -1))
correlated_prc = prcomp(correlated_data, center=TRUE, scale=TRUE)
prc_with_outlier = prcomp(data_with_outlier, center=TRUE, scale=TRUE)
plot(data_with_outlier)
biplot(correlated_prc)
biplot(prc_with_outlier)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment