forked from paul-buerkner/brms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddition-terms.Rd
116 lines (99 loc) · 3.5 KB
/
addition-terms.Rd
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/formula-helpers.R
\name{addition-terms}
\alias{addition-terms}
\alias{resp_se}
\alias{resp_weights}
\alias{resp_trials}
\alias{resp_cat}
\alias{resp_dec}
\alias{resp_cens}
\alias{resp_trunc}
\alias{resp_mi}
\title{Additional Response Information}
\usage{
resp_se(x, sigma = FALSE)
resp_weights(x, scale = FALSE)
resp_trials(x)
resp_cat(x)
resp_dec(x)
resp_cens(x, y2 = NULL)
resp_trunc(lb = -Inf, ub = Inf)
resp_mi(sdy = NULL)
}
\arguments{
\item{x}{A vector; usually a variable defined in the
data. Allowed values depend on the function:
\code{resp_se} and \code{resp_weights} require positive numeric values.
\code{resp_trials} and \code{resp_cat} require positive integers.
\code{resp_dec} requires \code{0} and \code{1}, or alternatively
\code{'lower'} and \code{'upper'};
\code{resp_cens} requires \code{'left'}, \code{'none'}, \code{'right'},
and \code{'interval'} (or equivalently \code{-1}, \code{0}, \code{1},
and \code{2}) to indicate left, no, right, or interval censoring.}
\item{sigma}{Logical; Indicates whether the residual standard deviation
parameter \code{sigma} should be included in addition to the known
measurement error. Defaults to \code{FALSE} for backwards compatibility,
but setting it to \code{TRUE} is usually the better choice.}
\item{scale}{Logical; Indicates whether weights should be scaled
so that the average weight equals one. Defaults to \code{FALSE}.}
\item{y2}{A vector specifying the upper bounds in interval censoring.}
\item{lb}{A numeric vector or single numeric value specifying
the lower truncation bound.}
\item{ub}{A numeric vector or single numeric value specifying
the upper truncation bound.}
\item{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.}
}
\value{
A vector containing additional information on the response
variable in an appropriate format.
}
\description{
Provide additional information on the response variable
in \pkg{brms} models, such as censoring, truncation, or
known measurement error.
}
\details{
These functions are almost solely useful when
called in formulas passed to the \pkg{brms} package.
Within formulas, the \code{resp_} prefix may be omitted.
More information is given in the 'Details' section
of \code{\link{brmsformula}}.
}
\examples{
\dontrun{
## 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) ~ log_Base4_c * Trt_c,
data = epilepsy, family = poisson())
summary(fit4)
}
}
\seealso{
\code{\link{brm}},
\code{\link{brmsformula}}
}