这是极非线性极大似然程序,运行的时候说红字部分有问题,硕士双精度输入参数没有定义Undefined function 'w' for input arguments of type 'double % This is the main program that finds MLE estimates. it takes takes sample size (T) and observed proportion correct % (r) as inputs.It returns the parameter values that maximize the log-likelihood function opts=optimset('DerivativeCheck','off','Display','off','TolX',1e-6,'TolFun',1e-6,'Diagnostics','off','MaxIter',200); % option settings for optimization algorithm global r; % define global variables data=xlsread('E:\Download\银行间质押式回购001.xls');%read the date of excel(according to your own file route) r=data(:,1); T=length(r); init_w=[0.1;0.1;0.1;0.1;0.1;0.1;0.1;0.1;0.1;0.1;0.1]';% starting parameter values low_w=-5*ones(1,11);% parameter lower bounds up_w=5*ones(1,11);% parameter upper bounds u=w(1,1)+w(1,2)*r+w(1,3)*r.^2+w(1,4)*r.^3+w(1,5)*r.^4+w(1,6)*r.^5+w(1,7)*r.^(-1); v=w(1,8)+w(1,9)*r+w(1,10)*r.^w(1,11); loglik=nonliner(w); for j=1:T-1; loglik=loglik-(T-1/2)*log2pi-(1/2)*m; m=m+log(v(j))+(r(j+1)-r(j)-u(j))^2/v(j); end loglik=(-1)*sum(loglik);% overall minus log-likelihood being minimized [w,lik,exit]=fmincon(@nonliner,init_w,[],[],[],[],low_w,up_w,[],opts); % optimization for model that minimizes minus log-likelihood (note that minimization of minus log-likelihood is equivalent to maximization of log-likelihood) % w: MLE parameter estimates % lik1: maximized log-likelihood value % exit1: optimization has converged if exit > 0 or not otherwise 运行结果: >> nonlinear Undefined function 'w' for input arguments of type 'double'. Error in nonlinear (line 12) u(r)=w(1,1)+w(1,2)*r+w(1,3)*r.^2+w(1,4)*r.^3+w(1,5)*r.^4+w(1,6)*r.^5+w(1,7)*r.^(-1); 哪位能帮忙解决下啊,毕业论文,着急啊! |


雷达卡



京公网安备 11010802022788号







