{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

simulation_lecture2

# simulation_lecture2 - reg Y X gen b0_estim=_coef_cons gen...

This preview shows pages 1–2. Sign up to view the full content.

/** Program for the simulations in lecture 2 **/ /** Here for the case where n = 3 **/ #delimit; set seed 154822; set obs 3; gen b0=5.0; gen b1=1.0; gen X=20*uniform(); save c:\Stata\MAIN, replace; keep if _n==1; gen abc=1; keep abc; save c:\Stata\OUTPUT1a, replace; program drop _all; program define simul1; capture{; local j=1; while `j' <=50 {; use c:\Stata\MAIN; gen u=5*invnorm(uniform()); gen Y=b0+b1*X+u;

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: reg Y X; gen b0_estim=_coef[_cons]; gen b1_estim=_coef[X]; gen R2=e(r2); egen meanX=mean(X); egen meanY=mean(Y); gen nobs=_N; gen sample=`j'; summ; keep if _n==1; keep sample nobs b0* b1* meanX meanY R2; append using c:\Stata\OUTPUT1a; save c:\Stata\OUTPUT1a, replace; local j=`j'+1; clear; }; }; end; simul1; use c:\Stata\OUTPUT1a; drop abc; summ; gr7 b1_estim, xline(1) xlab(-1,0,1,2); clear;...
View Full Document

{[ snackBarMessage ]}

### Page1 / 2

simulation_lecture2 - reg Y X gen b0_estim=_coef_cons gen...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online