-------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  /Users/seanfahle/Dropbox/BequestModel/REStud/REStudPublication/SSG_Code_REStud/Stata/Code/../Output/logs/APPENDIX_H_STATISTICS
> .txt
  log type:  text
 opened on:  30 Jun 2022, 16:54:28

. 
. preserve

. 
. keep if (fullWlthHist4==1) // -> balanced panel
(7,496 observations deleted)

. keep if (xnriw<=4)
(6,870 observations deleted)

. 
. by hhidpn: egen own_0 = max(cond(xnriw==0,ownHist,.))

. by hhidpn: egen own_1 = max(cond(xnriw==1,ownHist,.))
(120 missing values generated)

. by hhidpn: egen own_2 = max(cond(xnriw==2,ownHist,.))
(150 missing values generated)

. by hhidpn: egen own_3 = max(cond(xnriw==3,ownHist,.))
(140 missing values generated)

. by hhidpn: egen own_4 = max(cond(xnriw==4,ownHist,.))
(115 missing values generated)

. 
. gen keep_43 = (own_4==1 & own_3==1)

. gen sell_43 = (own_4==1 & own_3==0)

. gen rent_43 = (own_4==0 & own_3==0)

. 
. gen keep_32 = (own_3==1 & own_2==1)

. gen sell_32 = (own_3==1 & own_2==0)

. gen rent_32 = (own_3==0 & own_2==0)

. 
. gen keep_21 = (own_2==1 & own_1==1)

. gen sell_21 = (own_2==1 & own_1==0)

. gen rent_21 = (own_2==0 & own_1==0)

. 
. gen keep_10 = (own_1==1 & own_0==1)

. gen sell_10 = (own_1==1 & own_0==0)

. gen rent_10 = (own_1==0 & own_0==0)

. 
. gen post_sell = .
(11,450 missing values generated)

. replace post_sell = 1 if (xnriw==3 & sell_43==1)
(163 real changes made)

. replace post_sell = 1 if (xnriw==2 & sell_32==1)
(191 real changes made)

. replace post_sell = 1 if (xnriw==1 & sell_21==1)
(227 real changes made)

. replace post_sell = 1 if (xnriw==0 & sell_10==1)
(160 real changes made)

. // identify wave after selling
. 
. gen pre_sell = .
(11,450 missing values generated)

. replace pre_sell = 1 if (xnriw==4 & sell_43==1)
(163 real changes made)

. replace pre_sell = 1 if (xnriw==3 & sell_32==1)
(191 real changes made)

. replace pre_sell = 1 if (xnriw==2 & sell_21==1)
(227 real changes made)

. replace pre_sell = 1 if (xnriw==1 & sell_10==1)
(160 real changes made)

. // identify wave after selling
. 
. tab pre_sell

   pre_sell |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |        741      100.00      100.00
------------+-----------------------------------
      Total |        741      100.00

. tab post_sell

  post_sell |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |        741      100.00      100.00
------------+-----------------------------------
      Total |        741      100.00

. // same numbers of obs
. 
. tabstat wlthhist [aw=crwtall] if pre_sell ==1, c(s) s(n p50) f(%5.0fc)

    variable |         N       p50
-------------+--------------------
    wlthhist |       737       139
----------------------------------

. tabstat wlthhist [aw=crwtall] if post_sell==1, c(s) s(n p50) f(%5.0fc)

    variable |         N       p50
-------------+--------------------
    wlthhist |       739        23
----------------------------------

. // weights lead #s of obs to be different b/c some have zero weight
. 
. // Median wealth pre  liquidation in waves T-4 to T-1 is 139K.
. // Median wealth post liquidation in waves T-3 to T-0 is  23K.
. 
. // Change in medians is 139-23 = 116K.
. 
. // This is the change we wish to explain.
. 
. // NOTE: This is not the same thing as the median change in wealth.
. 
. * change in net worth
. gen wlthhistDiff = (wlthhist - cL1wlthhist) 
(636 missing values generated)

