subgroup_effect: Calculation of covariable effects within each value of...

View source: R/group_effect.R

subgroup_effectR Documentation

Calculation of covariable effects within each value of another covariable that has interaction

Description

This function calculate the OR, CI, an p.value within each value of specified covariable.

Usage

subgroup_effect(
  formula,
  model,
  method = c("lik.ratio", "wald"),
  transpose = FALSE,
  stat_digits = 2,
  p_digits = 4,
  sstable = FALSE,
  flextable = FALSE,
  simplify = TRUE,
  ...
)

Arguments

formula

A formula in the the form of A + B ~ X, where

- X is the covariable to be concerned. X must be of type factor. - A, B are the covarables having interaction with X whose effects will be calculated. If . or blank. All covariables having interaction with X would be included.

model

A fitted glm model or a formula

method

a string whose value is either "lik.ratio" for CI and tests based on likelihood ratio statistics (preferred) or "wald" for CI and tests based on Wald statistics

transpose

logical value, default is FALSE, whether to return a transposed summary. See also t.subgroup_logist_summary

stat_digits

Number of decimal digits for statistics

p_digits

Number of decimal digits for the p-values

sstable

logical value specifying whether to return in sstable format. Default is FALSE. Set to TRUE forces verbose to FALSE

flextable

logical value specifying whether to build flextable object. Default it FALSE. Set to TRUE forces sstable to TRUE.

simplify

by default, if there is only one variable on each side of the formula and no LHS is a binary, then the function will combine tables in each state of X to one. Set to FALSE to avoid this behaviour.

...

additional parameters passed to glm to fit "model" (if model is a formula)

Value

Under certain circumstances defined in param simplify, a flextable, an sstable, a data.frame of class 'subgroup_logist_summary', or a 'subgroup_logist_summary'/list of logist_summary, each represents one state of X.

Author(s)

Trinh Dong Huu Khanh

See Also

logist_summary, print.subgroup_logist_summary, t.subgroup_logist_summary

Examples

y = sample(0:1, 1000, replace = T)
x1 = sample(1:100, 1000, replace = T)
x2 = sample(c("A", "B"), 1000, replace = T)
x3 = sample(c("C", "D", "E"), 1000, replace = T)
x4 = sample(c("F", "G"), 1000, replace = T)
fakefit = glm(y ~ x1*x3 + x2*x3 + x2*x4, family = binomial())
C306::subgroup_effect(~x3, fakefit)

oucru-biostats/C306 documentation built on July 16, 2024, 2:33 p.m.