MATLAB m文件错误求教
function = NR_logistic(data,beta_start)x=data(:1);
y=data(:2);
n=length(x)
a=1; b=1;beta = beta_start; % initial values
while a>0.0001|b>0.01 % convergence criterion
beta_old = beta;
p = exp(beta(1)+beta(2)*x)./(1+exp(beta(1)+beta(2)*x));
l = sum(y.*log(p)+(1-y).*log(1-p))
s = [sum(y-p); % scoring function
sum((y-p).*x)];
J_bar = [sum(p.*(1-p)) sum(p.*(1-p).*x); % information matrix
sum(p.*(1-p).*x) sum(p.*(1-p).*x.*x)]
beta = beta_old -inv(J_bar)*s % new value of beta
a =mean(sprt(sum((beta-beta_old)^2))); % sum of absolute differences
b=(beta-beta_old)./beta_old;
end
运行出错:?? Error: File: D:\MATLAB7.0\work\NR_logistic.m Line: 2 Column: 9
Missing MATLAB operator. x=data(:1);是多1或少个','?
x=data(:);或x=data(:,1);
回复 沙发 ChaChing 的帖子
哦,这个问题解决了,但是又有这样的错误:? Error: File: D:\MATLAB7.0\work\NR_logistic.m Line: 14 Column: 21
Missing variable or function. beta = beta_old -inv(J_bar)?
change to
beta = beta_old -inv(J_bar) 输入法问题导致出错
页:
[1]