2

我正在尝试估计以下函数的参数:

u = log(x) - ω - φ*(log(h)) - δ1*z - δ2*(z^2-1)

我在 matlab 中使用 fminsearch 函数,代码如下:

data = xlsread('return_oc_out.xlsx');
a = data(:,25);

kernel = xlsread('RK_out.xlsx');
rkAA= kernel(:,25);

startingVals = [0.1 0.05 0.9 0.3];
T = size(a,1);

options = optimset('fminsearch');
options.Display = 'iter';
estimates = fminsearch(@residuiRK, startingVals, options, rkAA, h, a);
[ll, lls, u]=residuiRK(estimates, rkAA, h, a);

函数 residuiRK 具有以下代码:

function [ll, lls, u] = residuiRK(parameters, x_rk, h, data)
omega = parameters(1);
phi = parameters(2);
delta1 = parameters(3);
delta2 = parameters(4);

mu = mean(data);
T = size(data,1);
eps = data-mu;
z= eps./sqrt(exp(h));

lxRK=log(x_rk);
u = zeros(T,1);
for t = 1:T 
u(t) = lxRK(t) - omega - phi*h(t) - delta1*z(t) - delta2*(z(t).^2-1);
end 
lls = 0.5*(log(2*pi) + log(exp(h))+eps.^2./exp(h));
ll = sum(lls);

问题是: fminsearch 返回的估计参数等于我插入的起始值。为什么会出现这个问题?如果有人能解释一下,我将不胜感激。谢谢

4

1 回答 1

0

You should call your function like

[estimates, ~, exitflag, output] = fminsearch(...)

to diagnose your function call. exitflag should be 1 if the tolerance was reached, otherwise something wrong happened. output is a structure that you can consult to see the run summary of your fminsearch() call.

Also, your function call seems weird. You want to optimize over the parameters argument of residuiRK function, right? Then, why not passing the rest of arguments to your fminsearch minimized function? Like this:

estimates = fminsearch(@(x) residuiRK(x,rkAA,h,a), startingVals, options);

Later edit

So, based on the new info, apparently the exitflag of fminsearch() call is 1. Which means that the maximum coordinate difference between current best point and other points in simplex is less than or equal to options.TolX, and corresponding difference in function values is less than or equal to options.TolFun.

Your function might vary too slowly around startingVal. You could try to increase/decrease your tolerances. This can be done by modifying the options struct:

options = optimset('fminsearch');
options.Display = 'iter';
options.TolX = <some number>   % the default value is 0.0001
options.TolFun = <some number> % the default value is 0.0001

Try different values an see what happens to your values. If nothing happens, then apparently you guessed the minimum's position from the start. :-)

于 2014-06-26T11:28:30.357 回答