Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(mvtnorm)
- library(MBESS)
- rgMatrix <- matrix(ncol=2, c(1,-0.3, -0.3, 1))
- covMatrix <- cor2cov(rgMatrix, sd=rep(1,2))
- generate <- function(mu=c(0,0), n=1000) { rmvnorm(n, mean=mu, sigma=covMatrix, method="svd") }
- df <- as.data.frame(generate())
- colnames(df) <- c("Good", "Bad")
- df$Index <- (df$Good * 1) - (df$Bad * 0.5)
- cutoff <- quantile(df$Index, probs=0.90)
- df$Selected <- df$Index > cutoff
- library(ggplot2)
- qplot(Good, Bad, color=Selected, data=df) + geom_point(size=5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement