modelBayes: A Metropolis MCMC version for any modeling y~x, without...

Description Usage Arguments Value See Also

Description

A Metropolis MCMC version for any modeling y~x, without random effects (as in lmerBayes). This version is built off lmerBayes, with the hyperdistributions excluded. A single independent variable, y, can be fit against any number of predictors, x,

The model error can be binomial, Poisson, negative binomial, or Gaussian, with two alternatives for the Gaussian (described below).

Data are submitted the way lm or lmer require, with one single table, one row per observation. The formula, however, is not submitted using the R-style 'squiggle'~.

Rather, the names of x, y columns, are given. The model describing y's function of the x's is passed, and must be provided by the user (several are available within the CTFS R Package, though, in the Utilities topic). Examples below will serve to explain.

Usage

1
2
3
4
modelBayes(data, ycol, xcol, start, startSD, model = logistic.standard,
  error = "Binom", update = "conjugate", badparam = NULL,
  sdfunc = constant, badSDparam, steps = 1000, showstep = 100,
  burnin = 100, debug = FALSE, ...)

Arguments

data

The table of data, in lmer-style, including one column to be modeled (dependent variable, y), one or more predictors (independent variables, x), and one random effect, using any column names.

ycol

Chareacter string giving the name of a column in data that holds the x and y (numeric) variable.

xcol

Chareacter string giving the name of a column in data that holds the x and y (numeric) variable.

start

A vector giving the starting set of parameters for the model. It must be as long as the number of parameters required by the model.

startSD

A starting value for the error model; there must be as many startSD as parameters needed by sdfunc

model

The function name holding the model describing y's relationship to all the x's, without quote marks. The first argument of the function must be named x, the second param, with additional arguments allowed. The model may accept as x either a vector or a matrix, the latter for a multiple regression. There can be any number of parameters, but the number must match the number given as start parameters. The return value must be a numeric vector with the same size as x.

error

A character variable with 6 possible values: "Binom", "NgBinom", "Pois", "Gauss", "GaussMultResid", or "Flat".

  • "Binom" uses binomial error for residuals - NegBinom'uses negative binomial error for residuals; the SD is then the dispersion parameter (k) of the negative binomial.

  • "Poisson" uses Poisson error for residuals.

  • "Gauss" uses Gaussian error for residuals with constant standard deviation across groups.

  • "GaussMultResid" uses Gaussian error for residuals, with standard deviation a constant fraction of the model's prediction (and thus only appropriate if predictions are strictly positive).

  • "Flat" is a trivial model where the same likelihood is returned regardless of parameters or data. It is for testing how parameter search behaves in absence of data, as for describing an implied prior.

update

'conjugate' or 'metropolis', whether to use inverse-gamma (or inverse-Wishart for full covariance) vs. metropolis steps for updating covariances.

badparam

The name of a function (unquoted) that tests a set of model parameters for validity; must return TRUE if parameters are valid, otherwise FALSE.

sdfunc

The name of a function (unquoted) that models the error parameter as a function of the x's; the default uses the function named constant, meaning the standard deviation is the same for all values of x. Parameters for this function are estimated, just as parameters for the model function.

badSDparam

The name of a function which tests for invalid parameters for sdfunc, returning TRUE or FALSE (analogous to badparam); a simple version is provided, called badSD, which rejects a single parameter if it is < 0.

steps

The number of steps to run the Gibbs sampler.

showstep

Information is printed to the screen every showstep steps.

burnin

The number of steps to remove as burn-in before calculating posterior distributions; not that all parameters are saved and returned regardless.

debug

Logical. If TRUE, call browser to debug.

...

The typical R means for submitting additional parameters for various functions used in the model (model, sdfunc, badparam, badSDparam).

Value

The return value is a list with several components:

See Also

lmerBayes()


forestgeo/ctfs documentation built on May 3, 2019, 6:44 p.m.