Estimating a regression model using matlab

2 ビュー (過去 30 日間)
ektor
ektor 2019 年 5 月 26 日
コメント済み: Jeff Miller 2019 年 5 月 27 日
Dear all,
I have this regression model
g=randn(1000,1); error=randn(1000,1);
g(2:end)=k1+ k2*(g(1:end-1)-k1) + error(2:end)*k3 ;
k1, k2 are intercept and slope parameters respectively and k3 is the standard deviation
Also the following restrictions must be satisfied: |k2|<1 and k3>0.
Is there a way to estimate such a model, given that 'error' and 'g' are known?
Thanks in advance

採用された回答

Jeff Miller
Jeff Miller 2019 年 5 月 27 日
g=randn(1000,1); error=randn(1000,1);
% Model: g(2:end)=k1+ k2*(g(1:end-1)-k1) + error(2:end)*k3 ;
y = g(2:end);
x1 = g(1:end-1);
x2 = error(2:end);
b = regress(y,[ones(size(x1)), x1, x2]);
k3 = b(3);
k2 = b(2);
k1 = b(1) / (1 - k2);
  2 件のコメント
ektor
ektor 2019 年 5 月 27 日
This approach does not satisfy the restrictions
Jeff Miller
Jeff Miller 2019 年 5 月 27 日
Sorry, I missed the restrictions.
Maybe with fminsearch. The error function would look something like this:
function sse = myErrFunc(x) % x is a vector of 3 reals
% Convert real x's to k's satisfying constraints
k1 = x(1);
k2 = x(2)^2/(1+x(2)^2); % abs(k2)<1
if x(2)<0
k2 = -k2;
end
k3 = x(3)^2; % k3 must be positive
global y, x, error % trim these in advance so they only contain 1:end-1 or 2:end
predicted = k1 + k2*(g-k1) + error*k3;
sse = sum((y-predicted).^2);
end

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeModeling についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by