Multinom_traceplot_beta: Plots for Diagnosis of Convergence Distribution .

Description Usage Arguments Value Examples

View source: R/Poly_Gibbs_BetaTrace.R

Description

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

Usage

1
Multinom_traceplot_beta(beta_matrix, k)

Arguments

beta_matrix

A nIter X p matrix of beta updates over all iterations.

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)
beta_matrix = Result$beta_matrix
Multinom_traceplot_beta(beta_matrix = beta_matrix, k = 1)

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