predict.jags_analysis: Predict

Description Usage Arguments Details Value See Also

Description

Predict derived parameter from JAGS analysis. Level specifies the credibility intervals with or if level = "no" the function returns an object of class jags_samples

Usage

1
2
3
4
5
6
## S3 method for class 'jags_analysis'
predict(object, newdata = NULL, parm = "prediction",
  base = FALSE, values = NULL, model_id = default_model_id(object),
  modify_data_derived = NULL, derived_code = NULL, random_effects = NULL,
  select_data_derived = NULL, level = "current", estimate = "current",
  obs_by = FALSE, length_out = 50, ...)

Arguments

object

a jags_analysis object.

newdata

a data.frame or data list of the data values over which to calculate the estimates of the derived parameter or a character vector specify the variable or variable combination for which to calculate the estimates of the derived parameter. If NULL (the default) the derived parameter is calculated for each row in the original data set.

parm

a character scalar indicating the derived parameter for which the estimates should be calculated by default = "prediction"

base

a logical scalar indicating whether to express the expected value as a percent change of the base level or a data frame defining the base level.

values

NULL or a data frame with a single row that defines the value of particular variables. The variables in the arguments newdata and base are replaced by the corresponding values.

model_id

a count or string specifying the jags model to select.

modify_data_derived

a function to modify the derived data set (after it has been converted to list form)

derived_code

a character scalar defining a block in the JAGS dialect of the BUGS language that defines one or more derived parameters for each row of data. If NULL then derived_code is as defined by the JAGS model for which the JAGS analysis was performed.

random_effects

a named list which specifies which parameters to treat as random variables in the derived code. If NULL random_effects is as defined by the JAGS model for which the JAGS analysis was performed.

select_data_derived

a character vector of the variables to select from the data set being analysed (can also specify variables to transform and/or centre)

level

a numeric scalar specifying the significance level or a character scalar specifying which mode the level should be taken from. By default the level is as currently specified by opts_jagr in the global options. If level = "no" then the function returns a jags_sample object of the derived parameter.

estimate

a character scalar indicating whether the point estimate should be the "mean" or the "median". By default the estimate is as currently defined by opts_jagr in the global options.

obs_by

a logical scalar or a character vector indicating which variables to only predict for their observed combinations in the original. If obs_by = TRUE then newdata must be a character vector and the variables are taken to be those in newdata.

length_out

an integer scalar indicating the number of values when creating a sequence of values across the range of a continuous variable.

...

further arguments passed to or from other methods.

Details

Its important to realise that if the original data set was a data list then newdata must be a data list or NULL, base must be FALSE and values must be NULL. Otherwise if the original data set was a data frame then newdata cannot be a data list.

Its also important to realize that values always replaces the corresponding values in base but only replaces the corresponding values in newdata if they are unaltered, i.e., as they are in new_data(dataset(object)).

Value

the coef table for the derived parameter of interest or if level = "no" an object of class jags_samples

See Also

jags_model, jags_analysis, coef.jags_analysis and jaggernaut


poissonconsulting/jaggernaut documentation built on Feb. 18, 2021, 11:10 p.m.