


 use [DF_16],clear

merge 1:m mgrID  using [DF_11],nogen
collapse gm gp map_w,by( mgrID teamID yearID)
drop if map_w==.


gen tmwins=(gm/gp)*map_w

collapse (sum) tmwins,by(teamID yearID)

merge 1:1 yearID teamID using [DF_9].dta,nogen


	regress wp  i.yearID##c.z_wpg
	regress wp  z_wpg tmwins 
	
	


regress wp c.z_wpg##i.yearID [aw=games]
di "Pooled R2 (year-specific slopes): " e(r2)
regress wp c.z_wpg##i.yearID tmwins [aw=games]
di "Pooled R2 (year-specific slopes): " e(r2)
	 
		
gen R2=.

forvalues y =1901/2025 {
	
regress wp c.z_wpg [aweight=games] if yearID==`y'

di `y'


	
		replace R2 = e(r2) if year == `y'



}


replace R2=R2*100



		
gen R2_b=.

forvalues y =1901/2025 {
	
regress wp c.z_wpg tmwins [aweight=games] if yearID==`y'




	
		replace R2_b = e(r2) if year == `y'



}


replace R2_b=R2_b*100

preserve
keep yearID R2_b R2
duplicates drop
twoway ///
			   (lpolyci R2 year,   fcolor(gs12%36) alcolor(gs12%10) clstyle(none)) ///
			   (lpoly R2 year,   lpattern(dash) lcolor(black)) ///
			   (lpolyci R2_b year,   fcolor(cyan%36) alcolor(cyan%10) clstyle(none)) ///
			   (lpoly R2_b year,   lpattern(dash) lcolor(blue)), ///
			   ytitle("") ///
			   xtitle("") ///
			   ylabel(50(10)100,angle(0) labsize(8pt) nogrid) ///
			   xlabel(1900(10)2024, angle(45) labsize(8pt) nogrid) ///
			   legend(off) ///
			   graphregion(color(white)) ///
			   plotregion(margin(zero)) ysize(4.125) xsize(5.5)
			   
			   
			   * Vector exports 
graph export "r2.pdf", replace      
graph export "r2.eps", replace      
graph export "r2.svg", replace      
graph export "r2.emf", replace      
restore