addition-terms: Additional Response Information

Description Usage Arguments Details Value See Also Examples

Description

Provide additional information on the response variable in brms models, such as censoring, truncation, or known measurement error.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

Arguments

x

A vector; usually a variable defined in the data. Allowed values depend on the function: resp_se and resp_weights require positive numeric values. resp_trials, resp_thres, and resp_cat require positive integers. resp_dec requires 0 and 1, or alternatively 'lower' and 'upper'. resp_subset requires 0 and 1, or alternatively FALSE and TRUE. resp_cens requires 'left', 'none', 'right', and 'interval' (or equivalently -1, 0, 1, and 2) to indicate left, no, right, or interval censoring. resp_index does not make any requirements other than the value being unique for each observation.

sigma

Logical; Indicates whether the residual standard deviation parameter sigma should be included in addition to the known measurement error. Defaults to FALSE for backwards compatibility, but setting it to TRUE is usually the better choice.

scale

Logical; Indicates whether weights should be scaled so that the average weight equals one. Defaults to FALSE.

gr

A vector of grouping indicators.

y2

A vector specifying the upper bounds in interval censoring. Will be ignored for non-interval censored observations. However, it should NOT be NA even for non-interval censored observations to avoid accidental exclusion of these observations.

lb

A numeric vector or single numeric value specifying the lower truncation bound.

ub

A numeric vector or single numeric value specifying the upper truncation bound.

sdy

Optional known measurement error of the response treated as standard deviation. If specified, handles measurement error and (completely) missing values at the same time using the plausible-values-technique.

denom

A vector of positive numeric values specifying the denominator values from which the response rates are computed.

...

For resp_vreal, vectors of real values. For resp_vint, vectors of integer values. In Stan, these variables will be named vreal1, vreal2, ..., and vint1, vint2, ..., respectively.

Details

These functions are almost solely useful when called in formulas passed to the brms package. Within formulas, the resp_ prefix may be omitted. More information is given in the 'Details' section of brmsformula.

Value

A list of additional response information to be processed further by brms.

See Also

brm, brmsformula

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
## Not run: 
## Random effects meta-analysis
nstudies <- 20
true_effects <- rnorm(nstudies, 0.5, 0.2)
sei <- runif(nstudies, 0.05, 0.3)
outcomes <- rnorm(nstudies, true_effects, sei)
data1 <- data.frame(outcomes, sei)
fit1 <- brm(outcomes | se(sei, sigma = TRUE) ~ 1,
            data = data1)
summary(fit1)

## Probit regression using the binomial family
n <- sample(1:10, 100, TRUE)  # number of trials
success <- rbinom(100, size = n, prob = 0.4)
x <- rnorm(100)
data2 <- data.frame(n, success, x)
fit2 <- brm(success | trials(n) ~ x, data = data2,
            family = binomial("probit"))
summary(fit2)

## Survival regression modeling the time between the first 
## and second recurrence of an infection in kidney patients.
fit3 <- brm(time | cens(censored) ~ age * sex + disease + (1|patient), 
            data = kidney, family = lognormal())
summary(fit3)

## Poisson model with truncated counts  
fit4 <- brm(count | trunc(ub = 104) ~ zBase * Trt, 
            data = epilepsy, family = poisson())
summary(fit4)

## End(Not run)
  

brms documentation built on Aug. 23, 2021, 5:08 p.m.