楼主: tulipsliu
984 2

[学科前沿] [DSGE] Lumpy Investment in the Open Economy [推广有奖]

促进中国计量经济学发展学科带头人

学科带头人

44%

还不是VIP/贵宾

-

威望
0
论坛币
386068 个
通用积分
469.4802
学术水平
127 点
热心指数
140 点
信用等级
103 点
经验
46970 点
帖子
1770
精华
0
在线时间
2486 小时
注册时间
2007-11-5
最后登录
2024-4-30

初级热心勋章

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

经管之家:Do the best economic and management education!
RenMin University of China .
Daniel tulips liu.
Advance DSGE model,MATLAB compile FORTRAN and ob ject-Oriented Programming.
Copyright @ Volker Tjaden,23.08.2013.


MATLAB ob ject-Oriented Programming

The result picture of this progrma

ob ject-Oriented Programming code

classdef Adjcosts
    % This class summarizes all possible adjustment cost distributions
    % and associated methods
    
    properties(SetAccess=private)
        disttype; %distribution type
        xibar; %maximum adjustment cost draw
        p;
        q;
    end
    
    methods
        function Dist=Adjcosts(type,varargin)
            % constructor function
            Dist.disttype=type;
            switch Dist.disttype
                case 'uniform'
                    Dist.xibar=cell2mat(varargin(1));
                case 'beta'
                    Dist.xibar=cell2mat(varargin(1));
                    Dist.p=cell2mat(varargin(2));
                    Dist.q=cell2mat(varargin(3));
            end
        end
        
        function fx=cdf(Dist,x)
            % evaluate cummulative distribution function
            switch Dist.disttype
                case 'uniform'
                    fx=x./Dist.xibar;
                    % make sure between zero and one
                    fx=max(0,fx);
                    fx=min(1,fx);
                    return
                case 'beta'
                    fx=betacdf(x./Dist.xibar,Dist.p,Dist.q);
                    return
            end
        end
        
        function e_b=exp_cost(Dist,b)
            % evalate conditional expectation conditional on values
            % beeing smaller than b
            switch Dist.disttype
                
                case 'uniform'
                    e_b=b./2;
                    e_b=min(e_b,Dist.xibar/2);
                    e_b=max(e_b,0);
                    return
                case 'beta'
                    b=max(0,min(b,Dist.xibar));
                    e_b=max(0,Dist.xibar*...
                        (beta(Dist.p+1,Dist.q)./...
                        (betainc(b,Dist.p,Dist.q)*beta(Dist.p,Dist.q))).*betainc(b,Dist.p+1,Dist.q));
            end
        end
    end
    
end

FORTRAN language file ,F90

myinterp3_mex.F90

!
!   myinterp3_mex.F90
!   
!
!   Created by Volker Tjaden on 20.08.2013.
!   Copyright 2013 __MyCompanyName__. All rights reserved.
!
#include "fintrf.h"

!-----------------------------------------------------------------------
! Gateway routine
!-----------------------------------------------------------------------

subroutine mexFunction(nlhs,plhs,nrhs,prhs)
    implicit none
	 ! Arguments in mexFunction
    mwPointer  :: plhs(*), prhs(*)
    integer    :: nlhs, nrhs
	
	! Function declarations
    mwPointer   ::  mxGetPr, mxCreateNumericArray
    mwPointer   ::  mxGetDimensions
	mwSize      ::  mxGetNumberOfDimensions
    integer(4)  ::  mxClassIDFromClassName
    integer(4)  ::  mxGetString
    mwPointer   ::  mxGetN , mxGetM

	! Pointers to input/output mxArrays:
	! Input
    mwPointer  :: x,y,z,fxyz,xi,yi,zi
	! Output
    mwPointer  :: fint
	
	! Array size information
	mwSize	  :: ndim
	mwSize	  :: dims(3)
	mwSize	  :: nxi,nyi,nzi
	integer(4)   :: classid
    integer(4)   :: complexflag

!-----------------------------------------------------------------------

	! Copy pointers
	x	= mxGetPr(prhs(1))
	y	= mxGetPr(prhs(2))
	z	= mxGetPr(prhs(3))
	fxyz= mxGetPr(prhs(4))
	xi  = mxGetPr(prhs(5))
	yi  = mxGetPr(prhs(6))
	zi  = mxGetPr(prhs(7))
	
	! Retrieve size information
	ndim= mxGetNumberOfDimensions(prhs(4))
	call mxCopyPtrToPtrArray(mxGetDimensions(prhs(4)),&
	dims, ndim)
	nxi=max(mxGetN(prhs(5)),mxGetM(prhs(5)))
	nyi=max(mxGetN(prhs(6)),mxGetM(prhs(6)))
	nzi=max(mxGetN(prhs(7)),mxGetM(prhs(7)))
	
	! Create return arguments
	classid = mxClassIDFromClassName('double')
    complexflag = 0  
      
    plhs(1) = mxCreateNumericArray(ndim,(/nxi,nyi,nzi/), classid, complexflag)
    fint = mxGetPr(plhs(1))

	! call subroutine
	call myinterp3(%val(fint),%val(fxyz),%val(x),%val(y),%val(z),&
		%val(xi),%val(yi),%val(zi),dims(1),dims(2),dims(3),&
		nxi,nyi,nzi)
	return
end subroutine

subroutine myinterp3(fint,fxyz,x,y,z,xi,yi,zi,nx,ny,nz,nxi,nyi,nzi)
    implicit none
	double precision, intent(out) :: fint(nxi,nyi,nzi)
	double precision, intent(in)  :: fxyz(nx,ny,nz)
	double precision, intent(in)  :: x(nx)
	double precision, intent(in)  :: y(ny)
	double precision, intent(in)  :: z(nz)
	double precision, intent(in)  :: xi(nxi)
	double precision, intent(in)  :: yi(nyi)
	double precision, intent(in)  :: zi(nzi)
	mwSize, intent(in)			  :: nx,ny,nz,nxi,nyi,nzi
	! Local variables
	integer						  :: i1,i2,i3,j1,j2,j3
	integer					      :: idx,idy,idz
	double precision			  :: wx(2),wy(2),wz(2)
	
	fint=0.d0
	
	! Loop over all dimensions to interpolate
	do i1=1,nzi
		! find neigbor,
		call locate(z,nz,zi(i1),idz)
		idz=max(min(idz,nz-1),1)
		! weight on right neigbor
		wz(2)=(zi(i1)-z(idz))/(z(idz+1)-z(idz))
		wz(1)=1.d0-wz(2)
		do i2=1,nyi
			call locate(y,ny,yi(i2),idy)
			idy=max(min(idy,ny-1),1)
			wy(2)=(yi(i2)-y(idy))/(y(idy+1)-y(idy))
			wy(1)=1.d0-wy(2)
			do i3=1,nxi
				call locate(x,nx,xi(i3),idx)
				idx=max(min(idx,nx-1),1)
				wx(2)=(xi(i3)-x(idx))/(x(idx+1)-x(idx))
				wx(1)=1.d0-wx(2)
				! Interpolation step
				do j1=1,2
					do j2=1,2
						do j3=1,2
							fint(i3,i2,i1)=fint(i3,i2,i1)+&
							wx(j3)*wy(j2)*wz(j1)*&
							fxyz(idx+j3-1,idy+j2-1,idz+j1-1)
						end do
					end do
				end do
			end do
		end do
	end do		
end subroutine

