get.param.vals: Get posterior parameter estimates from a model object

Description Usage Arguments Value Author(s) See Also Examples

View source: R/hmob_funcs.R

Description

A function to build a matrix or dataframe of parameter estimates in a runjags or coda model object. The function gets the mean, median, standard deviation, and lower and upper 95 for route-level (ij) or month-level (ijt).

Usage

1
2
3
4
5
6
7
8
9
get.param.vals(
  n.districts,
  n.t,
  name,
  level = "route",
  stats,
  type = "matrix",
  n.cores = 2
)

Arguments

n.districts

Number of districts in model

n.t

Number of months or other time interval

name

Name of the parameter as it is in the model output

level

The hierarchical level of the model that correpsonds to name (e.g. 'route' or 'month')

stats

Expects statistics output of coda::summary function. If model out put is a runjags object, this can be given by: summary(as.mcmc.list(out))$statistics

type

Return a matrix or dataframe (default = 'matrix')

n.cores

Number of cores to use in parallel computation

Value

If level = 'route', a list containing two matrices named mean and sd. If level = 'month', a list containing two 3-dimensional arrays named mean and sd.

Author(s)

John Giles

See Also

Other model processing: calc.decay.stats(), mob.data.array.pop.level(), mob.data.array.route.level()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
load('./output/decay_1day_62dists_summary.Rdata')  # mod.decay # Summary of decay model parameters (Lambda)

# Get trip duration decay rate rate parameter lambda
lam <- get.param.vals(n.districts=62, 
                      name='lambda',
                      level='route',
                      stats=mod.decay,
                      n.cores=4)

see(lam$mean)

gilesjohnr/hmob documentation built on Aug. 8, 2020, 1:26 a.m.