top of page

[R Coding] Modified version of drop1 function for change-in-estimate method using the glm function a

The change-in-estimate method (CIE) is a well established method for selecting confounding variables to include in a regression model. Confounders bias estimates of exposure effect and, in short, to identify a confounder (C) we calculate two estimates of the effect of exposure on the outcome, one which is adjusted for the C and the other we don't. If the two estimates differ, we conclude that C is in fact a confounder.

The function dropCIE.R was developed to use with the glm function in R and the logit link function to help select a "final" model via CIE of the odds ratio (OR) for some set tolerance using an all-possible-models manual backwards selection procedure. Input for the code is as follows:

  1. model: a fitted object model, i.e. the full model where all potential confounders for the final regression model are included.

  2. beta: a single numeric value representing the coefficient, i.g. log(OR), of the exposure/variable of interest.

  3. coefnum: a single numeric value representing the beta coefficient number, e.g. for the model logit(p) = beta_0 + beta_1 x the position for beta_1 is 2 since the intercept is in the first position.

  4. varlist: a character string with the names of all potential confounder in the model - the exposure/variable of interest should not be included in this list.

  5. factor: a value to scale the exposure variable by, e.g. if the exposure variable is ordinal and you want to apply CIE for the highest level that is not 1 (default: factor = 1).

  6. tol: a numeric value representing the tolerance for how much change in the OR must occur to be considered a confounder in the final model (default: tol = 0.10).

Assuming there are k confounders, the program will start with the full model and drop one variable from varlist at a time and calculate the CIE when dropped. The variable with the smallest CIE will be removed from varlist an the program will output what the CIE was. The program will then start the sequence again but using k-1 confounders and then drop the next smallest CIE and output its respective value. This will continue until the smallest CIE is larger than the set tolerance. Once the final model is selected, it will automatically be saved into a new object with the same name as the inputted model but with a suffix "u" added to the end.

Example:

> varlist <- c('BMI', 'Age', 'Menopausal', 'SmkPkYrs')

> model <- glm(Status ~ Exp + BMI + Age + Menopausal + SmkPkYrs,

> family='binomial', data=CC)

> beta <- 0.113

> coefnum <- 2

> dropCIE(model,beta,coefnum,varlist)

Drop 1: Menopausal (0.03)

Drop 2: SmkPkYrs (0.06)

Final model

Estimate Std. Error z value Pr(>|z|)

(Intercept) 0.122976296 0.278522093 0.4415316 6.588282e-01

Exp: Ever 0.109703685 0.095749303 1.1457387 2.519033e-01

Age 0.002026979 0.004364574 0.4644163 6.423495e-01

Updated model saved as: modelu

Recent Posts
Archive
Search By Tags
No tags yet.
bottom of page