Skip to contents

Extract residuals from synthdid object

Usage

# S3 method for class 'synthdid'
residuals(object, type = c("control", "pretreatment", "all"), ...)

Arguments

object

A synthdid object

type

Type of residuals: "control" (default), "pretreatment", or "all"

...

Additional arguments (currently ignored)

Value

A matrix of residuals

Examples

# \donttest{
data(california_prop99)
result <- synthdid(PacksPerCapita ~ treated,
  data = california_prop99,
  index = c("State", "Year")
)
resid_control <- residuals(result, type = "control")
resid_pretreat <- residuals(result, type = "pretreatment")
head(resid_control)
#>                  1970      1971       1972       1973       1974       1975
#> Alabama     -52.08595 -49.80280 -48.727474 -46.223224 -41.993653 -38.716411
#> Arkansas    -41.58595 -41.10280 -45.927471 -41.123226 -40.493653 -35.616405
#> Colorado    -17.08595 -19.70280 -15.527469 -11.223232 -17.393647 -19.416408
#> Connecticut -21.88595 -27.60280 -39.027469 -39.823223 -37.793649 -40.216411
#> Delaware     13.11405  15.89721   6.472531   5.576771   1.106353  -2.816402
#> Georgia     -31.98595 -29.50280 -32.827472 -29.323223 -26.493653 -27.516407
#>                   1976        1977       1978       1979       1980       1981
#> Alabama     -38.534712 -35.4026082 -27.798003 -25.520137 -22.169570 -25.063926
#> Arkansas    -35.634710 -29.9026082 -23.498000 -20.420139 -13.569563 -15.963927
#> Colorado    -20.534712 -20.5026067 -21.598006 -15.420139 -14.369566 -10.863921
#> Connecticut -41.334707 -35.2026036 -33.298003 -29.520137 -27.369566 -28.263923
#> Delaware     -1.734709   0.7973964   4.701997   3.279858   5.130434   7.936082
#> Georgia     -28.834707 -24.6026052 -20.197997 -15.920139 -11.369566 -12.963927
#>                  1982       1983       1984       1985       1986        1987
#> Alabama     -22.68200 -20.760191 -16.100655 -12.682956  -7.635973  -8.6642390
#> Arkansas    -14.38199  -9.060194  -6.000656  -1.382953   2.064024  -0.3642359
#> Colorado    -11.28199 -11.760191  -9.400658 -14.782954 -14.035974 -20.2642375
#> Connecticut -27.08200 -22.960196 -16.600655 -16.182956 -15.435976 -13.6642390
#> Delaware     12.31801  12.539812  14.899345  17.317044  18.464018  18.3357610
#> Georgia     -10.58200  -8.460188  -2.800652   1.617047   5.064024   6.6357641
#>                   1988       1989       1990       1991       1992       1993
#> Alabama      -4.401398  -6.997396   1.121768   5.194038   7.828461   7.202115
#> Arkansas      4.998603   5.702609   5.621768  14.094040  24.728462  12.502118
#> Colorado    -21.901398 -23.797391 -20.078229 -12.505967 -12.971535 -12.697887
#> Connecticut -11.701393 -11.997396 -15.978230 -16.005967 -17.771538 -22.197887
#> Delaware     20.598610  19.102603  19.721766  16.094040  18.728462  22.502118
#> Georgia       7.598602   4.502604   6.321773   6.894035   7.928459   7.902112
#>                   1994       1995       1996        1997         1998
#> Alabama       7.041354   1.941808   2.197444   4.8640665   5.76600412
#> Arkansas      8.741359  12.341810  11.497440   8.6640619   9.06600722
#> Colorado    -10.958646 -15.258189 -16.102559 -18.7359320 -19.23399583
#> Connecticut -23.458646 -21.358187 -23.202557 -24.1359335 -24.93399278
#> Delaware     26.041354  26.541807  29.097446  24.0640635  32.36601032
#> Georgia       7.741359  -0.358187   3.497440   0.5640635   0.06600722
#>                   1999       2000
#> Alabama       2.202651   4.762696
#> Arkansas      6.302657   7.962701
#> Colorado    -18.897348 -18.437300
#> Connecticut -25.097345 -20.037299
#> Delaware     41.002654  49.262696
#> Georgia      -1.397348  -3.037299
# }