Hi
I'm stuck with a monte carlo simulation for testing 5 different models and comparing them at the end.
This is my current code: I would be extremely grateful for any help as unsure why it isn't working
** Generate the observable treatment effect
gen `Ty0' = gamma_0 + gamma_1* Tage+ gamma_2*Tfemale+ gamma3*Tage*Tfemale+Terror
gen yobs= Ty0 + TW
reg Ty0 TW
** Store value of beta
mat beta 'j' [`i',1] = ss1[1,1]
reg Ty0 TW Tage Tfemale Tfemale*Tage
** Store value of beta
mat beta 'j' [`i',2] = ss2[1,1]
reg Ty0 TW i.Tage
** Store value of beta
mat beta 'j' [`i',3] = ss3[1,1]
logit `TW' `Tage'
predict `pred_prob1' //
gen `lad'=1/`pred_prob1'^`TW'*(1-`pred_prob1'^(1-`TW'))
reg Ty0 Tage `lad' [W=`lad']
mat beta 'j' [`i',4] = ss4[1,1]
logit `TW' i.`Tage'
predict `pred_prob2' //
gen `lad2'=1/`pred_prob2'^`varw'*(1-`pred_prob2'^(1-`varw'))
reg `y0' `vage' `lad2' [w=`lad2']
mat beta 'j' [`i',5] = ss5[1,1]
}
end
** Run the programme R=1000 times
mat def beta1 = J(1000,2,.)
set seed 12345
forvalues i = 1/1000 {
SIM 'i' 5
}
svmat beta1
** Summarize each estimators
sum beta11 beta12 beta13 beta14 beta15
I'm stuck with a monte carlo simulation for testing 5 different models and comparing them at the end.
This is my current code: I would be extremely grateful for any help as unsure why it isn't working
** Generate the observable treatment effect
gen `Ty0' = gamma_0 + gamma_1* Tage+ gamma_2*Tfemale+ gamma3*Tage*Tfemale+Terror
gen yobs= Ty0 + TW
reg Ty0 TW
** Store value of beta
mat beta 'j' [`i',1] = ss1[1,1]
reg Ty0 TW Tage Tfemale Tfemale*Tage
** Store value of beta
mat beta 'j' [`i',2] = ss2[1,1]
reg Ty0 TW i.Tage
** Store value of beta
mat beta 'j' [`i',3] = ss3[1,1]
logit `TW' `Tage'
predict `pred_prob1' //
gen `lad'=1/`pred_prob1'^`TW'*(1-`pred_prob1'^(1-`TW'))
reg Ty0 Tage `lad' [W=`lad']
mat beta 'j' [`i',4] = ss4[1,1]
logit `TW' i.`Tage'
predict `pred_prob2' //
gen `lad2'=1/`pred_prob2'^`varw'*(1-`pred_prob2'^(1-`varw'))
reg `y0' `vage' `lad2' [w=`lad2']
mat beta 'j' [`i',5] = ss5[1,1]
}
end
** Run the programme R=1000 times
mat def beta1 = J(1000,2,.)
set seed 12345
forvalues i = 1/1000 {
SIM 'i' 5
}
svmat beta1
** Summarize each estimators
sum beta11 beta12 beta13 beta14 beta15

Comment