. // note: not annualized
. // note: difference uses carried forward, lagged wealth history
. 
. tabstat wlthhistDiff [aw=crwtall] if post_sell==1, c(s) s(n p50) f(%5.0fc)

    variable |         N       p50
-------------+--------------------
wlthhistDiff |       739       -67
----------------------------------

. 
. // Median change in wealth when selling is -67K.
. 
. **********
. ** Comparing those who entered an NH versus remained in the community
. **********
. 
. by hhidpn: egen nhr_0 = max(cond(xnriw==0,rnhmliv,.))

. by hhidpn: egen nhr_1 = max(cond(xnriw==1,rnhmliv,.))

. by hhidpn: egen nhr_2 = max(cond(xnriw==2,rnhmliv,.))

. by hhidpn: egen nhr_3 = max(cond(xnriw==3,rnhmliv,.))

. by hhidpn: egen nhr_4 = max(cond(xnriw==4,rnhmliv,.))

. 
. ** Stay NH, enter NH, remain in the community
. 
. gen stay_43 = (nhr_4==1 & nhr_3==1) // stay: nh resident both periods

. gen entr_43 = (nhr_4==0 & nhr_3==1) // entr: nh resident in 2nd period only

. gen cmty_43 = (nhr_4==0 & nhr_3==0) // cmty: community resident in both periods

. 
. gen stay_32 = (nhr_3==1 & nhr_2==1)

. gen entr_32 = (nhr_3==0 & nhr_2==1)

. gen cmty_32 = (nhr_3==0 & nhr_2==0)

. 
. gen stay_21 = (nhr_2==1 & nhr_1==1)

. gen entr_21 = (nhr_2==0 & nhr_1==1)

. gen cmty_21 = (nhr_2==0 & nhr_1==0)

. 
. gen stay_10 = (nhr_1==1 & nhr_0==1)

. gen entr_10 = (nhr_1==0 & nhr_0==1)

. gen cmty_10 = (nhr_1==0 & nhr_0==0)

. 
. // Liquidators who are NH residents pre- and post-liquidation
. gen stay_post_sell = .
(11,450 missing values generated)

. replace stay_post_sell = 1 if (xnriw==3 & sell_43==1 & stay_43==1)
(7 real changes made)

. replace stay_post_sell = 1 if (xnriw==2 & sell_32==1 & stay_32==1)
(13 real changes made)

. replace stay_post_sell = 1 if (xnriw==1 & sell_21==1 & stay_21==1)
(17 real changes made)

. replace stay_post_sell = 1 if (xnriw==0 & sell_10==1 & stay_10==1)
(27 real changes made)

. // identify wave before selling
. 
. gen stay_pre_sell = .
(11,450 missing values generated)

. replace stay_pre_sell = 1 if (xnriw==4 & sell_43==1 & stay_43==1)
(7 real changes made)

. replace stay_pre_sell = 1 if (xnriw==3 & sell_32==1 & stay_32==1)
(13 real changes made)

. replace stay_pre_sell = 1 if (xnriw==2 & sell_21==1 & stay_21==1)
(17 real changes made)

. replace stay_pre_sell = 1 if (xnriw==1 & sell_10==1 & stay_10==1)
(27 real changes made)

. // identify wave after selling
. 
. // Liquidators who are enter NH residents post-liquidation
. gen entr_post_sell = .
(11,450 missing values generated)

. replace entr_post_sell = 1 if (xnriw==3 & sell_43==1 & entr_43==1)
(24 real changes made)

. replace entr_post_sell = 1 if (xnriw==2 & sell_32==1 & entr_32==1)
(42 real changes made)

. replace entr_post_sell = 1 if (xnriw==1 & sell_21==1 & entr_21==1)
(65 real changes made)

. replace entr_post_sell = 1 if (xnriw==0 & sell_10==1 & entr_10==1)
(51 real changes made)

. // identify wave before selling
. 
. gen entr_pre_sell = .
(11,450 missing values generated)

