Estimating a regression model using matlab

조회 수: 1 (최근 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 CenterFile Exchange에서 Modeling에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by