Burak Aydin <burak235...@hotmail.com> asked:
Lets say I know Pearson covariance matrix.
When I use rmvnorm to simulate 9 variables and then
dichotomize/categorize
them, I cant retrieve the population covariance matrix.
library(polycor)
sim1 <- function(thresh=0.5, r=0.3) {
x <- rmvnorm(1000,c(0,0),matrix(c(1,r,r,1), nr=2))
x[x>thresh] <- 2
x[x<2] <- 1
polychor(x[,1], x[,2])
}
tr <- double(100)
for(i in 1:100) tr[i] <- sim1()
summary(tr)
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.1571 0.2703 0.3041 0.3010 0.3328 0.4062
--
| David Duffy (MBBS PhD) ,-_|\
| email: dav...@qimr.edu.au ph: INT+61+7+3362-0217 fax: -0101 / *
| Epidemiology Unit, Queensland Institute of Medical Research \_,-._/
| 300 Herston Rd, Brisbane, Queensland 4029, Australia GPG 4D0B994A v
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.