资源简介
GMM估计是计量,金融,经济中常见的估计参数的一种方法
代码片段和文件信息
function [paraestt_staVitChi_staPvalue]=my_gmmestimation(momentpara0YXZnumberK)
%This program is for GMM estimation
%input:
%moment: moment conditions function defined by users
%para0:initial value for estimated parameters
%YX:data used to estimate parameters
%Z: data for instrument variables
%number: maximum convergence number when choosing optimal weighting matrix
%K:number of moment conditions
%output:
%paraest:parameters estimated
%t_sta: T statistics for each estimated parameter
%V:covariance matrix for estimated parameters
%it: number of iteration
%Chi_sta and Pvalue: overidentifying test null hypothesis is moment
%conditions are feasible
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%example1
%to estimate the following model:Y=alpha+beta*X+eta
%moment conditions:[E(eta);E(X*eta)]=0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%clear
%kk=1000;
%X=randn(kk1);Y=1+2*X+randn(kk1)/3;Z=[ones(kk1)X];number=100;
%para0=[0;1];
%[paraestt_staV]=gmmestimation(‘linearmodel01‘para0YXZnumber2)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%moment conditions
%function f=linearmodel01(paranumYXZW)
%[Tq]=size(Y);
%alpha=para(1);beta=para(2);
%eta=[Y-(alpha+beta*X)];
%for i=1:T
% m_t(i:)=kron(eta(i:)Z(i:));
%end
%m=mean(m_t)‘;
%obj=m‘*W*m;
%if num==1
%f=obj;
%elseif num==2
%f=m_t;
%elseif num==3
%f=m;
%end
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%example2
%to estimate the following model:
%dr_t =(alpha+beta*r_t)*dt+sigma*r_t^(gamma)*dW_t
%where W_t is a Brownian motion
%r_t is interest rate at time t and dr_t=r_t-r_t-1=y_t
%x_t=r_t-1dW_t=sqrt(dt)*eta_t
%eta_t is a standard normal random variabledefine y=[y_t]x=[x_t] xy are colummn vectors
%rewrite the model: y=(alpha+beta*x)*dt+sigma*x^(gamma)*dW
%instrument variables:z=[1x]
%moment conditions;
%kron([E(y-(alpha+beta*x)*dt);
%E(y-((alpha+beta*x)*dt)^2-sigma^2*x^(2*gamma)*dt)]z)=0
%kron(AB) means Kroneker product of A and B
%%%%%%%%%%%%%%%moment function
% function f=cklstest01(paranumYXZW)
% [Tq]=size(Y);
% alpha=para(1);beta=para(2);sigsq=para(3);gamma=para(4);
% eta=[Y-(alpha+beta*X)/12(Y-(alpha+beta*X)/12).^2-sigsq*X.^(2*gamma)/12];
% for i=1:T
%
- 上一篇:粒子群搜索代码
- 下一篇:排队理论 Matlab仿真
评论
共有 条评论