|
我也遇到相同问题。如果你的参数不超过7个 也许我可以帮你
我的是参数有12个 不能用fminsearch()函数
我用fminunc老出错 忘达人帮忙啊。
附我出错的程序如下:看起来很复杂,其实密度函数本来是混合正态分布,只是对参数又进行了假设所以变复杂了。
%----likelihood function M函数文件
function fun3=myfun(x,s,f,b)
r01=x(1);r11=x(2);r02=x(3);r12=x(4);f01=x(5);
nd01=x(6);nd11=x(7);nd02=x(8);nd12=x(9);f11=x(10);f02=x(11);f12=x(12);
pi1=(1+exp(f01+f11*b))/(2+exp(f01+f11*b)+exp(f02+f12*b));
mu1=(s-r01-r11*f).^2;mu2=(s-r02-r12*f).^2;
sd1=sqrt(2*pi*exp(nd01+nd11*b));
sd2=sqrt(2*pi*exp(nd02+nd12*b));
fun3=-sum(log(pi1*exp(-mu1/exp(nd01+nd11*b)/2)/sd1+(1-pi1)*exp(-mu2/exp(nd02+nd12*b)/2)/sd2));
%窗口主程序
clc
mydata1=xlsread('spot.xls');
mydata2=xlsread('future.xls');
mydata3=xlsread('basic.xls');
s=mydata1(:,1);
f=mydata2(:,1);
b=mydata3(:,1);
options=optimset('fminunc');
[x,fval,exitflag,output]=fminunc(@fun3,[0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5],options,s,f,b)
|