# credsubs.level: Compute the maximum credible levels at which conclusions may... In credsubs: Credible Subsets

## Description

For each covariate point, `credsubs.level` computes the maximum credible level at which a conclusion may be drawn at each point, and what that conclusion is.

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15``` ```credsubs.level( params, design = NULL, FUN = function(x, params) { params %*% t(x) }, threshold = 0, method = c("asymptotic", "quantile"), step.down = TRUE, sides = c("both", "exclusive", "inclusive"), est.FUN = mean, var.FUN = sd, point.estimate = NULL, track = numeric(0), verbose = FALSE, z.store = c("ram", "recompute", "disk") ) ```

## Arguments

 `params` A numeric matrix whose rows are draws from the posterior distribution of either the regression surface or the parameter vector. `design` (Optional) A numeric matrix whose rows are covariate points over which the band is to be constructed. `FUN` (Optional) a function of the form `function(x, params)` that takes a row of `design` and the entire `params` matrix and returns a vector of the same length of `x` representing the regression surface. `threshold` Numeric; the value of `FUN` above which a covariate is included in the target subset. `method` Either "asymptotic" (default) or "quantile"; see details. `step.down` Logical (default `TRUE`); should the step-down procedure be used? `sides` One of "both" (default), "exclusive", or "inclusive". Which bounds should be constructed? `est.FUN` The function used to produce estimates of the regression surface. Default is `mean`. `var.FUN` The function used to quantify the variability of the regression surface posterior. Default is `sd`. `point.estimate` If not null, replaces the mean and sets the reference around which the standard error is computed. Useful for bootstrapping methods. Treated as a row of the `params` matrix. `track` A numeric vector of indices indicating which rows (default none) of the design matrix should have the sample of the corresponding `FUN(x, params)` returned. `verbose` Logical (default `FALSE`); print progress? `z.store` How should certain intermediate computations be handled? See details.

## Details

If design is NULL (default), it is taken to be the identity matrix of dimension ncol(params), so that the rows of params are treated as draws from the posterior FUN(x, params).

The 'asymptotic' method assumes that the marginal posteriors of the FUN(x, params) are asymptotically normal and is usually significantly faster and less memory-intensive than the 'quantile' method, which makes no such assumption.

By default (`z.store = "ram"`), the maximum credible level computation stores a potentially very large amount of intermediate computation results in memory. If not enough memory is available, `z.store = "disk"` uses the `ff` package to store the intermediate results on disk, which can still be fairly quick if the storage is fast (e.g. a local SSD). Alternatively, `z.store = "recompute"` discards the intermediate results and recomputes whenever needed. This uses minimal memory, but is usually the slowest option.

## Value

An object of class `credsubs.level`, which contains:

`level`

A numeric vector indicating the maximum credible level at which a conclusion may be drawn at each covariate point.

`sign`

A numeric vector indicating the which credible subsets of which each covariate point is a member at the credible level indicated by `level`. Exclusive and inclusive: 1, inclusive only: 0, neither: -1.

`threshold`

As provided.

`method`

As provided.

`step.down`

As provided.

`sides`

As provided.

`est`

Posterior estimate of the regression surface.

`est.FUN`

As provided.

`var`

Summary of posterior variability of the regression surface.

`var.FUN`

As provided.

`trace`

The posterior samples of the regression surface indicated by the `track` argument.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13``` ```### Sample from regression surface posterior reg.surf.sample <- matrix(rnorm(1000, mean=1:10), ncol=2, byrow=TRUE) credsubs.level(reg.surf.sample) ### Parametric case design <- cbind(1, 1:10) params <- matrix(rnorm(200, mean=1:2), ncol=2, byrow=TRUE) credsubs(params, design) ### With custom function params.sd <- cbind(1 / rgamma(100, 1), params) FUN.sd <- function(x, params) { params[, -1] %*% t(x) / params[, 1] } credsubs(params.sd, design, FUN.sd, threshold=1) ```

credsubs documentation built on Sept. 1, 2020, 5:07 p.m.