Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

model_get_weights

Get sampling weights used by a model


Description

This function does not cover lavaan models (NULL is returned).

Usage

model_get_weights(model)

## Default S3 method:
model_get_weights(model)

## S3 method for class 'svyglm'
model_get_weights(model)

Arguments

model

a model object

See Also

Examples

mod <- lm(Sepal.Length ~ Sepal.Width, iris)
mod %>% model_get_weights()

mod <- lm(hp ~ mpg + factor(cyl) + disp:hp, mtcars, weights = mtcars$gear)
mod %>% model_get_weights()

mod <- glm(
  response ~ stage * grade + trt,
  gtsummary::trial,
  family = binomial
)
mod %>% model_get_weights()

mod <- glm(
  Survived ~ Class * Age + Sex,
  data = Titanic %>% as.data.frame(),
  weights = Freq,
  family = binomial
)
mod %>% model_get_weights()

d <- dplyr::as_tibble(Titanic) %>%
  dplyr::group_by(Class, Sex, Age) %>%
  dplyr::summarise(
    n_survived = sum(n * (Survived == "Yes")),
    n_dead = sum(n * (Survived == "No"))
  )
mod <- glm(cbind(n_survived, n_dead) ~ Class * Age + Sex, data = d, family = binomial)
mod %>% model_get_weights()

broom.helpers

Helpers for Model Coefficients Tibbles

v1.3.0
GPL-3
Authors
Joseph Larmarange [aut, cre] (<https://orcid.org/0000-0001-7097-700X>), Daniel D. Sjoberg [aut] (<https://orcid.org/0000-0003-0862-2018>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.