Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: inconsistent do-file execution


From   Rufus Peabody <[email protected]>
To   [email protected]
Subject   st: inconsistent do-file execution
Date   Sun, 8 Jun 2008 19:48:41 -0400

Hey all,

I'm using Stata 10 SE for Mac. I'm having a problem with the execution of a do-file--each time I do the do-file, I get different results for only a subset of the data. First of all, is there any reason why running the same do-file which is using the exact same data would give me different results? The do-file is a bit long but I'll paste it in here, although I'm not sure how it would give me different results since I'm not simulating anything...

Thanks,
Rufus


use iteration2a_lag_bet.dta


regress kpct lkpct_norm_pit_003 lkpct_norm_opp_01 ltotal_bf lp_pa_norm_pit_up003 lstrike_pct_norm_opp_up01 lbip_pct_norm_opp_up01 kpct_int_bf if year<2005 & home==1
predict kpct_pred_home if home==1
regress kpct lkpct_norm_pit_003 lkpct_norm_opp_01 ltotal_bf lp_pa_norm_pit_up003 lbip_pct_norm_opp_up01 kpct_int_bf if year<2005 & home==0
predict kpct_pred_away if home==0

regress bbpct ltotal_bf lbbpct_norm_pit_003 lbbpct_norm_opp_up01 bbpct_int_bf lp_pa_norm_pit_up003 lp_pa_norm_opp_up01 lstrike_pct_norm_opp_up01 lstrike_pct_norm_pit_up003 lhrpct_norm_opp_up01 if year<2005 & home==1
predict bbpct_pred_home if home==1
regress bbpct ltotal_bf lbbpct_norm_pit_003 lbbpct_norm_opp_up01 bbpct_int_bf lp_pa_norm_pit_up003 lp_pa_norm_opp_up01 lstrike_pct_norm_opp_up01 lstrike_pct_norm_pit_up003 if year<2005 & home==0
predict bbpct_pred_away if home==0

regress hrpct ltotal_bf hr_bip_pfbf ladjhrpct_norm_pit_up003 ladjhrpct_norm_opp_up01 lebh_bip_norm_opp_up01 lebh_bip_norm_pit_up003 lbip_pct_norm_pit_up003 lgdppct_norm_pit_up003 if year<2005 & home==1
predict hrpct_pred_home if home==1
regress hrpct ltotal_bf hr_bip_pfbf ladjhrpct_norm_pit_up003 ladjhrpct_norm_opp_up01 lebh_bip_norm_pit_003 lbip_pct_norm_pit_up003 lgdppct_norm_pit_up003 lgdppct_norm_opp_01 if year<2005 & home==0
predict hrpct_pred_away if home==0

regress babip babip_pfbf ltotal_bf lbabip_norm_pit_003 lbabip_norm_opp lbip_pct_norm_pit_up003 if home==1 & year<2005
predict babip_pred_home if home==1
regress babip babip_pfbf ltotal_bf lbabip_norm_pit_003 lbabip_norm_opp_up lbip_pct_norm_pit_up003 if home==0 & year<2005
predict babip_pred_away if home==0

regress woba woba_pfbf kpct_pred_home bbpct_pred_home hrpct_pred_home babip_pred_home if home==1 & year<2005, robust
predict woba_pred_home if home==1
regress woba woba_pfbf kpct_pred_away bbpct_pred_away hrpct_pred_away babip_pred_away if home==0 & year<2005, robust
predict woba_pred_away if home==0

regress ip lip_norm_pit_up003 ltotal_bf woba_pred_home bbpct_pred_home if year<2005 & home==1, robust
predict ip_pred_home if home==1
regress ip lip_norm_pit_up003 ltotal_bf woba_pred_away if year<2005 & home==0, robust
predict ip_pred_away if home==0

regress bip_pct lbip_pct_norm_pit_up003 lkpct_norm_opp_up01 lbbpct_norm_opp_up01 if year<2005 & home==1, robust
predict bip_pct_pred_home if home==1
regress bip_pct lbip_pct_norm_pit_up003 lkpct_norm_opp_up01 lbbpct_norm_opp_up01 if year<2005 & home==0, robust
predict bip_pct_pred_away if home==0


regress kpct_pen lkpct_norm_pen_up01 lkpct_norm_opp_up01 lbip_pct_norm_opp_up01 ip_pred_home pitchers_lastweek_pen if year<2005 & home==1, robust
predict kpct_pen_pred_home if home==1
regress kpct_pen lkpct_norm_pen_01 lkpct_norm_opp_01 lbip_pct_norm_opp_up01 lbip_pct_norm_pen_01 lstrike_pct_norm_pen_01 pitchers_lastweek_pen ip_pred_away if year<2005 & home==0, robust
predict kpct_pen_pred_away if home==0

