Description Usage Arguments Value Examples
View source: R/Poly_Gibbs_Prediction.R
MultinomGibbs_Pred
Predicts using fitted Bayesian Ordered Multinomial Model.
1 | MultinomGibbs_pred(estimates, gamma_estimates, Test_X)
|
estimates |
a (p) X 1 vector of beta estimates, where beta1, beta2 etc are sorted as 0,1,2... |
gamma_estimates |
a (K+1) X 1 vector of gamma estimates which starts and ends with -Inf and Inf respectively and sorted in accending order. |
Test_X |
a () X p matrix of continuous scale covarites |
Predicted_Y a nrow(Test_X) X 1 vector of predicted responses
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | # Initialization
set.seed(250)
n <- 1000 # Total no of observations.
int1 <- -1 # gamma boundary
int2 <- 3 # gamma boundary
beta <- c(-.75, 1) # Regression Parameters for data generation.
X <- cbind(sample(1:4, n, replace = TRUE), rnorm(n, 0, 2)) # Generated design matrix
# Generation of Latent Variable Observations
eta <- X %*% beta
z <- rnorm(n, eta, 1)
# Generation of Responses depending on z
y <- rep(0, n)
y[z <= int1] <- 1
y[int1 <z & z <= int2] <- 2
y[int2 < z ] <- 3
#Spliting The Data in Train and Test in 80:20 ratio
Train_ID = sample(1:nrow(X), round(nrow(X) * 0.8), replace = FALSE) # Train Data IDS
Train_X = X[Train_ID, ]# Train Data Covariates
Test_X = X[-Train_ID, ]
Train_Y = y[Train_ID] # Train Data Response
Test_Y = y[-Train_ID] # Test Data Response
K = 3
nIter = 10000
burn_in = 5000
Result = MultinomGibbs_fit(Train_X, Train_Y, nIter, burn_in, K)
estimates = Result$estimates
gamma_estimates = Result$gamma_estimates
MultinomGibbs_pred(estimates, gamma_estimates,Test_X )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.