. replace entr_pre_sell = 1 if (xnriw==4 & sell_43==1 & entr_43==1)
(24 real changes made)

. replace entr_pre_sell = 1 if (xnriw==3 & sell_32==1 & entr_32==1)
(42 real changes made)

. replace entr_pre_sell = 1 if (xnriw==2 & sell_21==1 & entr_21==1)
(65 real changes made)

. replace entr_pre_sell = 1 if (xnriw==1 & sell_10==1 & entr_10==1)
(51 real changes made)

. // identify wave after selling
. 
. // Liquidators who are community residents before and after liquidation
. gen cmty_post_sell = .
(11,450 missing values generated)

. replace cmty_post_sell = 1 if (xnriw==3 & sell_43==1 & cmty_43==1)
(130 real changes made)

. replace cmty_post_sell = 1 if (xnriw==2 & sell_32==1 & cmty_32==1)
(136 real changes made)

. replace cmty_post_sell = 1 if (xnriw==1 & sell_21==1 & cmty_21==1)
(140 real changes made)

. replace cmty_post_sell = 1 if (xnriw==0 & sell_10==1 & cmty_10==1)
(79 real changes made)

. // identify wave before selling
. 
. gen cmty_pre_sell = .
(11,450 missing values generated)

. replace cmty_pre_sell = 1 if (xnriw==4 & sell_43==1 & cmty_43==1)
(130 real changes made)

. replace cmty_pre_sell = 1 if (xnriw==3 & sell_32==1 & cmty_32==1)
(136 real changes made)

. replace cmty_pre_sell = 1 if (xnriw==2 & sell_21==1 & cmty_21==1)
(140 real changes made)

. replace cmty_pre_sell = 1 if (xnriw==1 & sell_10==1 & cmty_10==1)
(79 real changes made)

. // identify wave after selling
. 
. tab stay_pre_sell

stay_pre_se |
         ll |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |         64      100.00      100.00
------------+-----------------------------------
      Total |         64      100.00

. tab stay_post_sell

stay_post_s |
        ell |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |         64      100.00      100.00
------------+-----------------------------------
      Total |         64      100.00

. // same numbers of obs
. 
. tab entr_pre_sell

entr_pre_se |
         ll |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |        182      100.00      100.00
------------+-----------------------------------
      Total |        182      100.00

. tab entr_post_sell

entr_post_s |
        ell |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |        182      100.00      100.00
------------+-----------------------------------
      Total |        182      100.00

. // same numbers of obs
. 
. tab cmty_pre_sell

cmty_pre_se |
         ll |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |        485      100.00      100.00
------------+-----------------------------------
      Total |        485      100.00

. tab cmty_post_sell

cmty_post_s |
        ell |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |        485      100.00      100.00
------------+-----------------------------------
      Total |        485      100.00

. // same numbers of obs
. 
. // stay NH
. tabstat wlthhist [aw=crwtall] if stay_pre_sell ==1, c(s) s(n p50) f(%5.0fc)

    variable |         N       p50
-------------+--------------------
    wlthhist |        63       126
----------------------------------

. tabstat wlthhist [aw=crwtall] if stay_post_sell==1, c(s) s(n p50) f(%5.0fc)

    variable |         N       p50
-------------+--------------------
    wlthhist |        64        21
----------------------------------

. // weights lead #s of obs to be different b/c some have zero weight
. 
. // enter NH
. tabstat wlthhist [aw=crwtall] if entr_pre_sell ==1, c(s) s(n p50) f(%5.0fc)

    variable |         N       p50
-------------+--------------------
    wlthhist |       182       138
----------------------------------

. tabstat wlthhist [aw=crwtall] if entr_post_sell==1, c(s) s(n p50) f(%5.0fc)

    variable |         N       p50
-------------+--------------------
    wlthhist |       182        15
----------------------------------

. // weights lead #s of obs to be different b/c some have zero weight
. 
. // remain CR
. tabstat wlthhist [aw=crwtall] if cmty_pre_sell ==1, c(s) s(n p50) f(%5.0fc)

    variable |         N       p50