regress bbpct_pen lbbpct_norm_pen_01 lbbpct_norm_opp_01 lstrike_pct_norm_pen_01 pitchers_lastweek_pen if year<2005 & home==1, robust
predict bbpct_pen_pred_home if home==1
regress bbpct_pen lbbpct_norm_opp_01 lstrike_pct_norm_pen_01 pitchers_lastweek_pen if year<2005 & home==0, robust
predict bbpct_pen_pred_away if home==0

regress babip_pen babip_pfbf lbabip_norm_pen_01 ip_pred_home ip_lastweek_pen if year<2005 & home==1, robust
predict babip_pen_pred_home if home==1
regress babip_pen babip_pfbf lbabip_norm_pen_01 ip_pred_away pitchers_lastweek_pen if year<2005 & home==0, robust
predict babip_pen_pred_away if home==0

regress hrpct_pen hrpct_pfbf ladjhrpct_norm_opp_01 ladjhrpct_norm_pen_01 ip_pred_home ip_lastweek_pen if year<2005 & home==1
predict hrpct_pen_pred_home if home==1
regress hrpct_pen hrpct_pfbf ladjhrpct_norm_opp_01 ladjhrpct_norm_pen_01 if year<2005 & home==0
predict hrpct_pen_pred_away if home==0

regress woba_pen kpct_pen_pred_home bbpct_pen_pred_home babip_pen_pred_home hrpct_pen_pred_home if year<2005 & home==1, robust
predict woba_pen_pred_home if home==1
regress woba_pen kpct_pen_pred_away bbpct_pen_pred_away babip_pen_pred_away hrpct_pen_pred_away if year<2005 & home==0, robust
predict woba_pen_pred_away if home==0


regress runavg_pen woba_pen_pred_home if year<2005 & home==1, robust
predict runavg_pen_pred_home if home==1
regress runavg_pen woba_pen_pred_away if year<2005 & home==0, robust
predict runavg_pen_pred_away if home==0


regress runavg woba_pred_home if year<2005 & home==1, robust
predict runavg_pred_home if home==1
regress runavg woba_pred_away if year<2005 & home==0, robust
predict runavg_pred_away if home==0

gen runavg_pred_home_IP=runavg_pred_home*ip_pred_home
gen runavg_pred_away_IP=runavg_pred_away*ip_pred_away

regress runavg_tm runavg_pen_pred_home runavg_pred_home runavg_pred_home_IP if year<2005 & home==1, robust beta
predict runavg_tm_pred_home if home==1
regress runavg_tm runavg_pen_pred_away runavg_pred_away runavg_pred_away_IP if year<2005 & home==0, robust beta
predict runavg_tm_pred_away if home==0

gen runavg_tm_pred=runavg_tm_pred_home if home==1
replace runavg_tm_pred=runavg_tm_pred_away if home==0

sort gameid
gen runavg_opp_pred=runavg_tm_pred[_n-1] if gameid[_n-1]==gameid
replace runavg_opp_pred=runavg_tm_pred[_n+1] if gameid[_n+1]==gameid

logit tm_win runavg_opp_pred runavg_tm_pred if home==1 & year<2005, robust
predict home_win_new2 if home==1


gen away_win_new2=1-home_win_new2

gen strat1_ols_in_new2=tm_unit if home==1 & home_win_new2>tm_perc & home_win_new2~=. & year<2005
gen strat1_ols_out_new2=tm_unit if home==1 & home_win_new2>tm_perc & home_win_new2~=. & year>2004
replace strat1_ols_in_new2=opp_unit if home==1 & away_win_new2>opp_perc & home_win_new2~=. & year<2005
replace strat1_ols_out_new2=opp_unit if home==1 & away_win_new2>opp_perc & home_win_new2~=. & year>2004


regress tm_unit home_win_new2 tm_perc if home==1 & home_win_new2~=. & year<2005
predict exp_return_home_new2 if home_win_new2!=.
regress opp_unit home_win_new2 tm_perc if home==1 & home_win_new2~=. & year<2005
predict exp_return_away_new2 if home_win_new2!=.

***
gen strat2_ols_in_new2=opp_unit if exp_return_away_new2>0 & away_win_new2>opp_perc & year<=2004 & home_win_new2~=. & home==1 & exp_return_away_new2!=.
replace strat2_ols_in_new2=tm_unit if exp_return_home_new2>0 & home_win_new2>tm_perc & year<=2004 & home_win_new2~=. & home==1 & exp_return_home_new2!=.
gen strat2_ols_out_new2=opp_unit if exp_return_away_new2>0 & away_win_new2>opp_perc & year>2004 & home_win_new2~=. & home==1 & exp_return_away_new2!=.
replace strat2_ols_out_new2=tm_unit if exp_return_home_new2>0 & home_win_new2>tm_perc & year>2004 & home_win_new2~=. & home==1 & exp_return_home_new2!=.


bysort year: summ strat2_ols_in strat2_ols_out strat1_ols_in strat1_ols_out [iweight=abs(home_win_new2-tm_perc)] *
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index