set.seed(125)
n <- 1000
Sigma <- matrix(c(
1.00, 0.30, 0.55, 0.20,
0.30, 1.00, 0.25, 0.50,
0.55, 0.25, 1.00, 0.40,
0.20, 0.50, 0.40, 1.00
), 4, 4, byrow = TRUE)
Z <- mnormt::rmnorm(n = n, mean = rep(0, 4), varcov = Sigma)
X <- data.frame(x1 = Z[, 1], x2 = Z[, 2])
Y <- data.frame(
y1 = ordered(cut(
Z[, 3],
breaks = c(-Inf, -0.5, 0.7, Inf),
labels = c("low", "mid", "high")
)),
y2 = ordered(cut(
Z[, 4],
breaks = c(-Inf, -1.0, 0.0, 1.0, Inf),
labels = c("1", "2", "3", "4")
))
)
ps <- polyserial(X, Y)
print(ps, digits = 3)
summary(ps)
plot(ps)
Run the code above in your browser using DataLab