example-data {bayesplot} | R Documentation |
Example draws to use in demonstrations and tests
Description
These functions return various objects containing data used in the examples throughout the bayesplot package documentation.
Usage
example_mcmc_draws(chains = 4, params = 4)
example_yrep_draws()
example_y_data()
example_x_data()
example_group_data()
Arguments
chains |
An integer between 1 and 4 indicating the desired number of chains. |
params |
An integer between 1 and 6 indicating the desired number of parameters. |
Details
Each of these functions returns an object containing data, parameter draws, or
predictions corresponding to a basic linear regression model with data
y
(outcome vector) and X
(predictor matrix), and parameters
alpha
(intercept), beta
(coefficient vector), and sigma
(error sd).
example_mcmc_draws()
-
If
chains > 1
, a250
(iterations) bychains
byparams
array or, ifchains = 1
, a250
byparams
matrix of MCMC draws from the posterior distribution of the parameters in the linear regression model described above. Ifparams = 1
then only the draws foralpha
are included in the returned object. Ifparams >= 2
then draws forsigma
are also included. And ifparams
is between3
and the maximum of6
then draws for regression coefficientsbeta[k]
(k
in1:(params-2)
) are also included. example_y_data()
-
A numeric vector with
434
observations of the outcome variable in the linear regression model. example_x_data()
-
A numeric vector with
434
observations of one of the predictor variables in the linear regression model. example_group_data()
-
A factor variable with
434
observations of a grouping variable with two levels. example_yrep_draws()
-
A
500
(draws) by434
(data points) matrix of draws from the posterior predictive distribution. Each row represents a full dataset drawn from the posterior predictive distribution of the outcomey
after fitting the linear regression model mentioned above.
Value
See Details.
Examples
draws <- example_mcmc_draws()
dim(draws)
dimnames(draws)
draws <- example_mcmc_draws(1, 2)
dim(draws)
colnames(draws)
draws <- example_mcmc_draws(params = 6)
dimnames(draws)[[3]]
y <- example_y_data()
x <- example_x_data()
group <- example_group_data()
length(y)
length(x)
length(group)
tail(data.frame(y, x, group), 5)
yrep <- example_yrep_draws()
dim(yrep) # ncol(yrep) = length(y) = length(x) = length(group)