submarg: Return subgroup margins

Description Usage Arguments Examples

View source: R/marg.R

Description

Calculates subgroup margins by running on subset of data. Doesn't matter for OLS but does matter, e.g., for logit.

Usage

1
2
3
4
5
6
7
8
submarg(
  mod,
  subgrp_var,
  treat_var = "treatment",
  mod_df = mod$data,
  weight = mod$prior.weights,
  ...
)

Arguments

mod

glm

subgrp_var

Subgroup variable, character. The subgroup variable must be a categorical variable

treat_var

Treatment variable, character

mod_df

Dataframe used to estimate model, defaults to mod$data

weight

Weight parameter to pass to 'modmarg::marg', defaults to mod$prior.weights

...

Other parameters passed to modmarg::marg

Examples

1
2
3
4
library(modmarg)
data(margex)
mod <- glm(outcome ~ treatment * yc + distance, data = margex, family = 'binomial')
submarg(mod, 'yc', 'treatment')

anniejw6/testingtools documentation built on Jan. 26, 2021, 6:41 a.m.