-------------+--------------------
    wlthhist |       483       138
----------------------------------

. tabstat wlthhist [aw=crwtall] if cmty_post_sell==1, c(s) s(n p50) f(%5.0fc)

    variable |         N       p50
-------------+--------------------
    wlthhist |       483        27
----------------------------------

. // weights lead #s of obs to be different b/c some have zero weight
. 
. /*
> 
> # liquidators total: 741
> 
> # liquidators who are NHRs pre- and post-liquidation: 64 (8.6%)
> # liquidators who are CRs pre-liquidation and NHRs post-liquidation: 182 (24.6%)
> # liquidators who were CRs pre- and post-liquidation: 485. (65.5%)
> (sum = 64+182+485 = 731.  Implies that 10 (1.3%) liquidators are NHRs pre and CRs post.)
> 
> NH stayers:
> Pre-liquidation NW = 126
> Post-liquidation NW = 21
> Change = -105 (83.3%)
> 
> NH entrants:
> Pre-liquidation NW = 138
> Post-liquidation NW = 15
> Change = -123 (89.1%)
> 
> CR stayers:
> Pre-liquidation NW = 138
> Post-liquidation NW = 27
> Change = -111 (80.4%)
> 
> */
. 
. **********
. ** Assess the role of out-of-pocket medical spending.
. **********
. 
. gen oop = total_oop_HH / 1e3

. // convert to 1000s of 2010 dollars
. // note: using total household oop, including respondent and spouse (both core and exit)
. 
. gen wlthhist_plus_oop = wlthhist + oop

. // net worth plus medical spending accruing between current/previous interview
. 
. tabstat wlthhist          [aw=crwtall] if pre_sell ==1, c(s) s(n p50) f(%5.0fc)

    variable |         N       p50
-------------+--------------------
    wlthhist |       737       139
----------------------------------

. tabstat wlthhist_plus_oop [aw=crwtall] if post_sell==1, c(s) s(n p50) f(%5.0fc)

    variable |         N       p50
-------------+--------------------
wlthhist_p~p |       739        55
----------------------------------

. // weights lead #s of obs to be different b/c some have zero weight
. 
. // Median wealth pre  liquidation in waves T-4 to T-1 is                       139K.
. // Median wealth post liquidation in waves T-3 to T-0 without replacing OOP is  23K.
. // Median wealth post liquidation in waves T-3 to T-0 after   replacing OOP is  55K.
. 
. // Change in medians is 139-23 = (139-55) + (55-23) = 116K.
. //                             =   84     +   22    = 116K.
. 
. // Median expenditures account for 55 - 23 = 22K of the 116K decrease in.
. // That is, 22/116 = 19%. 
. 
. **********
. ** Counterfactuals: liquidators as if renters.
. **********
. 
. sort hhidpn w

. set seed 1234

. 
. gen post_rent = .
(11,450 missing values generated)

. replace post_rent = 1 if (xnriw==3 & rent_43==1)
(741 real changes made)

. replace post_rent = 1 if (xnriw==2 & rent_32==1)
(857 real changes made)

. replace post_rent = 1 if (xnriw==1 & rent_21==1)
(1,016 real changes made)

. replace post_rent = 1 if (xnriw==0 & rent_10==1)
(1,265 real changes made)

. // identify wave after selling
. 
. * assign counterfactual changes in net worth from renters to liquidators
. * find nearest neighbors using carried forward, lagged wealth history
. gen to_impute = (post_sell==1 | post_rent==1)

. // want only (liquidators) and (renters)
. gen z = wlthhistDiff if (post_rent==1)
(7,571 missing values generated)

. // only use data from (renters)
. mi set wide

. mi register imputed z

. * impute one wave at a time (end-points only)
. mi impute pmm z cL1wlthhist if (to_impute==1 & xnriw==3), knn(1) add(1) noisily

Running regress on observed data:


      Source |       SS           df       MS      Number of obs   =       741
