get.mig.parameter.traces | R Documentation |
Functions for accessing traces of the MCMC parameters, either country-independent or country-specific.
get.mig.parameter.traces(
mcmc.list,
par.names = NULL,
burnin = 0,
thinning.index = NULL,
thin = NULL
)
get.mig.parameter.traces.cs(
mcmc.list,
country.obj,
par.names = NULL,
burnin = 0,
thinning.index = NULL,
thin = NULL
)
mcmc.list |
List of |
par.names |
Names of country-independent parameters (in case of
|
burnin |
Burn-in indicating how many iterations should be removed from the beginning of each chain. |
thinning.index |
Index of the traces for thinning. If it is |
thin |
An integer value for thinning. It is an alternative to
|
country.obj |
Country object (see |
Both functions return a matrix with columns being the parameters and
rows being the MCMC values, attached to one another in case of multiple chains.
get.mig.parameter.traces
returns country-independent parameters,
get.mig.parameter.traces.cs
returns country-specific parameters.
mig.coda.list.mcmc
for another way of retrieving parameter traces;
mig.parameter.names
and mig.parameter.names.cs
for parameter names.
# Toy simulation for US states
us.mig.file <- file.path(find.package("bayesMig"), "extdata", "USmigrates.txt")
sim.dir <- tempfile()
m <- run.mig.mcmc(nr.chains = 2, iter = 30, thin = 1, my.mig.file = us.mig.file,
output.dir = sim.dir, present.year = 2017, annual = TRUE)
# obtain traces of hierarchical parameters
par.values <- get.mig.parameter.traces(m$mcmc.list, burnin = 5)
dim(par.values) # matrix 50 x 4
hist(par.values[, "mu_global"], main = "mu")
# obtain traces of location-specific traces for California
mig.parameter.names.cs() # allowed parameter names
par.values.cs <- get.mig.parameter.traces.cs(m$mcmc.list,
country.obj = get.country.object("California", meta = m$meta),
burnin = 5, par.names = "phi_c")
dim(par.values.cs) # matrix 50 x 1
hist(par.values.cs, main = colnames(par.values.cs))
unlink(sim.dir, recursive = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.