Estimating a regression model using matlab

2 vues (au cours des 30 derniers jours)
ektor
ektor le 26 Mai 2019
Commenté : Jeff Miller le 27 Mai 2019
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

Réponse acceptée

Jeff Miller
Jeff Miller le 27 Mai 2019
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 commentaires
ektor
ektor le 27 Mai 2019
This approach does not satisfy the restrictions
Jeff Miller
Jeff Miller le 27 Mai 2019
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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Modeling dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by