BinaryGibbs_Traceplot: Plots for Diagnosis of Convergence Distribution .

Description Usage Arguments Value Examples

View source: R/Binary__Gibbs_TraceplotsPlots.R

Description

BinaryGibbs_Traceplot Plots for diagnosis of Parameters estimates by Probit Regression for Binary Responses via data augmentation and Gibbs sampling.

Usage

1
BinaryGibbs_Traceplot(beta_matrix, k)

Arguments

beta_matrix

a nIter X (p+1) matrix of beta_updates.

k

a integer not greater than (p+1) 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
set.seed(250)
require(truncnorm)
require(MASS)
N <- 500
x1 <- seq(-1, 1, length.out = N)
x2 <- rnorm(N, 0, 1)
D <- 3
X <- matrix(c(rep(1, N), x1, x2), ncol = D)
true_theta <- c(- 0.5, 3.3, 2)
p <- pnorm(X %*% true_theta)
y <- rbinom(N, 1, p)
N1  <- sum(y)  # Number of successes
N0  <- N - N1  # Number of failures
#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, -1] # Train Data Covariates
Test_X = X[-Train_ID, -1] # Test Data Covarites
Train_Y = y[Train_ID] # Train Data Response
Test_Y = y[-Train_ID] # Test Data Response
nIter = 10000
burn_in = round(nIter * 0.5)
prior = 2
prior_mean = rep(1, 3)
prior_var = diag(10, 3)
temp = BinaryGibbs_fit(Train_X, Train_Y, nIter, prior, burn_in, prior_mean, prior_var )
BinaryGibbs_Traceplot(beta_matrix = temp$beta_matrix, k = 0)

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