资源简介
自适应动态规划matalab简单代码实现,适合初学者,代码可运行
代码片段和文件信息
clear all;
close all;
% Define the structural parameters of the model
% i.e. policy invariant preference and technology parameters
% alpha : capital‘s share of output
% beta : time discount factor
% delta : depreciation rate
% sigma : risk-aversion parameter also intertemp. subst. param.
% gamma : unconditional expectation of the technology parameter
alpha = .35;
beta = .98;
delta = .025;
sigma = 2;
zbar = 5;
% Find the steady-state level of capital as a function of
% the structural parameters
kstar = ((1/beta - 1 + delta)/(alpha*zbar))^(1/(alpha-1));
% Define the number of discrete values k can take
gk = 101;
k = linspace(0.95*kstar1.05*kstargk);
% Compute a (gk x gk) dimensional consumption matrix c
% for all the (gk x gk) values of k_t k_t+1
for h = 1 : gk
for i = 1 : gk
c(hi) = zbar*k(h)^alpha + (1-delta)*k(h) - k(i);
if c(hi) < 0
c(hi) = 0;
end
% h is the counter for the endogenous state variable k_t
% i is the counter for the control variable k_t+1
end
end
% Compute a (gk x gk) dimensional consumption matrix u
% for all the (gk x gk) values of k_t k_t+1
for h = 1 : gk
for i = 1 : gk
if sigma == 1
u(hi) = log(c(hi));
else
u(hi) = (c(hi)^(1-sigma) - 1)/(1-sigma);
评论
共有 条评论