Multinom_traceplot_gamma: Plots for Diagnosis of Convergence Distribution .

Description Usage Arguments Value Examples

View source: R/Poly_Gibbs_GammaTrace.R

Description

Multinom_traceplot_gamma Plots for diagnosis of Parameters estimates by Ordered Multinomial Regression via data augmentation and Gibbs sampling.

Usage

1
Multinom_traceplot_gamma(gamma_update, k)

Arguments

gamma_update

a nIter X (K+1) matrix of beta_updates staring with -Inf and ending with + Inf, sorted in each row

k

a integer not greater than (p) indicating which beta is of interest.

Value

traceplot Line diagrams showing convergence of gibbs sampler for a parameter and indicating cumulative posterior mean over iterartions.

Examples

 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
29
# 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
k = 1
nIter = 10000
burn_in = 5000
breaks = 50
Result = MultinomGibbs_fit(Train_X, Train_Y, nIter, burn_in, K)
gamma_update = Result$gamma_update
Multinom_traceplot_gamma(gamma_update = gamma_update , k = 2)

zovialpapai/PolyGibbs documentation built on Dec. 9, 2019, 6:52 a.m.