Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Thread Subject:
Help with Econometrics Simulation

Subject: Help with Econometrics Simulation

From: Ricardo Silva

Date: 21 Nov, 2008 17:57:01

Message: 1 of 1

Hi, I wrote a code to replicate the original Dickey and Fuller critical values for Unit Root Tests. However, the number doesn't match. Any help with the code below?
%Critical Values for origial DF tests
format short
rho=1; %AR coeff.
ct=0.5; %Constant
t0=50; %dropped observations
t1=150; %Sample Size
mc=1000; %MC replication
yg(1)=0; %Initial value
%Hip. Cofiguration (OLS2 fuction at the end )
%c=1 -- Only Constant
%c=2 -- Constant ans Trend
%Begin the Monte Carlo Looping
for j=1:mc
    %Loop para o Processo Gerador de Dados
    for t=2:t1
    %Drop Initial Observations
    %OLS Regression
    [tratio]=ols2(y,x,c); df_t=tratio(1);
    %Save t-values
    if j == 1;
        sto=[sto df_t];
end; %Fim do Monte Carlo
%Calculating Critical Values
%Critical Values 1% 2.5% 5% 10% 90% 95% 99%
disp('1% 2.5% 5% 10% 90% 95% 99%')
disp(prctile(sto, [1 2.5 5 10 90 95 99]))

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% function [b,resid,vcv,tratio]=ols2(y,x,c)
% if c == 1;
% x=[x ones(rows(x),1)];
% end;
% if c == 2;
% x=[x ones(rows(x),1) seqa(1,1,rows(x))];
% end;
% df=rows(x)-cols(x);
% b=inv(x'*x)*x'*y;
% resid=y-x*b;
% sigsq=resid'*resid/df;
% vcv=sigsq*inv(x'*x);
% se=sqrt(diag(vcv));
% tratio=b./se;

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us