extract_response_strata: Separates elements in a statistical formula

View source: R/extract_response_strata.R

extract_response_strataR Documentation

Separates elements in a statistical formula

Description

This function separates the response variable, the strata variable, and the covariates/predictors in a statistical formula.

Usage

extract_response_strata(f, covars = FALSE)

Arguments

f

⁠[formula]⁠
Formula for model fitting.

covars

⁠[logical(1)=FALSE]⁠
logical. If true, all the (other) covariates/explanatory variables in the formula are also appended to the output, separated from the response and strata variables.

Value

A list with strings representing the response variable (response), the stratum variable (strata), and possibly all explanatory variables (covars), if covars = TRUE, as shown in the formula.

Examples

# formula with strata
f <- formula(use ~ exp1 + exp2 + exp1:exp2 + strata(id))
extract_response_strata(f)
extract_response_strata(f, covars = TRUE)

# formula without strata
f2 <- formula(use ~ exp1 + exp2 + exp1:exp2)
extract_response_strata(f2, covars = TRUE)


NINAnor/oneimpact documentation built on June 14, 2025, 12:27 a.m.