您好,欢迎访问三七文档
这个notes纯粹是扫盲用的。我用了一个最简单的线性DSGE,只有两个方程。先是我用手算的方法找到saddle-path的policyfunction,然后手算出impulseresponsefunction。这些我都用Dynare做了计算,程序和结果都写在note里面。上面是我note的截图,这个DSGE模型实际上就是一个linearrationalexpecationmodel(LREM),但DSGE的线性化后的本质也就是个LRE。虽然这个note提供的模型非常简单,但是思路在于如何用Dynare来深入学习这个动态系统。有几个事情需要大家自己来做:1.beta和rho的大小,大家从换很多次calibration,看能对IRF带来什么影响?2.beta和rho都大于1的时候,你应该怎么修改模型,为了维持模型的稳定性?3.看修改shock的stardarddeviation能对模型带了什么影响?4.如果你再加一个方程进去呢?什么样子的方程?以上内容我都试验过了。这个东西没法帮大家试验,所以大家必须自己试着做。这样你可以学到很多关于动态系统的感性认识。之后,我用最大似然估计对参数估计,然后我故意制造under-identification的问题,让大家看一下结果是什么样子。最后就是Bayesianestimation,我只估计了1个参数,用了2条平行马尔科夫链,做了超超短程模拟(只有500次,正常情况都是100000),为了省时间(我电脑只用50秒左右),所以我并没有让电脑跑很长的马尔科夫链和多个平行链条。所以结果非常差,但是这不是的目的。目的还是在于让从来没见过整个估计过程的同学看到一个全貌。所以我没有提及理论内容,或者是一带而过。对于Bayesianestimation,有个地方要注意的就是shock的个数必须大于等observable的个数,这是启动Kalmanfilter模拟likelihoodfunction的充分条件。Kalmanfilter是一个极其复杂的算法,计量经济学上面用来模拟likelihoodfunction。以后我会有一个贴子专门来展开Kalmanfilter的内部结构。notes下载SimplestDSGE.pdf(257.99KB)关于模型具体推导和模拟的例子,请看第六个帖子DSGE模型讨论之六——新古典增长模型(入门级DSGE)的推导和Dynare模擬关于模型求解方法,比如Blanchard-Khan,Uhlig方法,看第三个帖子DSGE模型讨论之三——线形理性预期模型(Linearrationalexpectationmodel)如果你连DSGE是什么都不知道,看针对DSGE模型学习的建议性计划(原创)关于DSGE求解和模型参数估计的一些认识(原创)dynaresimplemodelConfiguringDynare...[mex]GeneralizedQZ.[mex]Sylvesterequationsolution.[mex]Kroneckerproducts.[mex]Sparsekroneckerproducts.[mex]Localstatespaceiteration(secondorder).[mex]Bytecodeevaluation.[mex]k-orderperturbationsolver.[mex]k-ordersolutionsimulation.[mex]QuasiMonte-Carlosequence(Sobol).[mex]MarkovSwitchingSBVAR.StartingDynare(version4.3.3).Startingpreprocessingofthemodelfile...Found2equation(s).Evaluatingexpressions...doneComputingstaticmodelderivatives:-order1Computingdynamicmodelderivatives:-order1Processingoutputs...donePreprocessingcompleted.StartingMATLAB/Octavecomputing.STEADY-STATERESULTS:x0y0EIGENVALUES:ModulusRealImaginary0.90.901.1111.1110Thereare1eigenvalue(s)largerthan1inmodulusfor1forward-lookingvariable(s)Therankconditionisverified.Residualsofthestaticequations:Equationnumber1:0Equationnumber2:0MODELSUMMARYNumberofvariables:2Numberofstochasticshocks:2Numberofstatevariables:1Numberofjumpers:1Numberofstaticvariables:0MATRIXOFCOVARIANCEOFEXOGENOUSSHOCKSVariableseue0.0100000.000000u0.0000000.010000POLICYANDTRANSITIONFUNCTIONSyxx(-1)4.7368420.900000e5.2631581.000000u1.0000000MOMENTSOFSIMULATEDVARIABLESVARIABLEMEANSTD.DEV.VARIANCESKEWNESSKURTOSISy-0.3479661.2792061.636369-0.0766290.045543x-0.0656400.2423470.058732-0.0916980.036069CORRELATIONOFSIMULATEDVARIABLESVARIABLEyxy1.00000.9970x0.99701.0000AUTOCORRELATIONOFSIMULATEDVARIABLESVARIABLE12345y0.91270.82440.73640.65810.5958x0.91630.82950.74260.66920.6119Loading900observationsfromSimul_data.matInitialvalueofthelogposterior(orlikelihood):-14016.6527Warning:OptionsLargeScale='off'andAlgorithm='trust-region-reflective'conflict.IgnoringAlgorithmandrunningactive-setalgorithm.Toruntrust-region-reflective,setLargeScale='on'.Torunactive-setwithoutthiswarning,useAlgorithm='active-set'.Infminconat454Indynare_estimation_1at228Indynare_estimationat70Insimplemodelat129Indynareat120Warning:Yourcurrentsettingswillrunadifferentalgorithm(interior-point)inafuturerelease.Infminconat458Indynare_estimation_1at228Indynare_estimationat70Insimplemodelat129Indynareat120MaxLinesearchDirectionalFirst-orderIterF-countf(x)constraintsteplengthderivativeoptimalityProcedure0314016.7-0.1917-1447.33-0.0950.5-1.1e+055.09e+04213-1577.29-0.083130.125-2.88e+048.91e+03317-1579.48-0.041560.5-2444.29e+03422-1587.63-0.077590.25-3411.9e+03529-1588.01-0.074790.0625-29356.2632-1588.68-0.082741-76.1390735-1589.03-0.085021-48.8980838-1589.17-0.086231-140110941-1589.19-0.084361-11.317.61044-1589.19-0.083481-3.358.11147-1589.19-0.083451-0.720.0422Localminimumpossible.Constraintssatisfied.fminconstoppedbecausethesizeofthecurrentsearchdirectionislessthantwicetheselectedvalueofthestepsizetoleranceandconstraintsaresatisfiedtowithinthedefaultvalueoftheconstrainttolerance.stoppingcriteriadetailsNoactiveinequalities.POSTERIORKERNELOPTIMIZATIONPROBLEM!(minus)thehessianmatrixatthemodeisnotpositivedefinite!=posteriorvarianceoftheestimatedparametersarenotpositive.Youshouldtrytochangetheinitialvaluesoftheparametersusingtheestimated_params_initblock,oruseanotheroptimizationroutine.Warning:Theresultsbelowaremostlikelywrong!Indynare_estimation_1at480Indynare_estimationat70Insimplemodelat129Indynareat120MODECHECKFvalobtainedbytheminimizationroutine:-1589.188769RESULTSFROMMAXIMUMLIKELIHOODparametersEstimates.d.t-statbeta0.89350.00000.0000rho0.90650.00000.0000Totalcomputingtime:0h00m07s
本文标题:07[经济学模型]DSGE模型讨论之七最简单的DSGE模型的Dynare模拟和MLE,Bayesia
链接地址:https://www.777doc.com/doc-3052402 .html