bayesmodel: bayesmodel

Description Usage Arguments Value Examples

View source: R/bayesmmm.R

Description

Creates a bayesian model using rstan.

Usage

1
2
bayesmodel(data, y, variables, observations = NULL, cores = 4,
  chains = 4, adstock_range = c(0.1, 0.7), chainlength = 2000)

Arguments

data

A data frame containing a column of observations (labelled "date"), an optional column of pool names (labelled "poolname"), the dependent variable, and indepedendent variables.

y

A string identifying the dependent variable.

variables

a data frame (optionally created by the variable_grid function) containing one row for each independent variable and the following columns: '

variable

The variable name

expected sign

Either "+" or "-" for half-normal prior distributions. Any other values will be ignored and treated as NA. Default NA

transformation

Choose between "standard", "standard pooled", or "media".

reference.point

Choose between "0", "min", or "max".

global

An optional boolean to specify whether coefficients should vary across pools. If FALSE, a separate coefficient will be estimated for each pool using hierarchical partial-pooling, otherwise a single coefficient will be estimated. Default FALSE.

prior.mean

The prior mean. NA assumes a weakly informative prior distribution (i.e. zero after standardisation).

prior.sd

The prior standard deviation. NA assumes a weakly informative prior distribution (i.e. 1 after standardisation).

observations

an optional string vector of observation names, e.g. c("2014-01-01", "2014-01-08", ...). Default NULL

cores

The number of cores to be used for the markov chain estimation. Default 4.

Value

model

the Stan model

summary

a data frame of untransformed MAP estimates

script

the generated Stan code

scale

the scaling factors used for standardisation

y

the y vector

x

the x data frame

priors

the priors (if any)

observations

the observation names (if any)

Examples

1
model <- bayesmodel(dep, indeps, priors, observations=obs)

nrhodes1451/bayesmmm documentation built on Jan. 2, 2020, 2:16 a.m.