【发布时间】:2014-04-18 03:13:15
【问题描述】:
我在 Matlab 的第一个晚上遇到了一些麻烦。我猜我是在 R 中获得桂冠......
我正在尝试解决一个欧拉方程的无限时间平衡问题。
Matlab 似乎更适合在这个问题中进行优化,但我刚开始定义函数时遇到了一些问题。这是我所拥有的:
%% ECON 20210 Honors Problem Set #2 Code
%% Writen By Jacob Miller
%% Date 4/17/2014
%% In this problem, you have to write
%% a program to solve the following social planner problem:
%% Maximize The sum from t=1 to T over Ct,Nt, Kt+1 of the function
%% sum from t=1 to T of B^t-1*(Ct^(1-y)/1-y)-psi*log(n)
%% subject to the constraint Ct=A(kt^a)*(nt^1-a)+(1-d)Kt-Kt+1
function [eul] = funkone(c,y,p,n)
eul = (power(c,minus(1,y))/minus(1,y)-p*log(n));
现在正在返回错误:
EDU>> MillerEconPset2
Error using MillerEconPset2 (line 12)
Not enough input arguments.
似乎认为我正在尝试运行该函数,但我只想定义它。我在 R 中有一个类似的脚本:
myfunc<-function(c,y,n,p){
(c^(1-y))/(1-y)-n*log(p)
}
但不幸的是,R 在求解全局均衡方面几乎没有那么好。知道如何修复 Matlab 代码吗?
感谢十亿。
最好的,
杰克
【问题讨论】:
-
MillerEconPset2 是脚本文件吗?如果可以,我们可以查看吗?
标签: r matlab function maximize