Code covered by the BSD License  

Highlights from
Sensitivity of T-Statistic (Asymptotic thumb rule)

from Sensitivity of T-Statistic (Asymptotic thumb rule) by Anurag Banerjee
Rule of Thumb: t-statistic being sensitive to nuisance parameters in variance.

tsensdemo
function tsensdemo
% 
% % This program calculates the ASYMPMTOTIC decision (Rule of Thumb) of the t-statistic
%  ( linear restrictions case) being sensitive to nuisance parameter in the variance covariance matrix.
%                       Cut and paste the function in your own file
%   Reference:  Banerjee, A.N. and J.R. Magnus (2000), On the sensitivity of the usual
%   t- and F-tests to covariance misspecification, Journal of Econometrics, 
%   Vol 95(10), pp 157-176.


X = [ones(100,1) (1:100)' rand(100,1)]; % generated data
C1 = [1 0 0]; % restriction on the intercept
C2 = [0 0 1]; % restriction on the \beta_3
n = length(X);
A = Derivative(n);  %    This is the derivative of the Omega matrix 
[decision1, RHO,ASY_MEAN,ASY_VARIANCE] = t_sens(X,C1,A)
[decision2, RHO,ASY_MEAN,ASY_VARIANCE] = t_sens(X,C2,A)
         
function [decision, RHO,ASY_MEAN,ASY_VARIANCE] =t_sens(X,C,T)

%   
%    Rule of Thumb: Banerjee, A.N. and J.R. Magnus (2000)
%           Testing for restriction C \beta = c0
%           The t-statistic is sensitive (at the 50% level) 
%           to covariance misspecification if and only if
%                           ???/c>0.40
%    input: X = the matrix of independent data (n x k)
%           C = the restriction k x 1
%           T = the Derivative of the covariance matrix at \theta = 0
%   In this demo the derivative matrix A is the derivative of
%   variance covariance matrix of AR(1)(same as MA(1))) at the \theta =0
%   where \theta is the AR(1) parameter.
%
%      Output : decision = 1 then  t-statistic is sensitive to
%                             nuisance parameter \theta 
%                          = 0 otherwise
%                RHO      = ???/c 
%                
%            ASY_MEAN,ASY_VARIANCE = asymptotic mean and variance of RHO
%  ------------------------------------------------------------------------
%   Reference: Banerjee, A.N. and J.R. Magnus (2000), On the sensitivity of the usual
%   t- and F-tests to covariance misspecification, Journal of Econometrics, 
%   Vol 95(10), pp 157-176.
%  ------------------------------------------------------------------------
% % /* ........... PROCEDURES FOR SENSITIVITY ............................
% 
%                 Anurag N Banerjee
%                 Durham University,
%                         UK
%                                         Date 17/11/2009
% ..............................................................
% This program is in the public domain.  While the author disclaims
% any responsibility for the performance of this software, he
% would appreciate receiving any comments.
% 
% This written by Anurag N Banerjee and may be distributed as freeware
% for public non-commercial use. Please provide appropriate
% acknowledgment if this supports supports published work.
% ..................................................................



    [n k] = size(X);
    XtX_1 = inv(X'*X);
    P = X*XtX_1*X';
    M = eye(n) - P;
    B = X*XtX_1*C'/sqrt(C*XtX_1*C');
    BTMTB = B'*T*M*T*B;
    BDB = B'*T*B ;

    CONST = sqrt(BDB^2+4*BTMTB); % Calculating  constant (c) 
    RHO = BDB/CONST; % Calculating  r of the product normal distribution */
    decision = (abs(RHO) > 0.4);
    
% the asymptotic mean and variance from the product normal approximation */
    ASY_MEAN = CONST*RHO; 
    ASY_VARIANCE = CONST*sqrt(1+RHO^2);
 
% @ --------------------
%   Derivative of Co-Variance Matrix of AR1 process
% ---------------------- @
function DV = Derivative(n);
DV =  zeros(n,n);
for i =1:n ;
    for j=1:n;
        if  (abs(i-j) == 1) ;
        DV(i,j) = -1;
        else;
        DV(i,j) = 0;
        end
    end
end


Contact us at files@mathworks.com