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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/example-data.R
\name{example-data}
\alias{example-data}
\alias{example_mcmc_draws}
\alias{example_yrep_draws}
\alias{example_y_data}
\alias{example_x_data}
\alias{example_group_data}
\title{Example draws to use in demonstrations and tests}
\usage{
example_mcmc_draws(chains = 4, params = 4)
example_yrep_draws()
example_y_data()
example_x_data()
example_group_data()
}
\arguments{
\item{chains}{An integer between 1 and 4 indicating the desired number of
chains.}
\item{params}{An integer between 1 and 6 indicating the desired number of
parameters.}
}
\value{
See \strong{Details}.
}
\description{
These functions return various objects containing data used in the examples
throughout the \strong{bayesplot} package documentation.
}
\details{
Each of these functions returns an object containing data, parameter draws, or
predictions corresponding to a basic linear regression model with data
\code{y} (outcome vector) and \code{X} (predictor matrix), and parameters
\code{alpha} (intercept), \code{beta} (coefficient vector), and \code{sigma}
(error sd).
\describe{
\item{\code{example_mcmc_draws()}}{
If \code{chains > 1}, a \code{250} (iterations) by \code{chains} by
\code{params} array or, if \code{chains = 1}, a \code{250} by \code{params}
matrix of MCMC draws from the posterior distribution of the parameters in
the linear regression model described above. If \code{params = 1} then only
the draws for \code{alpha} are included in the returned object. If
\code{params >= 2} then draws for \code{sigma} are also included. And if
\code{params} is between \code{3} and the maximum of \code{6} then draws
for regression coefficients \code{beta[k]} (\code{k} in \code{1:(params-2)})
are also included.
}
\item{\code{example_y_data()}}{
A numeric vector with \code{434} observations of the outcome variable in the
linear regression model.
}
\item{\code{example_x_data()}}{
A numeric vector with \code{434} observations of one of the predictor
variables in the linear regression model.
}
\item{\code{example_group_data()}}{
A factor variable with \code{434} observations of a grouping variable with
two levels.
}
\item{\code{example_yrep_draws()}}{
A \code{500} (draws) by \code{434} (data points) matrix of draws from the
posterior predictive distribution. Each row represents a full dataset drawn
from the posterior predictive distribution of the outcome \code{y} after
fitting the linear regression model mentioned above.
}
}
}
\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)
}
\keyword{internal}
|