# NOT RUN {
# }
# NOT RUN {
# Continuous Covariate
X1 <- runif(100, 0,1)
# Binary Covariate
X2 <- rbinom(100, 1, 0.5)
pi <- exp(2*X1 + -2*X2)/(exp(2*X1 + -2*X2) + 1)
# Binary response
Y <- rbinom(100, 1, pi)
keep <- sample(1:100, 75, replace=FALSE)
X <- cbind(X1, X2)
Xtn <- X[keep,]
ytn <- Y[keep]
Xtt <- X[-keep,]
ytt <- Y[-keep]
# Since Multinomial need to select boundaries of "latent states".
# For co below the latent states are < 0 and > 0
co <- c(-100000, 0, 100000)
# Their selection is arbitrary and doesn't impact things
# See Thanasis work on this.
# m0 s20 v k0 n0 a0
simParms <- c(0.0, 1.0, 2.0, 1.0, 2.0, 0.1)
# m s2 s s s0 s0
modelPriors <- c(0, 10, 0, 1, 0, 1)
draws <- 50000
burn <- 25000
thin <- 25
nout <- (draws - burn)/thin
# Takes about 15 seconds to run
fit <- ordinal_ppmx(y = ytn, co=co, X=Xtn, Xpred=Xtt,
similarity_function=1, consim=1,
calibrate=0,
simParms=c(0.0, 1.0, 0.5, 1.0, 2.0, 0.1, 1),
modelPriors=c(0, 1, 0, 0.5, 0, 10),
draws=draws, burn=burn, thin=thin, verbose=FALSE)
# The first partition iterate is used for plotting
# purposes only. We recommended using the salso
# R-package to estimate the partition based on Si
pairs(cbind(Y, X), col=fit$Si[1,])
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab