%ECON 607 Problem Set 1, Question 3 %Andrew McCallum, Jan. 23, 2008 %Clear memory, screen, and close all graphs before execution. clear all; clc; close all; %a) %Adds the path where I store my functions. addpath('U:\Public\html\files\matlab\functions'); %c) %4 alpha = 0; sig2 = 1; T = 1100; y0 = 1; repeat = 100; %AR(1) process with rho: rho = 0.95; %note that rho must be less than one or you will get an explosive series %set the seed so we all get the same results randn('seed',1234); %generate the ar1 using our cute little ar1 program. notice that we can %generate an TxRepeat matrix of ar1 process if we want . yburn = genar1(alpha, rho, sig2, T, y0, repeat); %keep the last 100 observations of each process y = yburn(T-99:T,1:repeat); rhohat95 = 9999*ones(repeat,1); for p = 1:1:100 [rhohat95(p,1), junk, junk2, junk3] = myols(y(2:100,p),y(1:99,p)); end murhohat95 = round(100*mean(rhohat95))/100; figure(1); subplot(2,2,1); hist(rhohat95); title(['\rho = 0.95; \mu =',num2str(murhohat95)]); %change the color of the inside of the boxes to white h95 = findobj(gca,'Type','patch'); set(h95,'FaceColor','w'); %AR(1) process with rho: rho = 0.5; %note that rho must be less than one or you will get an explosive series %set the seed so we all get the same results randn('seed',1234); %generate the ar1 using our cute little ar1 program. notice that we can %generate an TxRepeat matrix of ar1 process if we want . yburn = genar1(alpha, rho, sig2, T, y0, repeat); %keep the last 100 observations of each process y = yburn(T-99:T,1:repeat); rhohat5 = 9999*ones(repeat,1); for p = 1:1:100 [rhohat5(p,1), junk, junk2, junk3] = myols(y(2:100,p),y(1:99,p)); end murhohat5 = round(100*mean(rhohat5))/100; figure(1); subplot(2,2,2); hist(rhohat5); title(['\rho = 0.5; \mu =',num2str(murhohat5)]); %change the color of the inside of the boxes to white h5 = findobj(gca,'Type','patch'); set(h5,'FaceColor','w'); %AR(1) process with rho: rho = 0.999; %note that rho must be less than one or you will get an explosive series %set the seed so we all get the same results randn('seed',1234); %generate the ar1 using our cute little ar1 program. notice that we can %generate an TxRepeat matrix of ar1 process if we want . yburn = genar1(alpha, rho, sig2, T, y0, repeat); %keep the last 100 observations of each process y = yburn(T-99:T,1:repeat); rhohat999 = 9999*ones(repeat,1); for p = 1:1:100 [rhohat999(p,1), junk, junk2, junk3] = myols(y(2:100,p),y(1:99,p)); end murhohat999 = round(100*mean(rhohat999))/100; figure(1); subplot(2,2,3); hist(rhohat999); title(['\rho = 0.5; \mu =',num2str(murhohat999)]); %change the color of the inside of the boxes to white h999 = findobj(gca,'Type','patch'); set(h999,'FaceColor','w');