Prior_Setup: Setup Prior Objects

Description Usage Arguments Value See Also Examples

View source: R/Prior.R

Description

Sets up the structure for the Prior mean and Variance Matrices using information from a classical model.

Usage

1
2
3
4
5
6
7
8
9
Prior_Setup(
  formula,
  data = NULL,
  subset = NULL,
  na.action = na.fail,
  drop.unused.levels = FALSE,
  xlev = NULL,
  ...
)

Arguments

formula

a model formula or terms object or an R object.

data

a data.frame, list or environment (or object coercible by as.data.frame to a data.frame), containing the variables in formula. Neither a matrix nor an array will be accepted.

subset

a specification of the rows to be used: defaults to all rows. This can be any valid indexing vector (see [.data.frame) for the rows of data or if that is not supplied, a data frame made up of the variables used in formula.

na.action

how NAs are treated. The default is first, any na.action attribute of data, second a na.action setting of options, and third na.fail if that is unset. The factory-fresh default is na.omit. Another possible value is NULL.

drop.unused.levels

should factors have unused levels dropped? Defaults to FALSE.

xlev

a named list of character vectors giving the full set of levels to be assumed for each factor.

...

for model.frame methods, a mix of further arguments such as data, na.action, subset to pass to the default method. Any additional arguments (such as offset and weights or other named arguments) which reach the default method are used to create further columns in the model frame, with parenthesised names such as "(offset)".

For get_all_vars, further named columns to include in the model frame.

Value

A list with items related to the prior.

mu

An initial version of the prior mean vector, populated with all zeros

Sigma

An initial version of the prior Variance-Covariance vector, populated as the diagonal identity matrix

model

The model frame from object if it exists

x

The design matrix from object if it exists

See Also

Other prior utility Functions: Prior_Check()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Dobson (1990) Page 93: Randomized Controlled Trial :
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)
print(d.AD <- data.frame(treatment, outcome, counts))
## Step 1: Set up Prior
ps=Prior_Setup(counts ~ outcome + treatment)
mu=ps$mu
V=ps$Sigma
print(ps)

knygren/glmbayes documentation built on Sept. 4, 2020, 4:39 p.m.