我遇到了以下问题。我有两个带有每日拦截估计的向量,我假设拦截的行为都分别遵循OU过程。但是,拦截之间存在很强的相关性,因此为了处理两个OU进程,我想关联两个OU进程的维纳进程。问题:我不知道如何在我的代码中实现相关系数,可能有人可以帮助我:我正在运行以下代码:
%model intercept
x = inter_w;
dx = diff(x);
dt = 1/252; % Time in years (252 observations per year)
dxdt = dx/dt;
x(end) = []; % To ensure the number of elements in x and dxdt match
% Fit a linear trend to estimate mean reversion parameters
coeff = polyfit(x, dxdt, 1);
res = dxdt - polyval(coeff, x);
revRate = -coeff(1)
meanLevel = coeff(2)/revRate
vol = std(res) * sqrt(dt)
OUmodel = hwv(revRate, meanLevel, vol, 'StartState', inter_w(507,1), 'Correlation', corr)
第二个OU过程
y = inter_s; dy = diff(y);
dt = 1/252; % Time in years (252 observations per year)
dydt = dy/dt; y(end) = []; % To ensure the number of elements in x and dxdt match
% Fit a linear trend to estimate mean reversion parameters
coeffy = polyfit(y, dydt, 1);
resy = dydt - polyval(coeffy, y);
revRatey = -coeffy(1)
meanLevely = coeffy(2)/revRatey
voly = std(resy) * sqrt(dt)
y = inter_s;
dy = diff(y);
dt = 1/252; % Time in years (252 observations per year)
dydt = dy/dt;
y(end) = []; % To ensure the number of elements in x and dxdt match
% Fit a linear trend to estimate mean reversion parameters
coeffy = polyfit(y, dydt, 1);
resy = dydt - polyval(coeffy, y);
revRatey = -coeffy(1)
meanLevely = coeffy(2)/revRatey
voly = std(resy) * sqrt(dt)
OUmodely = hwv(revRatey, meanLevely, voly, 'StartState', inter_s(507,1), 'Correlation', corr)
如果我理解这个解释,我的维纳过程现在与相关系数相关" corr"。但是,如果我模拟1000个inter_w和1000个inter_s,那些进程之间的相关性甚至不接近" corr" ..我在某个地方犯了一个错误,但不知道在哪里..谢谢你的回复