generate_data: Generate a data vector according to a model

View source: R/prediction.R

generate_dataR Documentation

Generate a data vector according to a model

Description

This function generates draws from the prior predictive distribution. Parameter values are drawn from their priors, and consequently data is generated from the sampling distribution given these parameter values.

Usage

generate_data(
  formula,
  data = NULL,
  family = "gaussian",
  ny = NULL,
  ry = NULL,
  r.mod,
  sigma.fixed = NULL,
  sigma.mod = NULL,
  Q0 = NULL,
  formula.V = NULL,
  linpred = NULL
)

Arguments

formula

A model formula, see create_sampler. Any left-hand-side of the formula is ignored.

data

see create_sampler.

family

sampling distribution family, see create_sampler.

ny

see create_sampler.

ry

see create_sampler.

r.mod

see create_sampler.

sigma.fixed

see create_sampler.

sigma.mod

see create_sampler.

Q0

see create_sampler.

formula.V

see create_sampler.

linpred

see create_sampler.

Value

A list with a generated data vector and a list of prior means of the parameters. The parameters are drawn from their priors.

Examples


n <- 250
dat <- data.frame(
  x = rnorm(n),
  g = factor(sample(1:10, n, replace=TRUE)),
  ny = 10
)
gd <- generate_data(
  ~ reg(~ 1 + x, Q0=10, b0=c(0, 1), name="beta") + gen(factor = ~ g, name="v"),
  family="binomial", ny="ny", data=dat
)
gd
plot(dat$x, gd$y)



mcmcsae documentation built on Oct. 11, 2023, 1:06 a.m.