Get the values from model weights
Returns weighting variable of a model.
get_weights(x, ...) ## Default S3 method: get_weights(x, na_rm = FALSE, null_as_ones = FALSE, ...)
x |
A fitted model. |
... |
Currently not used. |
na_rm |
Logical, if |
null_as_ones |
Logical, if |
The weighting variable, or NULL
if no weights were specified
or if weights were 1. If the weighting variable should also be returned
(instead of NULL
), when all weights are set to 1 (i.e. no weighting),
set null_as_ones = TRUE
.
data(mtcars) set.seed(123) mtcars$weight <- rnorm(nrow(mtcars), 1, .3) # LMs m <- lm(mpg ~ wt + cyl + vs, data = mtcars, weights = weight) get_weights(m) get_weights(lm(mpg ~ wt, data = mtcars), null_as_ones = TRUE) # GLMs m <- glm(vs ~ disp + mpg, data = mtcars, weights = weight, family = quasibinomial) get_weights(m) m <- glm(cbind(cyl, gear) ~ mpg, data = mtcars, weights = weight, family = binomial) get_weights(m)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.