-------------+----------------------------------   F(1, 739)       =    202.91
       Model |  2161309.62         1  2161309.62   Prob > F        =    0.0000
    Residual |  7871484.89       739  10651.5357   R-squared       =    0.2154
-------------+----------------------------------   Adj R-squared   =    0.2144
       Total |  10032794.5       740  13557.8304   Root MSE        =    103.21

------------------------------------------------------------------------------
           z |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 cL1wlthhist |  -.2917163    .020479   -14.24   0.000    -.3319202   -.2515124
       _cons |   5.676327   4.019777     1.41   0.158    -2.215216    13.56787
------------------------------------------------------------------------------

Univariate imputation                       Imputations =        1
Predictive mean matching                          added =        1
Imputed: m=1                                    updated =        0

                                      Nearest neighbors =        1

------------------------------------------------------------------
                   |               Observations per m             
                   |----------------------------------------------
          Variable |   Complete   Incomplete   Imputed |     Total
-------------------+-----------------------------------+----------
                 z |        741          163       163 |       904
------------------------------------------------------------------
(complete + incomplete = total; imputed is the minimum across m
 of the number of filled-in observations.)

. mi impute pmm z cL1wlthhist if (to_impute==1 & xnriw==2), knn(1) add(1) noisily

Running regress on observed data:


      Source |       SS           df       MS      Number of obs   =       857
-------------+----------------------------------   F(1, 855)       =    340.53
       Model |  8373888.89         1  8373888.89   Prob > F        =    0.0000
    Residual |  21024880.5       855  24590.5036   R-squared       =    0.2848
-------------+----------------------------------   Adj R-squared   =    0.2840
       Total |  29398769.4       856  34344.3568   Root MSE        =    156.81

------------------------------------------------------------------------------
           z |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 cL1wlthhist |  -.4353296   .0235906   -18.45   0.000    -.4816319   -.3890274
       _cons |   21.33558   5.648245     3.78   0.000     10.24953    32.42163
------------------------------------------------------------------------------

Univariate imputation                       Imputations =        2
Predictive mean matching                          added =        1
Imputed: m=2                                    updated =        0

                                      Nearest neighbors =        1

------------------------------------------------------------------
                   |               Observations per m             
                   |----------------------------------------------
          Variable |   Complete   Incomplete   Imputed |     Total
-------------------+-----------------------------------+----------
                 z |        857          191       191 |      1048
------------------------------------------------------------------
(complete + incomplete = total; imputed is the minimum across m
 of the number of filled-in observations.)

. mi impute pmm z cL1wlthhist if (to_impute==1 & xnriw==1), knn(1) add(1) noisily

Running regress on observed data:


      Source |       SS           df       MS      Number of obs   =     1,016
-------------+----------------------------------   F(1, 1014)      =    551.88
       Model |  12336447.7         1  12336447.7   Prob > F        =    0.0000
    Residual |  22666371.9     1,014  22353.4239   R-squared       =    0.3524
-------------+----------------------------------   Adj R-squared   =    0.3518
       Total |  35002819.5     1,015  34485.5365   Root MSE        =    149.51

------------------------------------------------------------------------------
           z |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 cL1wlthhist |  -.3464163    .014746   -23.49   0.000    -.3753526   -.3174801
       _cons |   7.418181   4.859349     1.53   0.127    -2.117349    16.95371
------------------------------------------------------------------------------

Univariate imputation                       Imputations =        3
Predictive mean matching                          added =        1
Imputed: m=3                                    updated =        0

                                      Nearest neighbors =        1

------------------------------------------------------------------
                   |               Observations per m             
                   |----------------------------------------------
          Variable |   Complete   Incomplete   Imputed |     Total
-------------------+-----------------------------------+----------
                 z |       1016          227       227 |      1243
------------------------------------------------------------------
(complete + incomplete = total; imputed is the minimum across m
 of the number of filled-in observations.)

. mi impute pmm z cL1wlthhist if (to_impute==1 & xnriw==0), knn(1) add(1) noisily

