Description Usage Arguments Value See Also
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.
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, ...)
|
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 |
xcol |
Chareacter string giving the name of a column in |
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".
|
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 ( |
The return value is a list with several components:
resid: A 2D array with the entire chain of the error parameters, from Gibbs sampler
fullparam: A 2D array with the entire chain of model parameters from the Gibbs sampler
burn: Atomic, the number of steps discarded as burn-in before calculated statistics from Gibbs sampler
steps: Atomic, the number of steps run in Gibbs sampler
llike: Full log-likelihood of the model at each step of the Gibbs'sampler
obs: The original y (dependent) variable, just as submitted
data: The original x (independent) variables, just as submitted
parnames: The names of the model parameters
start: The start parameters submitted
best: Best estimate of the model parameters for the entire data
CI: Credible intervals for the model parameters
bestresid: The best estimate of parameters for the error model
CIresid: Credible intervals for the parameters of the error model
pred: A dataframe with all observations, predictors, and the model's best prediction, mean prediction, and credible intervals at each point
many: A 2D array holding N draws of the model's prediction at each sampling point; N is either the number of post-burn-in steps, or 1000, whichever is greater
keep: The steps of the Gibbs sampler after burn-in, as a vector of negative numbers
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.