subroutine locate(xx,N,x,j)
	implicit none
	real(8), intent(in), dimension(N)		:: xx  ! lookup table
	mwSize, intent(in)						:: N   ! no elements of lookup table
	real(8), intent(in)						:: x   ! Value whose neares neighbors are to be found
	integer, intent(out)					:: j   ! returns j if xx(j)<x<xx(j+1),
												   ! 0 if value is to the left of grid,
												   ! N if value is to the right of grid
	! locals
	integer :: jl, jm, ju
	
	jl = 0
	ju = N+1
	
	do
		if ((ju-jl)==1) exit
		jm = (ju+jl)/2
		if ((xx(N) > xx(1)) .eqv. (x > xx(jm))) then 
			jl = jm
		else
			ju = jm
		end if
	end do											   
	
	! Set output
	if (x == xx(1)) then
		j = 1
	elseif (x == xx(N)) then
		j = N
	else
		j = jl
	end if
end subroutine locate

policies_on_mex.F90

!
!   myinterp3_mex.F90
!   
!
!   Created by Volker Tjaden on 23.08.2013.
!   Copyright 2013 __MyCompanyName__. All rights reserved.
!
#include "fintrf.h"

!-----------------------------------------------------------------------
! Gateway routine
!-----------------------------------------------------------------------

subroutine mexFunction(nlhs,plhs,nrhs,prhs)
    	implicit none
	! Arguments in mexFunction
    	mwPointer  :: plhs(*), prhs(*)
    	integer    :: nlhs, nrhs

    	! Function declarations
    	mwPointer   ::  mxGetPr, mxCreateNumericMatrix
    	integer(4)  ::  mxClassIDFromClassName
    	integer(4)  ::  mxGetString
    	mwPointer   ::  mxGetN , mxGetM

    	! Pointers to input/output mxArrays:
    	! Input
    	mwPointer  :: prices,EV,EV_down,EV_up,kgrid,q,rho,w,gam,del,b,beta,xibar
    	! Output
    	mwPointer  :: kopt,xihat,up,down,uncont,kopt_ind
	
    	! Array size information
    	mwSize	     :: nks, neps, mwOne
    	integer(4)   :: classid
    	integer(4)   :: complexflag

!-----------------------------------------------------------------------
	! Copy pointers
	prices	= mxGetPr(prhs(1))
	EV	= mxGetPr(prhs(2))
	EV_down = mxGetPr(prhs(3))
	EV_up   = mxGetPr(prhs(4))
	kgrid	= mxGetPr(prhs(5))
	q	= mxGetPr(prhs(6))
	rho	= mxGetPr(prhs(7))
	w	= mxGetPr(prhs(8))
	gam	= mxGetPr(prhs(9))
	del	= mxGetPr(prhs(10))
	b	= mxGetPr(prhs(11))
	beta	= mxGetPr(prhs(12))
	xibar   = mxGetPr(prhs(13))	

	! Retrieve size information
	nks	= mxGetM(prhs(2))
	neps    = mxGetN(prhs(2))	

	! Create return arguments
	complexflag = 0  
	mwOne=1	

	classid = mxClassIDFromClassName('double')      
    	plhs(1) = mxCreateNumericMatrix(mwOne,neps,classid, complexflag)
    	kopt = mxGetPr(plhs(1))
	plhs(2) = mxCreateNumericMatrix(nks,neps,classid, complexflag)	
	xihat = mxGetPr(plhs(2))

	classid = mxClassIDFromClassName('logical')  
	plhs(3) = mxCreateNumericMatrix(nks,neps,classid, complexflag)
    	up = mxGetPr(plhs(3))
	plhs(4) = mxCreateNumericMatrix(nks,neps,classid, complexflag)
    	down = mxGetPr(plhs(4))
	plhs(5) = mxCreateNumericMatrix(nks,neps,classid, complexflag)
    	uncont = mxGetPr(plhs(5))
	classid = mxClassIDFromClassName('double')  
  	plhs(6) = mxCreateNumericMatrix(mwOne,neps,classid, complexflag)
    	kopt_ind = mxGetPr(plhs(6))
	
	! call subroutine
	call policies_on(%val(kopt),%val(xihat),%val(up),%val(down),&
		%val(uncont),%val(kopt_ind),%val(EV),%val(EV_down),&
		%val(EV_up),%val(kgrid),%val(q),%val(rho),%val(w),&
		%val(gam),%val(del),%val(b),%val(beta),%val(xibar),nks,neps)

	return
end subroutine

subroutine policies_on(kopt,xihat,up,down,uncont,kopt_ind,&
	EV,EV_down,EV_up,kgrid,q,rho,w,&
	gam,del,b,beta,xibar,nks,neps)
	implicit none
	real(8), intent(out)	:: kopt(neps)
	real(8), intent(out)	:: xihat(nks,neps)
	!logical*1, intent(out)	:: up(nks,neps)
	!logical*1, intent(out)	:: uncont(nks,neps)
	!logical*1, intent(out)	:: down(nks,neps)
	integer*1, intent(out)	:: up(nks,neps)
	integer*1, intent(out)	:: uncont(nks,neps)
	integer*1, intent(out)	:: down(nks,neps)
	real(8), intent(out)	:: kopt_ind(neps)
	real(8), intent(in)	:: EV(nks,neps)
	real(8), intent(in)	:: EV_down(nks,neps)
	real(8), intent(in)	:: EV_up(nks,neps)
	real(8), intent(in)	:: kgrid(nks)
	real(8), intent(in)	:: q,rho,w,gam,del,b,beta,xibar
	mwSize, intent(in)	:: nks,neps
	! local variables	
	integer(4)		:: i1,ind,pos,i2
	real(8)			:: E,EC,vbest,vcand
	
	! Loop over idiosyncratic productivity states
	ind=1	
	do i1=1,neps
		! 1. Find capital choice
		pos=0
		vbest=-huge(vbest)
		if (i1>1) then
			ind=int(kopt_ind(i1-1),4)
		end if
		do while (ind<=nks)
			vcand=-gam*kgrid(ind)*q*rho&
			+beta*EV(ind,i1)
			if (vcand>vbest) then
				vbest=vcand
				pos=ind
			else
				exit
			end if
			ind=ind+1
		end do
		E=vbest
		kopt_ind(i1)=real(pos,8)
		kopt(i1)=kgrid(pos)

		! 2. Check whether optimal choice is within constrained
		!    set and if not, in what direction constrain
		do i2=1,nks
			! (EC-repmat(E,mpar.nksim,1))./(rho*w);
			if (((1.d0-del+b)/gam)*kgrid(i2)<kopt(i1)) then
				up(i2,i1)=1 !.true.
				EC=-(1.d0-del+b)*kgrid(i2)*q*rho+&
					beta*EV_up(i2,i1)
				xihat(i2,i1)=-(EC-E)/(rho*w)
				xihat(i2,i1)=min(xibar,max(0.d0,xihat(i2,i1)))
			elseif(((1.d0-del-b)/gam)*kgrid(i2)>kopt(i1)) then
				down(i2,i1)=1 !.true.
				EC=-(1.d0-del-b)*kgrid(i2)*q*rho+&
					beta*EV_down(i2,i1)
				xihat(i2,i1)=-(EC-E)/(rho*w)
				xihat(i2,i1)=min(xibar,max(0.d0,xihat(i2,i1)))
			else
				uncont(i2,i1)=1!.true.
				xihat(i2,i1)=0.d0
			end if
		end do
	end do			

end subroutine

MATLAB main sc ripts file

mainsc ript.m

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Lumpy Investment in the Open Economy
% 
 % Version 2.0
%   - Fluctuations in aggregate world-tfp
%   - Small-scale adjustments
%   - Different adjustment cost distributions
%
% 	Date of last change: 13/08/2013
%   Authors: Christian Bayer, Volker Tjaden, Uni Bonn
%
% - Continues alogrithm until F-Test indicates no
% significant difference
%
%   main.m needs the following function-files for execution
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clear all
close all
clc
setenv('PATH', [getenv('PATH') ';D:\PGI\win64\12.9\bin']);
Computername='Celsius';

