simulation_lecture2

simulation_lecture2 - reg Y X; gen b0_estim=_coef[_cons];...

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

View Full Document Right Arrow Icon
/** 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;
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
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

This note was uploaded on 09/04/2011 for the course ECON 140b taught by Professor Staff during the Winter '08 term at UCSB.

Page1 / 2

simulation_lecture2 - reg Y X; gen b0_estim=_coef[_cons];...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online