Monte Carlo Simulation

26
Monte Carlo Simulation: SLR

description

Monte Carlo Simulation in Finance

Transcript of Monte Carlo Simulation

Page 1: Monte Carlo Simulation

Monte Carlo Simulation: SLR

Page 2: Monte Carlo Simulation

Exercise 1

)ˆ(E

Page 3: Monte Carlo Simulation

3

Estimating the Error Variance

• We don’t know what the error variance, 2, is, because we don’t observe the errors, ui

• What we observe are the residuals, ûi

• We can use the residuals to form an estimate of the error variance

Page 4: Monte Carlo Simulation

4

Error Variance Estimate (cont)

2/ˆ2

is ofestimator unbiasedan Then,

ˆ and ˆfor similarly and ˆ of valueexpected The

ˆˆ

ˆˆ

ˆˆˆ

22

2

100

1100

1010

10

nSSRun

uequals

xu

xux

xyu

i

i

ii

iii

iii

Page 5: Monte Carlo Simulation

5

Exercise 2

• The OLS estimates of 1 and 0 are unbiased if •

• Proof of unbiasedness depends on our 4 assumptions – if any assumption fails, then OLS is not necessarily unbiased

• Remember unbiasedness is a description of the estimator – in a given sample we may be “near” or “far” from the true parameter

11

00

)ˆ(

)ˆ(

E

E

Page 6: Monte Carlo Simulation

6

Exercise 2: Contd:

212

1

1

2

/ˆˆse

, ˆ oferror standard the

have then wefor ˆ substitute weif

ˆsd that recall

regression theoferror Standardˆˆ

xx

s

i

x

Check if estimated Variance of Beta_hat is same as true variance of beta_hat

Page 7: Monte Carlo Simulation

Exercise 4

• Exercise 4: Show that the variance of ‘u’ and ‘y’ are same for a given value of x.

• The mean of u is zero and the mean of y is b0+ b1x.

• Also show that the variance of u unconditional on x is same as variance of u conditional on x.

Page 8: Monte Carlo Simulation

8

Variance of OLS (cont)• Var(u|x) = E(u2|x)- [E(u|x)]2

• E(u|x) = 0, so 2 = E(u2|x) = E(u2) = Var(u)

• Thus 2 is also the unconditional variance, called the error variance• • , the square root of the error variance is called the standard deviation of

the error• • Can say: E(y|x)=0 + 1x and Var(y|x) = 2

• The random variables y and e have the same variance because they differ only by a constant.

Page 9: Monte Carlo Simulation
Page 10: Monte Carlo Simulation

Simulate one sample Data/* simulate data */data normal;call streaminit(1234567);

do n = 1 to 40; if n < 21 then x = 10;else x = 20; e = rand('normal',0,50);y = 100 + 10*x + e; output; end;

run;

Page 11: Monte Carlo Simulation

Print the Dataset

proc print data=normal(firstobs=15 obs=25);var x y;title 'Observations from normal DGP';run;

Page 12: Monte Carlo Simulation

Compute True Variance of B1_hat

22

xsVar

= 2500/1000 =2.5

Page 13: Monte Carlo Simulation

Computing True Variance of b1_hatproc means data=normal css;var x; title 'corrected ss for x or (x-xbar)^2';run;/* true parameter values */data truevar; sig2 = 2500; ssx = 1000; truevar = sig2/ssx;truese = sqrt(truevar); run;

Page 14: Monte Carlo Simulation

Print

proc print data=truevar; var truevar truese;title 'true var(b1) and se(b1)';run;

Page 15: Monte Carlo Simulation

Regress Y on X

proc reg data=normal outest=est tableout mse;model y = x;title 'regression with normal data';title2 'true intercept = 100 & slope = 10';run;

Page 16: Monte Carlo Simulation

Check the Results

• here you should find that estimated intercept and slope are 112 and 8.9 approx. respectively.

• esimtated variance of the error term is 2803 against true value of 2500;

• true standard error of b1 is 1.58 and the estimated standard error is 1.67;

Page 17: Monte Carlo Simulation

/* print est data set */

• proc print data=est; • title 'OUTEST data';

Page 18: Monte Carlo Simulation

Monte Carlo Experiment: simulate data 10,000 times

data normal;call streaminit(1234567); do sample = 1 to 10000;

do n = 1 to 40; if n < 21 then x = 10;else x = 20; e = rand('normal',0,50);y = 100 + 10*x + e; output; end;

End;run;

Page 19: Monte Carlo Simulation

/* regression with NOPRINT option */

proc reg noprint data=normal outest=est tableout MSE;model y = x;by sample;

run;

Page 20: Monte Carlo Simulation

data parm;set est;

if _type_='PARMS'; b0 = intercept;b1 = x; sig2 = _MSE_;keep sample b0 b1 sig2;

run;

Page 21: Monte Carlo Simulation

Monte Carlo summary statistics

proc means data=parm mean var std min max p1 p99;var b0 b1 sig2;title 'Monte Carlo summary statistics';

run;

Page 22: Monte Carlo Simulation

Results summary

• sample variance of b1 is 2.56 when compared to true variance of 2.5,

• which illustrates what variance of b1 actually measures- the sampling variation of the least squares estimates in repeated(many) samples.

• the average estimate of error variance is 2493 compared to the true value of 2500.;

Page 23: Monte Carlo Simulation

summarize slope estimates & plot histogram

proc univariate data = parm;var b1;histogram/normal;title 'Sampling distribution of b1';title2 'Errors Normal';

run;

Page 24: Monte Carlo Simulation

Check if variance estimated is unbiased

data se;set est; if _type_='STDERR';se = x; varb1 = se**2;keep sample varb1 se;run;

proc means data=se mean;var varb1 se; title 'average value estimated var(b1): normal data';title2 'true var(b1)= 2.50';run;

Page 25: Monte Carlo Simulation

Finally check the estimator of the variance of b1_hat

• That is standard error of b1_hat• Where do you find this??

Page 26: Monte Carlo Simulation

Exercise 4proc sort data=normal; by x; run;

proc means data=normal; by x;var y e; run;

*check here : the standard deviation of e is the same irrespective of x but not y;

proc means data=normal;var y e; run;