% Parameters for parallel execution
mpar.nblocks=49;
mpar.nblocks_local=3;
% Dependencies
addpath('../functions')
addpath('../functions/mex')

pool = 'local'
%
%% Start matlab pool

% Declare dependencies (Depends on machine and
% for baseline
dependencies={'Price','updatestep','Adjcosts.m','policies',...
    'simulation','mclearing','plant_statistics',...
    'myinterp3_mex.mexa64','ppval_mex.mexa64','spcoefs_mex.mexa64',...
    'myinterp4_mex.mexa64','policies_on_mex.mexa64','myinterp3_mex.mexmaci64','ppval_mex.mexmaci64','spcoefs_mex.mexmaci64',...
    'myinterp4_mex.mexmaci64','policies_on_mex.mexmaci64'};




% Quadratic dependencies
% baseline
dependencies_qdr={'Price','updatestep_qdr','policies_qdr',...
    'simulation_qdr','mclearing_qdr',...
    'myinterp3_mex.mexa64','ppval_mex.mexa64','spcoefs_mex.mexa64',...
    'policies_on_qdr'};

dependencies=union(dependencies,dependencies_qdr);

if matlabpool('size') == 0 % checking to see if my pool is already open
    matlabpool('open',pool,mpar.nblocks_local)
    matlabpool('addfiledependencies',dependencies)
else
    matlabpool updatefiledependencies
end

%% Initialize value functions
% for constraint adjustment
%&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
% Guide to dimensionality
% 1 - firm capital stock
% 2 - Home aggregate capital
% 3 - Foreign aggregate capital
% 4 - Difference in log-tfp
% 5 - Sum in log-tfp
%Set parameters
[par,mpar] = set_parameters(mpar);
Val_Home=zeros(mpar.nk,mpar.nK,mpar.nK,mpar.nz_d,mpar.nz_s);
Val_Foreign=zeros(mpar.nk,mpar.nK,mpar.nK,mpar.nz_d,mpar.nz_s);

load('initial.mat');

%% Simulations for Table 2 (Frictionless, Fixed Costs, Quadratic Costs)



% Data


% Fixed Costs
resultfile=['../results/TABLE_TWO.mat'];
tempfile=['../results/temp.mat'];
initial=initial_guesses(1);
[par,mpar] = set_parameters(mpar);
main_fixcost
initial_guesses(1).alpha_world=par.alpha_world;
initial_guesses(1).alpha_diff=par.alpha_diff;
initial_guesses(1).alpha_lam=par.alpha_lam;
initial_guesses(1).alpha_tau=par.alpha_tau;
save initial initial_guesses
clear BCstats
BCstats=BCS(par,mpar);

TABLE_TWO.alpha_world(:,3)=par.alpha_world;
TABLE_TWO.alpha_diff(:,3)=par.alpha_diff;
TABLE_TWO.alpha_lam(:,3)=par.alpha_lam;
TABLE_TWO.alpha_tau(:,3)=par.alpha_tau;
TABLE_TWO.var(:,3)=BCstats.var;
TABLE_TWO.relvar(:,3)=BCstats.relvar;
TABLE_TWO.autocorr(:,3)=BCstats.autocorr;
TABLE_TWO.corr(:,3)=BCstats.corr;
TABLE_TWO.xibar(:,3)=par.xibar;
TABLE_TWO.omega(:,3)=par.omega;

% Quadratic Costs
[par,mpar] = set_parameters(mpar);
mpar.kmin=0.7*par.kss;
mpar.kmax=6*par.kss;
mpar.Kmin=1.2*par.kss;
mpar.Kmax=2.25*par.kss;

initial=initial_guesses(2);

par.phi=0.155;
%Set Value functions to zero (Different dimensionailty to what
%main_fixcosts needs)
Val_Home=zeros(mpar.nk,mpar.nK,mpar.nK,mpar.nz_d,mpar.nz_s);
Val_Foreign=zeros(mpar.nk,mpar.nK,mpar.nK,mpar.nz_d,mpar.nz_s);

main_qdr
initial_guesses(2).alpha_world=par.alpha_world;
initial_guesses(2).alpha_diff=par.alpha_diff;
initial_guesses(2).alpha_lam=par.alpha_lam;
initial_guesses(2).alpha_tau=par.alpha_tau;
save initial initial_guesses
clear BCstats
BCstats=BCS(par,mpar);

TABLE_TWO.alpha_world(:,4)=par.alpha_world;
TABLE_TWO.alpha_diff(:,4)=par.alpha_diff;
TABLE_TWO.alpha_lam(:,4)=par.alpha_lam;
TABLE_TWO.alpha_tau(:,4)=par.alpha_tau;
TABLE_TWO.var(:,4)=BCstats.var;
TABLE_TWO.relvar(:,4)=BCstats.relvar;
TABLE_TWO.autocorr(:,4)=BCstats.autocorr;
TABLE_TWO.corr(:,4)=BCstats.corr;
TABLE_TWO.xibar(:,4)=par.xibar;
TABLE_TWO.omega(:,4)=par.omega;

% Frictionless
[par,mpar] = set_parameters(mpar);
mpar.kmin=0.7*par.kss;
mpar.kmax=6*par.kss;
mpar.Kmin=1.2*par.kss;
mpar.Kmax=2.25*par.kss;

initial=initial_guesses(3);

par.phi=0;
%Set Value functions to zero (Different dimensionailty to what
%main_fixcosts needs)
%Val_Home=zeros(mpar.nk,mpar.nK,mpar.nK,mpar.nz_d,mpar.nz_s);
%Val_Foreign=zeros(mpar.nk,mpar.nK,mpar.nK,mpar.nz_d,mpar.nz_s);

main_qdr
initial_guesses(3).alpha_world=par.alpha_world;
initial_guesses(3).alpha_diff=par.alpha_diff;
initial_guesses(3).alpha_lam=par.alpha_lam;
initial_guesses(3).alpha_tau=par.alpha_tau;
save initial initial_guesses
clear BCstats
BCstats=BCS(par,mpar);

TABLE_TWO.alpha_world(:,2)=par.alpha_world;
TABLE_TWO.alpha_diff(:,2)=par.alpha_diff;
TABLE_TWO.alpha_lam(:,2)=par.alpha_lam;
TABLE_TWO.alpha_tau(:,2)=par.alpha_tau;
TABLE_TWO.var(:,2)=BCstats.var;
TABLE_TWO.relvar(:,2)=BCstats.relvar;
TABLE_TWO.autocorr(:,2)=BCstats.autocorr;
TABLE_TWO.corr(:,2)=BCstats.corr;
TABLE_TWO.xibar(:,2)=par.xibar;
TABLE_TWO.omega(:,2)=par.omega;

%Taken from oecd_stats in Data. Run bcstats_oecd.m to generate the xls file
TABLE_TWO.var(:,1)=1.96* [1	2.82	1.03	0.72	2.25	3.02	0.50	2.08]';
TABLE_TWO.relvar(:,1)= [1	2.82	1.03	0.72	2.25	3.02	0.50	2.08]';
TABLE_TWO.autocorr(:,1)=[0.60	0.65	0.68	0.57	0.49	0.50	0.57	0.45]';
TABLE_TWO.corr(:,1)=[1.00	0.85	0.82	0.61	0.38	0.79	-0.43	-0.06]';

Bibliography

Stéphane Adjemian, Houtan Bastani, Fréderic Karamé, Michel Juillard, Junior Maih, Ferhat Mihoubi,George Perendia, Johannes Pfeifer, Marco Ratto, and Sébastien Villemot. Dynare: Reference Manual Version 4. Dynare Working Papers 1, CEPREMAP, April 2011.
Yann Algan, Olivier Allais, Wouter J. Den Haan, and Pontus Rendahl. Chapter 6 - solving and simulating models with heterogeneous agents and aggregate uncertainty. In Karl Schmedders and Kenneth L. Judd,editors, Handbook of Computational Economics Vol. 3, volume 3 of Handbook of Computational Economics,pages 277 – 324. Elsevier, 2014. doi: http://dx.doi.org/10.1016/B978-0-444-52980-0.00006-2.
Sungbae An and Frank Schorfheide. Bayesian analysis of dsge models. Econometric Reviews, 26(2-4):113–172,2007. doi: 10.1080/07474930701220071.
Lawrence J. Christiano, Martin Eichenbaum, and Charles Evans. Nominal rigidities and the dynamic effects of a shock to monetary policy. Working Paper 8403, National Bureau of Economic Research, July 2001.
Andrea L. Eisfeldt and Tyler Muir. Aggregate Issuance and Savings Waves. NBER Working Papers 20442,National Bureau of Economic Research, Inc, September 2014.
Jesús Fernández-Villaverde, Juan F. Rubio Ramírez, and Frank Schorfheide. Solution and estimation methods for dsge models. Working Paper 21862, National Bureau of Economic Research, January 2016.
Andrew Gelman and Donald B. Rubin. Inference from iterative simulation using multiple sequences. Statist.Sci., 7(4):457–472, 11 1992. doi: 10.1214/ss/1177011136.
J. Geweke. Contemporary Bayesian Econometrics and Statistics. John Wiley, 2005.
Lars Peter Hansen and James J. Heckman. The Empirical Foundations of Calibration. Journal of Economic Perspectives, 10(1):87–104, Winter 1996.
Peter N. Ireland. Technology Shocks in the New Keynesian Model. The Review of Economics and Statistics,86(4):923–936, November 2004.
Kenneth L. Judd. Numerical Methods in Economics. MIT Press, 1998.
Alejandro Justiniano, Giorgio Primiceri, and Andrea Tambalotti. Investment Shocks and the Relative Price of Investment. Review of Economic Dynamics, 14(1):101–121, January 2011.
Aubhik Khan and Julia K. Thomas. Idiosyncratic Shocks and the Role of Nonconvexities in Plant and Aggregate Investment Dynamics. Econometrica, 76(2):395–436, 03 2008.
Mario J. Miranda and Paul L. Fackler. Applied Computational Economics and Finance. MIT Press, Cambridge,MA, USA, 2002. ISBN 0262134209.

测试插入图片

好像不成功,还不太顺手 Markdown 文件。

图片2
测试图片

-表格

knitr::kable(m)
CVXR.soln
β1\beta_{1} 0.000000000000
β2\beta_{2} -3.709418467534
β3\beta_{3} -2.285371048930
β4\beta_{4} 0.000000000000
β5\beta_{5} 0.033081598479
β6\beta_{6} 0.845256267755
β7\beta_{7} 1.526459817851
β8\beta_{8} 3.562817222139
β9\beta_{9} 4.181218564517
β10\beta_{10} 4.397059387273

rugarch package table test

2020/06/11 add by tulipsliu

*---------------------------------*
*          GARCH Model Fit        *
*---------------------------------*

Conditional Variance Dynamics 	
-----------------------------------
GARCH Model	: sGARCH(1,1)
Mean Model	: ARFIMA(1,0,1)
Distribution	: norm 

Optimal Parameters
------------------------------------
        Estimate  Std. Error  t value Pr(>|t|)
mu     -0.006096    0.008739  -0.6976 0.485426
ar1    -0.409944    0.302402  -1.3556 0.175219
ma1     0.464602    0.293532   1.5828 0.113468
omega   0.011528    0.002916   3.9530 0.000077
alpha1  0.160495    0.026845   5.9787 0.000000
beta1   0.795690    0.033736  23.5855 0.000000

Robust Standard Errors:
        Estimate  Std. Error  t value Pr(>|t|)
mu     -0.006096    0.009072 -0.67197 0.501601
ar1    -0.409944    0.300539 -1.36403 0.172559
ma1     0.464602    0.292434  1.58874 0.112119
omega   0.011528    0.006431  1.79261 0.073036
alpha1  0.160495    0.048002  3.34353 0.000827
beta1   0.795690    0.066572 11.95230 0.000000

LogLikelihood : -1103.88988216 

Information Criteria
------------------------------------
                   
Akaike       1.1245
Bayes        1.1415
Shibata      1.1245
Hannan-Quinn 1.1307

Weighted Ljung-Box Test on Standardized Residuals
------------------------------------
                        statistic p-value
Lag[1]                     0.1174  0.7318
Lag[2*(p+q)+(p+q)-1][5]    1.2283  0.9998
Lag[4*(p+q)+(p+q)-1][9]    2.2781  0.9694
d.o.f=2
H0 : No serial correlation

Weighted Ljung-Box Test on Standardized Squared Residuals
------------------------------------
                        statistic p-value
Lag[1]                      2.169  0.1408
Lag[2*(p+q)+(p+q)-1][5]     3.163  0.3781
Lag[4*(p+q)+(p+q)-1][9]     4.920  0.4413
d.o.f=2

Weighted ARCH LM Tests
------------------------------------
            Statistic Shape Scale P-Value
ARCH Lag[3]     1.469 0.500 2.000  0.2255
ARCH Lag[5]     1.471 1.440 1.667  0.6000
ARCH Lag[7]     3.274 2.315 1.543  0.4634

Nyblom stability test
------------------------------------
Joint Statistic:  1.2113
Individual Statistics:             
mu     0.1599
ar1    0.1810
ma1    0.1858
omega  0.3695
alpha1 0.2737
beta1  0.3562

Asymptotic Critical Values (10% 5% 1%)
Joint Statistic:     	 1.49 1.68 2.12
Individual Statistic:	 0.35 0.47 0.75

Sign Bias Test
------------------------------------
                   t-value   prob sig
Sign Bias           1.5222 0.1281    
Negative Sign Bias  0.0156 0.9876    
Positive Sign Bias  0.7968 0.4256    
Joint Effect        3.1404 0.3705    


Adjusted Pearson Goodness-of-Fit Test:
------------------------------------
  group statistic p-value(g-1)
1    20     117.3    3.498e-16
2    30     133.6    2.272e-15
3    40     146.4    2.454e-14
4    50     153.3    1.127e-12


Elapsed time : 0.219413042068 

> coef(fit)
               mu               ar1               ma1             omega            alpha1 
-0.00609622945246 -0.40994374751906  0.46460158552654  0.01152847660338  0.16049501344632 
            beta1 
 0.79569039675846

knitr::kable(coef(fit))

x
μ\mu -0.006096229452
ar1 -0.409943747519
ma1 0.464601585527
ω\omega 0.011528476603
α1\alpha1 0.160495013446
beta1beta1 0.795690396758
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:open economy Investment investmen Economy Invest

劳动经济学
沙发
西门高 发表于 2020-6-13 21:10:33 |只看作者 |坛友微信交流群
谢谢好东西

使用道具

藤椅
tulipsliu 在职认证  发表于 2020-6-13 21:18:34 |只看作者 |坛友微信交流群
西门高 发表于 2020-6-13 21:10
谢谢好东西
我是不是有点不厚道?
没有给源代码,其实有源代码的。还没压缩文件发论坛。如果有需要我在回复里添加上来。

如果想一起学习,可以加我tencent

280201722 潇湘旭

共勉,加油。

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-3 17:11