View source: R/sensitivity_expected_values.R
compute_SensIAT_expected_values | R Documentation |
Compute Conditional Expected Values based on Outcome Model
compute_SensIAT_expected_values(
model,
alpha = 0,
new.data = model.frame(model),
...
)
## S3 method for class 'lm'
compute_SensIAT_expected_values(model, alpha, new.data, ...)
## S3 method for class 'glm'
compute_SensIAT_expected_values(
model,
alpha,
new.data,
...,
y.max = NULL,
eps = .Machine$double.eps
)
## S3 method for class 'negbin'
compute_SensIAT_expected_values(
model,
alpha,
new.data,
...,
y.max = NULL,
eps = .Machine$double.eps^(1/4)
)
model |
An object representing the output of the outcome model. |
alpha |
The sensitivity parameter |
new.data |
Data to compute conditional means for, defaults to the model frame for the fitted model. |
... |
passed onto methods. |
y.max |
The maximum value of the outcome variable for the Poisson and Negative Binomial models.
If omitted it is chosen from the quantile function for the distribution at |
eps |
The tolerance for the quantile function used to estimate |
Compute the conditional expectations needed for predictions in the models. Two additional values/expectations are computed:
$E \big[ Y(t) \exp \{ \alpha Y(t) \} | A(t)=1, \bar{O}(t) \big]$
, returned as E_Yexp_alphaY
, and
$E \big[ \exp \{ \alpha Y(t) \} \ | A(t)=1, \bar{O}(t) \big]$
, returned as E_exp_alphaY
.
For the methods shown here
The new.data
frame with additional columns alpha
, E_Yexp_alphaY
, and E_exp_alphaY
appended.
compute_SensIAT_expected_values(lm)
: (Gaussian) Linear Model method
The stats::integrate method is used to compute the conditional expectations.
compute_SensIAT_expected_values(glm)
: Generalized Linear Model method
compute_SensIAT_expected_values(negbin)
: Negative Binomial Model method
model <- lm(mpg ~ as.factor(cyl)+disp+wt, data=mtcars)
compute_SensIAT_expected_values(model, alpha= c(-0.3, 0, 0.3), new.data = mtcars[1:5, ])
model <- glm(cyl ~ mpg+disp+wt, data=mtcars, family=poisson())
compute_SensIAT_expected_values(model, alpha= c(-0.3, 0, 0.3), new.data = mtcars[1:5, ]) |>
dplyr::mutate('E(y|alpha)' = .data$E_Yexp_alphaY/.data$E_exp_alphaY)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.