Financial Modeling in Matlab Exercise

Submitted by: Submitted by

Views: 242

Words: 384

Pages: 2

Category: Science and Technology

Date Submitted: 11/08/2012 03:45 AM

Report This Essay

c/d Financial models

clearvars; n=10^5; z=randn(1,n); varz=1;

mu_z=0; %i indicates which function you use (g_i)

for i=1:6

for k=1:n

a(k)=1/n*exp(z(k)-1/2)*g(i,z(k));

b(k)=1/n*g(i,(z(k)+1));

end

A(i)=sum(a); %sample mean

B(i)=sum(b); %sample mean

%--stda(i)=1/sqrt(n)*sqrt(sum((n*a-A(i)).^2));

%--stdb(i)=1/sqrt(n)*sqrt(sum((n*b-B(i)).^2));

Vargzb(i)=varz*(dg(i,mu_z))^2;%delta method

Vargza(i)=varz*(exp(mu_z-1/2)*dg(i,mu_z)+exp(mu_z-1/2)*g(i,mu_z))^2; %product rule

end

A

B

stda=(1/sqrt(n))*sqrt(Vargza); %stda alt

stdb=(1/sqrt(n))*sqrt(Vargzb); %stdb alt

CIAl=[A-1.96*stda]

CIAr=[A+1.96*stda]

CIBl=[B-1.96*stdb]

CIBr=[B+1.96*stdb]

overlap=[(CIAr>CIBl)]

diffa=mean(CIAr-CIAl)

diffb=mean(CIBr-CIBl)

%--stda

%--stdb

%USED: 1) Central Limit Theorem

%2)Hints: to compute the approximate confidence interval, recall that the

%standard deviation of the average of n independent identically distributed

%variables is given by n^ (-1/2) times the standard deviation of a single

%variable.

%3)The [single variable] -> What is the variance of (exp(z(k)-1/2)*g(z(k))

%given that the variance of z(k)=1. ?

%Answer: http://www.math.umt.edu/patterson/549/Delta.pdf

%DELTAMETHOD If Y=f(X), var(Y) is approx. given by Var(Y)=[f'(mu_x)]^2*Var(X)

OUTPUT:

A = 1.0078 2.0095 4.4859 0.6065 0.3417 0.1826 (A,B are the numbers

B = 1.0027 2.0109 4.5002 0.6068 0.3396 0.1858 to be calculated for g1,g2..,g6)

CIAl = 1.0040 2.0095 4.4783 0.6065 0.3379 0.1792 (lower endpnt CI95% for A)

CIAr = 1.0115 2.0095 4.4934 0.6065 0.3455 0.1860 (upper endpntCI95%for A)

CIBl = 0.9965 2.0109 4.4940 0.6006 0.3396 0.1858

CIBr = 1.0089 2.0109 4.5064 0.6130 0.3396 0.1858

overlp = 1 0 0 1 1 1 (Do intervals overlap)

diffa = 0.0062 diffb = 0.0062 (CI length)