add_sample_lines: Sample Lines

Description Usage Arguments Details Examples

View source: R/blm_plots.R

Description

Adds random sampled lines from a blm object to an existing plot.

Usage

1
add_sample_lines(object, n = 5, sample_from_prior = FALSE, ...)

Arguments

object

a blm object

n

number of lines to show

sample_from_prior

draw samples from the prior distribution?

...

additional arguments passed to lines

Details

Draws random samples from the posterior (or prior if sample_from_prior = TRUE) distribution of blm object. Requires the mvrnorm from the MASS package for random sampling. NOTE: only works for straight lines, assuming first and second coefficient are intercept and slope.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
x <- rnorm(100)
b <- 1.3
w0 <- 0.2 ; w1 <- 3

y <- rnorm(100, mean = w0 + w1 * x, sd = sqrt(1/b))
model <- blm(y ~ x, prior = NULL, beta = b, 
               data = data.frame(x=x, y=y)) 

plot(model)
## Not run: 
add_sample_lines(model, col='green')                

## End(Not run)

manschmi/blm documentation built on May 21, 2019, 11:25 a.m.