Running regress on observed data:


      Source |       SS           df       MS      Number of obs   =     1,265
-------------+----------------------------------   F(1, 1263)      =    427.91
       Model |  19718402.9         1  19718402.9   Prob > F        =    0.0000
    Residual |  58199896.7     1,263  46080.6783   R-squared       =    0.2531
-------------+----------------------------------   Adj R-squared   =    0.2525
       Total |  77918299.6     1,264  61644.2244   Root MSE        =    214.66

------------------------------------------------------------------------------
           z |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 cL1wlthhist |  -.4267762   .0206312   -20.69   0.000    -.4672513    -.386301
       _cons |   40.48309   6.277883     6.45   0.000     28.16687    52.79932
------------------------------------------------------------------------------

Univariate imputation                       Imputations =        4
Predictive mean matching                          added =        1
Imputed: m=4                                    updated =        0

                                      Nearest neighbors =        1

------------------------------------------------------------------
                   |               Observations per m             
                   |----------------------------------------------
          Variable |   Complete   Incomplete   Imputed |     Total
-------------------+-----------------------------------+----------
                 z |       1265          160       160 |      1425
------------------------------------------------------------------
(complete + incomplete = total; imputed is the minimum across m
 of the number of filled-in observations.)

. desc _*_z

              storage   display    value
variable name   type    format     label      variable label
-------------------------------------------------------------------------------------------------------------------------------------------
_1_z            float   %9.0g                 
_2_z            float   %9.0g                 
_3_z            float   %9.0g                 
_4_z            float   %9.0g                 

. egen zi = rowmax(_*_z)
(6830 missing values generated)

. egen N  = rownonmiss(_*_z)

. tab N if (post_sell==1) & inlist(xnriw,3,2,1,0) // -> expect 1s only

          N |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |        741      100.00      100.00
------------+-----------------------------------
      Total |        741      100.00

. tab N if (post_rent==1) & inlist(xnriw,3,2,1,0) // -> expect 4s only

          N |      Freq.     Percent        Cum.
------------+-----------------------------------
          4 |      3,879      100.00      100.00
------------+-----------------------------------
      Total |      3,879      100.00

. mi extract 0, clear // clear the imputation, delete imputed data

. 
. gen ctfl = cL1wlthhist + zi if (post_sell==1)
(10,709 missing values generated)

. // carried forward lagged wealth history + counterfactually assigned change
. // note: z = wlthhistDiff = wlthhist - cL1wlthhist
. 
. gen wlthHistCtfl = .
(11,450 missing values generated)

. replace wlthHistCtfl = wlthhist if (pre_sell ==1) & inlist(xnriw,4,3,2,1) 
(741 real changes made)

. // start of the segment, use original wealth history
. replace wlthHistCtfl = ctfl     if (post_sell==1) & inlist(xnriw,3,2,1,0)
(741 real changes made)

. // end of segment, use counterfactual wealth history
. 
. tabstat wlthHistCtfl [aw=crwtall] if pre_sell ==1, c(s) s(n p50) f(%5.0fc)

    variable |         N       p50
-------------+--------------------
wlthHistCtfl |       737       139
----------------------------------

. tabstat wlthHistCtfl [aw=crwtall] if post_sell==1, c(s) s(n p50) f(%5.0fc)

    variable |         N       p50
-------------+--------------------
wlthHistCtfl |       739        83
----------------------------------

. 
. // Median wealth pre  liquidation in waves T-4 to T-1 is                           139K.
. // Median wealth post liquidation in waves T-3 to T-0 for synthetic liquidators is  83K.
. // (synthetic liquidators = liquidators as if renters)
. 
. // Change in medians for synthetic liquidators is 139-83 = 56K.
. 
. // (Change in medians) - (Change for synthetic liquidators) = 116 - 56 = 60K.
. 
. // Median expenditures account for 60K of the 116K decrease in.
. // That is, 60/116 = 52%. 
. 
. restore

. 
. * close log
. cap log close
