View source: R/postestimation.R
| margins | R Documentation |
Calculates average adjusted predictions and confidence intervals from the active or supplied model.
margins(model = NULL,
at = NULL,
over = NULL,
type = c("response",
"link"),
atmeans = FALSE,
level = 0.95,
digits = 3,
p_digits = 3,
show = TRUE,
console = FALSE)
model |
Optional fitted model or R4VN model result. The most recently fitted R4VN model is used when omitted. |
at |
Predictor settings created by |
over |
Optional grouping variable(s), including |
type |
Response-scale or link-scale predictions. |
atmeans |
If TRUE, unspecified covariates are fixed at representative means/modes instead of averaging individual predictions. |
level |
Confidence level. |
digits, p_digits |
Formatting digits. |
show, console |
R4VN display controls. |
Unless atmeans = TRUE, variables not specified in at() retain their observed values and predictions are averaged over the estimation sample. Standard errors use the fitted covariance matrix and a delta-method gradient when the model provides the information required.
An R4VN result object, invisibly.
at, marginsplot, predict, lincom
d <- data.frame(
outcome = factor(c(0, 0, 0, 1, 0, 1, 1, 1), levels = 0:1,
labels = c("No", "Yes")),
age = c(20, 25, 30, 35, 40, 45, 50, 55),
sex = factor(rep(c("Female", "Male"), 4))
)
m <- logistic(outcome, c.age, i.sex, data = d, event = "Yes", show = FALSE)
margins(m, at = at(age = 40), show = FALSE)
margins(m, over = sex, show = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.