Estimating a regression model using matlab

2 visualizaciones (últimos 30 días)
ektor
ektor el 26 de Mayo de 2019
Comentada: Jeff Miller el 27 de Mayo de 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

Respuesta aceptada

Jeff Miller
Jeff Miller el 27 de Mayo de 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 comentarios
ektor
ektor el 27 de Mayo de 2019
This approach does not satisfy the restrictions
Jeff Miller
Jeff Miller el 27 de Mayo de 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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Modeling en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by