plot_trend: Plot estimated trend and credible intervals

Description Usage Arguments Details Value See Also

View source: R/plot_trend.r

Description

Plot posterior median of trend parameters and associated credible intervals.

Usage

1
2
3
4
plot_trend(theta = NULL, mfit = NULL, obstype = "normal", alpha = 0.05,
  obsvar = NULL, uxvar = NULL, xvar = NULL, colset = "blue",
  trend.col = NULL, trend.lwd = 3, bci.col = NULL, pt.col = "gray60",
  pt.pch = 1, pt.cex = 1, ylab, xlab, main, ylim, xlim, ...)

Arguments

theta

A list generated by extract_theta function. If theta is specified, do not specify a value for mfit.

mfit

An object containing posterior draws from a spmrf or stan model fit. The object can be of class stanfit, array, matrix, or data.frame. Do not specify theta if mfit is specified.

obstype

Name of probability distribution of observations. This controls the back-transformation of the process parameters. Possible obstypes are 'normal', 'poisson', 'binomial', or 'coalescent'. Assumed link functions are the log for 'poisson' and 'coalescent', and logit for 'binomial'.

alpha

Controls level for 100*(1-alpha)% Bayesian credible intervals.

obsvar

Vector of observations. Assumed to be ordered by time with one observation per time point. If obsvar is NULL, then data are not plotted. Note if plotting observations you must also specify a matching xvar of the same length.

uxvar

vector of unique values of the grid locations of the trend parameters. This can be a numeric or integer vector. Must be the same length as theta and must be sorted to match order of locations of theta elements. If not specified and no xvar is specified, then a sequence from 1 to the length of theta with unit spacing will be used. If xvar and obsvar are specified, then uxvar does not need to be specified.

xvar

x-variable for plotting observations obsvar. Should be a numeric integer vector. Must be the same length as observation vector (obsvar). Must be specified if obsvar is specified.

colset

Color set for trend and credible intervals. These are presets chosen with common color combinations. Choices are 'blue', 'purple', 'red', 'green', and 'gray'. This parameter is overridden If trend.col and bci.col are specified.

trend.col

Color of the trend line. Any standard R plotting colors are allowed. Use this along with bci.col if color choices other than the presets provided by colset are desired.

bci.col

Color of the credible interval band. Any standard R colors are allowed.

pt.col

Color of data points if plotted with obsvec specified.

pt.pch

Type of points to use if data plotted with obsvec specified (see points for details.

pt.cex

Size of points to use if data plotted with obsvec specified (see points for details.

ylab

Character string describing label for y-axis. Default is "y" if unspecified.

xlab

Character string describing label for x-axis. Default is "x" if unspecified.

main

Character string describing label for main title. Default is "" empty string.

ylim

Numeric vector with two elements describing limits of y-variable. Default is range of combined vector of obsvec and extreme values of BCI's if unspecified.

xlim

Numeric vector with two elements describing limits of x-variable. Default is range of sequence from 1 to max length of elements in theta or number of rows in mfit.

...

Additional parameters passed to the plot function.

Details

The input can be either in the form of a list generated by the extract_theta function (passed in as the theta variable) or as a raw model fit object from spmrf or rstan (passed in as mfit). Note that using mfit is more computationally costly than using theta because the extract_theta function is called when mfit is specified.

Value

Returns a plot object.

See Also

plot, points, extract_theta, spmrf, stanfit, array, matrix, data.frame


faulknerjam/bnps documentation built on Oct. 18, 2018, 12:03 p.m.