plot.BMSC {bmscstan}R Documentation

Plot estimates from a BMSC object.

Description

Plot estimates from a BMSC object.

Usage

## S3 method for class 'BMSC'
plot(x, who = "both", type = "interval", CI = 0.95, ...)

Arguments

x

An object of class BMSC.

who

parameter to choose the estimates to plot

both

plot in the same graph both controls and the Single Case

control

only the controls

single

only the Single Case (β + δ)

delta

only the difference between the Single Case and controls

type

a parameter to select the typology of graph

interval

the estimates will be represented by means of pointrange, with median and the boundaries of the credible interval

area

a density plot

hist

a density histogram

CI

the dimension of the Credible Interval (or Equally Tailed Interval). Default 0.95.

...

other arguments are ignored.

Value

a plot, a ggplot2 object, or a bayesplot 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 results of both patient and control group

plot(mdl.reg)

# plot the results of the patient

plot(mdl.reg, who = "single")

# plot the results of the difference between the control group and the patient

plot(mdl.reg, who = "delta")

# density plots

plot(mdl.reg, type = "area")

# histograms

plot(mdl.reg, type = "hist")



[Package bmscstan version 1.1.0 Index]