pause on infile x y using ovfit gen samp=1 if _n<7 gen samp2=1 if _n<40 sort x scatter y x pause sort x scatter y x if samp==1 pause gen x2=x*x gen x3=x*x2 gen x4=x*x3 gen x5=x*x4 gen x6=x*x5 gen x7=x*x6 gen x8=x*x7 reg y x x2 x3 x4 x5 if samp==1 predict yhat scatter y yhat x if samp==1 pause scatter y yhat x pause reg y x if samp==1 predict yhat2 scatter y yhat2 x reg y x if samp2==1 predict yh1 reg y x x2 x3 if samp2==1 predict yh2 reg y x x2 x3 x4 x5 if samp2==1 predict yh3 scatter y yh1 yh2 yh3 x pause gen uu=uniform() sum uu pause gen cut=0 replace cut=1 if uu>0.5 replace cut=. if samp2==. sum cut pause reg y x if cut==0 predict yc1 label variable yc1 "Forecast Model 1" reg y x x2 x3 if cut==0 predict yc2 label variable yc2 "Forecast Model 2" reg y x x2 x3 x4 x5 x6 x7 x8 if cut==0 predict yc3 label variable yc3 "Forecast Model 3" scatter y yc1 yc2 yc3 x if cut==1 pause gen fit1=(y-yc1)*(y-yc1) if cut==1 gen fit2=(y-yc2)*(y-yc2) if cut==1 gen fit3=(y-yc3)*(y-yc3) if cut==1 sum fit1 fit2 fit3