This is a panel dataset that conatins 1000 observations and two periods.
Time independent variables:
Time dependent variables:
#Lets randomly generate all the variable I want
indiv<-1:1000
gender<-sample(x = 0:1, size = 1000, replace = TRUE)
age_1<-sample(x = 18:35, size = 1000, replace = TRUE)
soceco_level<-sample(x = 1:3, size = 1000, replace = TRUE)
labor_1<-sample(x = 0:1, size = 1000, replace = TRUE)
care_1<-sample(x = 0:1, size = 1000, replace = TRUE)
labor_2<-sample(x = 0:1, size = 1000, replace = TRUE)
care_pref<-sample(x = 0:1, size = 1000, replace = TRUE)
shock_wage_1<-rnorm(1000, -5, 5)
shock_wage_2<-rnorm(1000, -5, 5)
#Format is as a data frame
my_data<-matrix(c(indiv, gender, age_1, soceco_level,labor_1,care_1,labor_2, care_pref, shock_wage_1, shock_wage_2 ), ncol=10)
my_data02<-as.data.frame.matrix(my_data)
#Rename the variables
my_data02<-
rename(my_data02,
indiv = V1,
gender = V2,
age_1 = V3,
soceco_level = V4,
labor_1 = V5,
care_1 = V6,
labor_2 = V7,
care_pref = V8,
shock_wage_1 =V9,
shock_wage_2 =V10
)
my_data02<-mutate(my_data02,
wage_1 = labor_1*exp(0.5*gender + 0.5*soceco_level + 0.05*age_1 - 0.025*age_1^2 + shock_wage_1),
age_2 = age_1 + 20)
my_data02<-mutate(my_data02,
wage_2 = labor_2*(wage_1 + exp(labor_1 + 0.05*age_2 - 0.025*age_2^2 + shock_wage_2)),
care_2 = ifelse(care_1 - labor_1*((wage_1 - mean(wage_1))/mean(wage_1)) - gender + care_pref > 1, 1, 0))
table01<-(head(my_data02))
kable(table01, align = "rrrrrrrrrrr", digits = c(1, 1, 2, 1, 1, 4, 4,6,2,6,1))
| indiv | gender | age_1 | soceco_level | labor_1 | care_1 | labor_2 | care_pref | shock_wage_1 | shock_wage_2 | wage_1 | age_2 | wage_2 | care_2 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 32 | 3 | 1 | 0 | 0 | 1 | -10.09 | -10.630265 | 0 | 52 | 0 | 0 |
| 2 | 0 | 22 | 1 | 1 | 1 | 0 | 1 | -18.34 | -5.163540 | 0 | 42 | 0 | 1 |
| 3 | 1 | 20 | 2 | 1 | 0 | 1 | 1 | 2.48 | -10.655038 | 0 | 40 | 0 | 0 |
| 4 | 1 | 28 | 1 | 1 | 1 | 1 | 1 | 2.38 | -3.072351 | 0 | 48 | 0 | 1 |
| 5 | 1 | 33 | 2 | 0 | 1 | 0 | 1 | -4.94 | -3.441887 | 0 | 53 | 0 | 0 |
| 6 | 1 | 28 | 3 | 0 | 0 | 1 | 0 | 0.09 | 0.407149 | 0 | 48 | 0 | 0 |
#xtable(my_data02[1:10, ])
In this section I provide a table that computes the proportion of labor force participation and care provision by age.
#Lets randomly generate all the variable I want
table02<-my_data02 %>%
group_by(age_1) %>%
summarize(
lab_1 = mean(labor_1),
car_1 = mean(care_1),
lab_2 = mean(labor_2),
car_2 = mean(care_2))
kable(table02, align = "rrrrrrr", digits = c(2, 1, 1, 5, 1, 1, 5))
| age_1 | lab_1 | car_1 | lab_2 | car_2 |
|---|---|---|---|---|
| 18 | 0.5 | 0.6 | 0.56364 | 0.3 |
| 19 | 0.5 | 0.4 | 0.44828 | 0.3 |
| 20 | 0.5 | 0.5 | 0.44262 | 0.2 |
| 21 | 0.5 | 0.5 | 0.53226 | 0.4 |
| 22 | 0.5 | 0.6 | 0.52941 | 0.3 |
| 23 | 0.5 | 0.6 | 0.52381 | 0.4 |
| 24 | 0.5 | 0.6 | 0.40816 | 0.4 |
| 25 | 0.5 | 0.4 | 0.54688 | 0.3 |
| 26 | 0.5 | 0.5 | 0.48276 | 0.3 |
| 27 | 0.5 | 0.5 | 0.50980 | 0.4 |
| 28 | 0.6 | 0.6 | 0.46809 | 0.3 |
| 29 | 0.5 | 0.4 | 0.59677 | 0.3 |
| 30 | 0.5 | 0.6 | 0.46512 | 0.4 |
| 31 | 0.5 | 0.3 | 0.56140 | 0.3 |
| 32 | 0.6 | 0.6 | 0.55319 | 0.4 |
| 33 | 0.4 | 0.5 | 0.61290 | 0.3 |
| 34 | 0.6 | 0.4 | 0.34848 | 0.2 |
| 35 | 0.5 | 0.5 | 0.65909 | 0.3 |
print(xtable(table02, type = "latex"), file = "table02.tex")
Let’s run the following regression:
\[care_2 = \beta_0 + \beta_1 care_1 + \beta_2 X + \varepsilon\] Where the set of controls \(X\) contains: age, gender, wage_1, labor_1.
model01 <-lm(care_2 ~ care_1 + age_2 + gender+ wage_1 + labor_1, data=my_data02)
tab_model(model01, p.style = "stars")
| care_2 | ||
|---|---|---|
| Predictors | Estimates | CI |
| (Intercept) | 0.17 | -0.01 – 0.36 |
| care_1 | 0.38 *** | 0.34 – 0.42 |
| age_2 | -0.00 | -0.01 – 0.00 |
| gender | -0.38 *** | -0.43 – -0.34 |
| wage_1 | -0.14 ** | -0.25 – -0.04 |
| labor_1 | 0.39 *** | 0.35 – 0.43 |
| Observations | 1000 | |
| R2 / R2 adjusted | 0.502 / 0.500 | |
|
||
stargazer(model01, title="Results", align=TRUE, out = "table03.tex")
% Table created by stargazer v.5.2.2 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu % Date and time: Thu, Mar 25, 2021 - 7:19:42 PM % Requires LaTeX packages: dcolumn