library(tidyverse)
library(ggplot2)
data <- read.csv("data\\data_panel.csv")
glimpse(data)
## Rows: 10,202
## Columns: 46
## $ hhid <int> 2013000001, 2013000001, 2013000042, 20130000…
## $ year <int> 2017, 2019, 2017, 2019, 2017, 2019, 2017, 20…
## $ prov <chr> "北京", "北京", "北京", "北京", "北京", "北…
## $ gender <int> 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0,…
## $ education <int> 3, 3, 2, 2, 2, 2, 3, 3, 2, 3, 4, 4, 3, 3, 4,…
## $ marriage <int> 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1,…
## $ health <int> 2, 2, 3, 2, 2, 2, 1, 2, 2, 3, 3, 4, 2, 3, 4,…
## $ total_income <dbl> 136634.78, 139585.71, 80668.00, 88999.62, 20…
## $ total_consump <dbl> 91600.00, 108264.83, 28656.00, 133716.73, 12…
## $ total_asset <dbl> 9421595, 9830520, 409693, 1062253, 8503600, …
## $ total_debt <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,…
## $ house_asset <dbl> 8000000.0, 8566460.0, 300000.0, 737667.4, 80…
## $ house_debt <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,…
## $ shengcun_con <dbl> 71950.00, 83227.92, 27336.00, 124689.58, 853…
## $ fazhan_con <dbl> 19650.000, 25036.907, 1320.000, 9027.145, 42…
## $ relationship <int> 2, 2, 1, 1, 3, 4, 1, 3, 2, 2, 2, 1, 1, 1, 1,…
## $ workplace_type <int> 0, 0, 5, 5, 0, 0, 0, 0, 1, 5, 0, 0, 0, 0, 5,…
## $ work_type <int> 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1,…
## $ family_num <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
## $ house_n <int> 2, 2, 1, 2, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 2,…
## $ house_dummy <int> 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1,…
## $ house_price <dbl> 8000000.0, 8566460.0, 300000.0, 737667.4, 80…
## $ house_loan <dbl> 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e…
## $ down_payment <dbl> 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e…
## $ mortgage_per_mon <dbl> 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.…
## $ loan_arrears <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,…
## $ age <int> 72, 74, 48, 50, 68, 70, 56, 58, 59, 61, 70, …
## $ loan_confirmation <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ other_asset <dbl> 1421595.0, 1264060.0, 109693.0, 324585.6, 50…
## $ other_debt <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ logtotal_income <dbl> 11.82507, 11.84644, 11.29811, 11.39640, 12.2…
## $ logtotal_consump <dbl> 11.42520, 11.59234, 10.26315, 11.80349, 11.7…
## $ logtotal_asset <dbl> 16.05852, 16.10100, 12.92317, 13.87590, 15.9…
## $ logtotal_debt <dbl> 0.00000, 0.00000, 0.00000, 0.00000, 0.00000,…
## $ loghouse_debt <dbl> 0.00000, 0.00000, 0.00000, 0.00000, 0.00000,…
## $ logother_debt <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ loghouse_asset <dbl> 15.89495, 15.96337, 12.61154, 13.51125, 15.8…
## $ logother_asset <dbl> 14.16729, 14.04984, 11.60545, 12.69031, 13.1…
## $ loghouse_price <dbl> 15.89495, 15.96337, 12.61154, 13.51125, 15.8…
## $ logshengcun_con <dbl> 11.183741, 11.329350, 10.215996, 11.733591, …
## $ logfazhan_con <dbl> 9.885884, 10.128146, 7.186144, 9.108102, 10.…
## $ logloan_arrears <dbl> 0.00000, 0.00000, 0.00000, 0.00000, 0.00000,…
## $ age2 <int> 5184, 5476, 2304, 2500, 4624, 4900, 3136, 33…
## $ prov_mean_house_price <dbl> 27497.00, 32190.85, 27497.00, 32190.85, 2749…
## $ log_prov_mean_house_price <dbl> 10.22183, 10.37944, 10.22183, 10.37944, 10.2…
## $ debt_dummy <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,…