DDPGP_Dens: Posterior density function estimation using MCMC results

Description Usage Arguments Value Examples

View source: R/Main_Functions.R

Description

Posterior density function estimation using MCMC results

Usage

1
2
DDPGP_Dens(mcmc, new_pat, range, if_plot = 0, quantiles = c(0.025, 0.975),
  color = "green")

Arguments

mcmc

A list-The MCMC output from mcmc_Gibbs or FiniteDP

new_pat

A matrix consisting of the covariates of new sample points. Each row represents one sample point. It can also be vector consisting of the covariates of a new sample point.

range

A vector consisting of the values to be evaluated in the plot for density estimation.

if_plot

A logical variable indicating whether the density estimation should be plotted. 1 means estimation should be plotted; 0 means otherwise. Defualt value is 0, i.e. not plotted.

quantiles

A two-dimensional vector determining the quantiles for the confidence bounds to be plotted. The first value is the lower quantile and the second value is the upper quantile. Default is (0.025,0.975)

color

A string determining the color of the plot.

Value

A list composed of the estimation for the density across the given range. The Density_estimation is the mean across all iterations, and the Density_lower_quant and Density_upper_quant are the density estimations for the specified quantiles. Each row represents the estimation for each new sample point.

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
30
31
32
33
34
35
36
37
38
39
40
41
42
########################################
#Source dependent packages
library(MASS)
library(mc2d)
library(mvnfast)
library(survival)
#Simulate Data using built-in data generation
##
seed=1
set.seed(seed)
Npat=5
data <- simulate_data(Npat)

########################################
#Run MCMC 
########################################
#Inputs for mcmc 
response <- log(data$OS)
covariate <- cbind(scale(data$Age),data$AUC,data$CR)
censor_status <- data$death
mcmc_settings<-NULL
mcmc_settings$nskip<-10
mcmc_settings$nburn<-50
mcmc_settings$ndisplay<-100
mcmc_settings$nsave<-20
mcmc_settings$sigma_jump<-c(0,4,2.5,4,2.6)
###################
#Run MCMC function
mcmc_Gibbs<-mcmc_DDPGP(response,covariate,censor_status,mcmc_settings)
########################################
#Plotting Density Estimation 
########################################
#Parameters in Plotting Estimation for Functions 
range=seq(2,8,1)
example_AUC <- 5
example_CR <- 1
example_Age <- 1
new_pat<-cbind(example_Age,example_AUC,example_CR)
if_plot=1
###################
#Plot DDP-GP Density Esimation
a=DDPGP_Dens(mcmc_Gibbs,new_pat,range, if_plot)

DDPGPSurv documentation built on May 2, 2019, 2:51 p.m.