Clear Filters
Clear Filters

Problem estimating variance-covariance matrix of multivariate normal with restrictions on variance-covariance using Maximum Likelihood.

5 views (last 30 days)
Hi all,
I am estimating a Vector Autoregression Model using Maximum Likelihood where I impose constraints on the variance-covariance matrix of residuals.
For Maximum Likelihood estimation, the set of parameters to optimize on is the set of betas coefficients and the sigmas, the variance-covariance matrix of residuals.
For this I am using fmincon where I pass the constraints and initial values. I am able to correctly impose restrictions on the regression coefficients but my procedure cannot "update" the varianc-covariance parameters. They remain stuck at their initial value. What I mean by that is that my procedure correctly estimates the betas coefficients but completely disregards the variance-covariance matrix.
I have tried the following:
  • Pass as initial values only the betas coefficients. This gives me the same answer as when I include the initial values for the variance-covariance matrix.
To clear things up, I post here the code to test:
% Main script
y=rand(100,3); % creates the dependent matrix
x=[ones(99,1) y(1:end-1,:)]; % creates the independent matrix
y=y(2:end,:); % accommodates the size
Ny=size(y,2); % number of dependent variables
[T,Nx]=size(x); % number of independent variables
betas_init=[zeros(1,3) ; diag(repmat(0.4,3,1))]; % initial values for betas
sigmas_init=cov(y); % initial values for sigmas; does not matter which I put
initparam=[vec(betas_init) ; vec(sigmas_init)];
% Testing restrictions
beq(1,1)=0.0004; % value can be changed
% Calling fmincon
[optparam] = fmincon(@(allparam) VAR_likelihood(y,x,allparam),[initparam],[],[],Aeq,beq,[],[],[],options);
% Function to be called
function [sum_lik]=VAR_likelihood(y,x,allparam)
betas=reshape(allparam(1:Nx*Ny),Nx,Ny); % gather the betas parameters from initparam/allparam
sigmas=reshape(allparam(1+Nx*Ny:Nx*Ny+Ny*Ny),Ny,Ny); % gather the sigmas parameters from initparam/allparam
allparam(1+Nx*Ny:Nx*Ny+Ny*Ny)=vec(errors'*errors/(T-1)); % pass the variance-covariance matrix to the set of params.
pdf=1/(((2*pi())^(Ny/2))*sqrt(det(sigmas))).* ... % compute the density
sum_lik = -sum(log(pdf)); % => same as Stata
fprintf(1,['The value of the likelihood is ' num2str(sum_lik),'\n']);
% Testing if the restrictions have been taken into account
varcov=error'*error/(T-1); % Clearly,
varcov == reshape(optparam(1+Nx*Ny:end),Ny,Ny) % but the restriction is passed to optparam.
I do not see why I am unable to pass the updating of the variance-covariance matrix to the allparam/optparam vector.
Thank you very much.
  1 Comment
charles alexander
charles alexander on 21 Nov 2020
there is an error in the size of x.
in the % main script,
the end -1 is wrong, it is +1. this creates the independent matrix for x.
try this, i hope it helps.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!