TOBIT function error message

1 view (last 30 days)
Nitay Cohen
Nitay Cohen on 26 Apr 2015
Commented: Geoff Hayes on 26 Apr 2015
Hi!
I'm quite new to MATLAB and I get strange error message I can't understand: "Error using MLobjective_1 (line 3) Not enough input arguments." My Code:
clc;
clear;
format('long');
load 'matlabdata'
X=[Y AGE MARRIED WOMAN KIDS ones(length(I),1)];
theta_ini=[0.1 0.1 0.1 1]';
options = optimset('display','iter','maxiter',10000,'maxfunevals',20000,'TolX',1e-12,'TolFun',1e-12);
tic
[theta,fval1,exitflag1,output1]=fminsearch(@(theta) MLobjective_1(theta,I,X),theta_ini,options)
toc
The function:
function f = MLobjective (theta,I,X)
beta=theta(1:4,1);
sigma=theta(5,1);
n=length(I);
for i=1:n;
if I(i,1)==0
lik_contribution(i,1)=(1-normcdf(X(i,:)*beta/sigma));
else
lik_contribution(i,1)=(1/sigma*normpdf(I(i)-X(i)*beta)/sigma);
end;
end
Can someone recognize where is the problem??
Thank you!
  1 Comment
Geoff Hayes
Geoff Hayes on 26 Apr 2015
Nitay - the error message is telling you that when MLobjective_1 is being called, not enough input arguments are being provided to it. According to the function signature, three inputs are expected (actually the signature is for a function named MLobjective - is this a typo or has a different function been provided?).

Sign in to comment.

Answers (0)

Categories

Find more on Just for fun in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!