pp_check.BMSC {bmscstan}R Documentation

Posterior predictive check for BMSC objects

Description

pp_check() plots the posterior predictive check for BMSC objects.

Usage

## S3 method for class 'BMSC'
pp_check(object, type = "dens", limited = FALSE, ...)

Arguments

object

a BMSC object

type

a parameter to select the typology of graph

dens

density overlay plot

hist

histogram plot

mode

the distribution of the mode statistic, over the simulated datasets, compared to the mode of the real data

limited

logical. TRUE if the output should be limited within the 95% credible interval, FALSE it should not. Default FALSE.

...

other arguments are ignored.

Value

a ggplot2 object

Examples

 
# simulation of healthy controls data

Sigma.ctrl <- matrix(cbind(1, .7,  .7, 1) ,nrow=2)

U <- t(chol(Sigma.ctrl))

numobs <- 100

set.seed(123)

random.normal <- matrix( rnorm( n = ncol(U) * numobs, mean = 3, sd = 1),
                         nrow = ncol(U), ncol = numobs)

X = U %*% random.normal

dat.ctrl <- as.data.frame(t(X))

names(dat.ctrl) <- c("y","x")

cor(dat.ctrl)

# simulation of patient data

Sigma.pt <- matrix(cbind(1, 0,  0, 1) ,nrow=2)

U <- t(chol(Sigma.pt))

numobs <- 20

set.seed(0)

random.normal <- matrix( rnorm( n = ncol(U) * numobs, mean = 3, sd = 1),
                 nrow = ncol(U), ncol = numobs)

X = U %*% random.normal

dat.pt <- as.data.frame(t(X))

names(dat.pt) <- c("y","x")

cor(dat.pt)

# fit the single case model

mdl.reg <- BMSC(y ~ x, data_ctrl = dat.ctrl, data_sc = dat.pt, seed = 10)

# summarize the data

summary(mdl.reg)

# plot the posterior predictive checks

pp_check(mdl.reg, limited = FALSE)

pp_check(mdl.reg, limited = TRUE)

pp_check(mdl.reg, type = "mode", limited = FALSE)

pp_check(mdl.reg, type = "hist", limited = FALSE)



[Package bmscstan version 1.1.0 Index]