assigned | R Documentation |
When passing a lm
object to lmitt()
, extract and use
the treatment variable specified in the StudySpecification
.
assigned(specification = NULL, data = NULL, dichotomy = NULL)
adopters(specification = NULL, data = NULL, dichotomy = NULL)
a.(specification = NULL, data = NULL, dichotomy = NULL)
z.(specification = NULL, data = NULL, dichotomy = NULL)
specification |
Optional |
data |
Optional data set. By default |
dichotomy |
optional; a formula defining the dichotomy of the treatment
variable if it isn't already |
When passing a lm
object to lmitt()
, the treatment
variable in the formula
passed to lm()
needs to be identifiable.
Rather than placing the treatment variable directly in the formula
,
use one of these functions, to allow lmitt()
to identify the treatment
variable.
To keep the formula in the lm()
call concise, instead of passing
specification
and data
arguments to these functions, one can
pass a WeightedStudySpecification
object to the weights
argument of the lm()
call or a SandwichLayer
object to the
offset
argument.
Alternatively, you can pass the specification
and data
arguments.
While assigned()
can be used in any situation, it is most useful
for scenarios where the treatment variable is non-binary and the
StudySpecification
contains a Dichotomy
. For example, say
q
is a 3-level ordinal treatment variable, and the binary
comparison of interest is captured in dichotomy = q == 3 ~ q < 3
.
If you were to fit a model including q
as a predictor, e.g.
lm(y ~ q, ...)
, lm
would treat q
as the full ordinal
variable. On the other hand, by calling lm(y ~ assigned(), weights =
ate(spec), ...)
, assigned()
will generate the appropriate binary
variable to allow estimation of treatment effects.
If called outside of a model call and without a data
argument, this
will extract the treatment from the specification
. If this is the
goal, the treatment()
function is better suited for this purpose.
The treatment variable to be placed in the regression formula.
data(simdata)
spec <- obs_spec(z ~ uoa(uoa1, uoa2), data = simdata)
mod <- lm(y ~ assigned(), data = simdata, weights = ate(spec))
lmittmod <- lmitt(mod)
summary(lmittmod, vcov.type = "CR0")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.