Removing (influential) cases from fitted svyglm model

Viewed 27

I am running a logistic regression model using complex survey data using the survey package in R. After fitting the model, I performed regression diagnostics using the car package. I noticed outlying and influential observations that I would like to remove and then refit the model to check for their effects on the regression coefficients but my current approach is not giving me want I expect.

My dataset has about 10,000 observations. Here is sample data and code I have tried using:

library(car); library(survey)
dat <- structure(list(id = c(1009918, 1012826, 1029625, 1000926, 1027525, 
1000115, 1000201, 1000202, 1000214, 1000219, 1000313, 1000324, 
1000510, 1000521, 1000624, 1000708, 1000811, 1000817, 1000818, 
1000906, 1000922, 1001002, 1001005, 1001401, 1001411, 1001413, 
1001420, 1001424, 1001501, 1001510, 1001518, 1001526, 1001621, 
1001807, 1001922, 1001926, 1002106, 1002217, 1002406, 1002416, 
1002618, 1002709, 1003004, 1003017, 1003103, 1003108, 1003304, 
1003319, 1003723, 1003804, 1003811, 1003819, 1004014, 1008902, 
1008913, 1009011, 1009022, 1009123, 1009212, 1009215), strata = c(1, 
2, 6, 1, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), cluster = c(785, 
938, 2337, 28, 2122, 3, 6, 6, 6, 6, 10, 10, 16, 16, 19, 22, 24, 
24, 24, 28, 28, 33, 33, 45, 45, 45, 45, 45, 50, 50, 50, 50, 53, 
60, 63, 63, 69, 74, 96, 96, 100, 102, 111, 111, 115, 115, 122, 
122, 178, 193, 193, 193, 210, 755, 755, 759, 759, 762, 765, 765
), weights = c(621.921704979739, 5440.9107594311, 8450.49341643626, 
2457.37241774248, 7174.79930450487, 930.492019594546, 443.253676607562, 
443.253676607562, 886.507353215123, 443.253676607562, 1552.30979801343, 
517.436599337811, 403.146111343943, 806.292222687886, 439.775494378883, 
839.561001668328, 1210.77101540146, 403.590338467152, 403.590338467152, 
457.23211170669, 914.464223413381, 584.557580338056, 584.557580338056, 
233.135312658304, 233.135312658304, 233.135312658304, 466.270625316608, 
233.135312658304, 287.94933168791, 287.94933168791, 287.94933168791, 
287.94933168791, 2354.32022397843, 213.628591090648, 300.596873749779, 
300.596873749779, 1121.27419052962, 528.482361549292, 1936.60489456861, 
1291.06992971241, 282.360930726457, 3526.73915258957, 337.531162185852, 
337.531162185852, 2183.63202546241, 2729.54003182802, 1035.32340123929, 
1552.98510185893, 1400.62601417017, 717.92144006312, 358.96072003156, 
1435.84288012624, 275.058410167952, 557.874242565598, 278.937121282799, 
1687.48015279064, 1012.48809167438, 424.663883556537, 227.805527040477, 
227.805527040477), age = c(20, 19, 93, 24, 18, 23, 22, 23, 24, 
19, 18, 24, 20, 19, 18, 17, 19, 23, 19, 19, 21, 22, 21, 20, 23, 
24, 24, 19, 21, 22, 20, 23, 21, 23, 20, 22, 23, 15, 20, 23, 24, 
18, 24, 24, 15, 21, 24, 16, 22, 20, 20, 18, 21, 20, 21, 21, 24, 
22, 24, 18), gender = structure(c(1L, 1L, 1L, 2L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L), levels = c("Male", "Female"), class = "factor"), 
    educ = structure(c(4L, 2L, 1L, 3L, 2L, 3L, 2L, 2L, 2L, 2L, 
    3L, 2L, 3L, 2L, 3L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 
    3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 3L, 3L, 2L, 4L, 2L, 3L, 2L, 
    4L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 3L, 2L, 3L, 2L, 
    4L, 4L, 4L, 3L, 3L), levels = c("No formal education", "Primary", 
    "Secondary", "Tertiary"), class = "factor"), employ = structure(c(4L, 
    3L, 4L, 2L, 3L, 3L, 3L, 3L, 2L, 3L, 4L, 3L, 2L, 2L, 2L, 4L, 
    3L, 3L, 3L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 2L, 4L, 4L, 4L, 4L, 
    4L, 4L, 2L, 3L, 3L, 1L, 3L, 2L, 3L, 3L, 4L, 3L, 2L, 4L, 4L, 
    2L, 3L, 1L, 2L, 3L, 3L, 2L, 2L, 2L, 2L, 1L, 4L, 3L, 4L), levels = c("Unemployed", 
    "Employed", "Self-employed", "Other"), class = "factor"), 
    know = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 2L, 2L), levels = c("No/Don't know", "Yes"), class = "factor"), 
    status = structure(c(2L, 4L, 2L, 1L, 5L, 3L, 2L, 2L, 2L, 
    4L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 5L, 2L, 
    2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 5L, 4L, 2L, 5L, 5L, 4L, 3L, 
    2L, 3L, 2L, 2L, 2L, 2L, 4L, 3L, 3L, 4L, 3L, 2L, 2L, 3L, 1L, 
    2L, 1L, 1L, 2L, 2L, 2L), levels = c("1", "2", "3", "4", "5"
    ), class = "factor"), smoker = structure(c(2L, 2L, 2L, 2L, 
    2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), levels = c("no", 
    "yes"), class = "factor")), row.names = c(81L, 4174L, 6722L, 
1255L, 2712L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 
26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 
39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 
52L, 53L, 54L, 55L), class = "data.frame")

## Create survey design object
dat_svy <- survey::svydesign(ids = ~cluster, strat = ~strata, weights = ~weights, data = dat, nest = TRUE)

options(survey.lonely.psu = "adjust")

## fit logistic regression model
mod <- survey::svyglm(formula = smoker ~ age + educ + gender + employ + educ + know + status, design = dat_svy, family = "quasibinomial")

I have tried the following:

update(mod, subset = !(rownames(dat_svy) %in% c(2, 5, 9, 13, 21))) # returns an error
update(mod, subset = -c(2, 5, 9, 13, 21)) # only removes one (first specified) observation
0 Answers
Related