Description Usage Arguments Value Examples
View source: R/Poly_Gibbs_BetaPosterior.R
Multinom_PosteriorDistribution_plot_beta
Plots Posterior Frequency Distribution of Parameters estimated by Ordered Multinomial Regression via data augmentation and Gibbs sampling.
1 | Multinom_PosteriorDistribution_plot_beta(beta_matrix, k, burn_in, breaks)
|
beta_matrix |
a nIter X (p) matrix of beta_updates. |
k |
a integer not greater than (p) indicating which beta is of interest. |
burn_in |
burn_in period , less than (nrow(beta_matrix) - 1) |
breaks |
integer, no of breaks in histogram |
PosteriorDistribution_plot
A histrogram showing Posterior Frequency Distribution and Posterior Mean
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
breaks = 50
Result = MultinomGibbs_fit(Train_X, Train_Y, nIter, burn_in, K)
beta_matrix = Result$beta_matrix
Multinom_PosteriorDistribution_plot_beta(beta_matrix = beta_matrix , k = 2, burn_in = 2500, breaks= 50)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.