Skip to main content
1 of 3
SKM
  • 631
  • 12
  • 28

Matlab : Stuck in implementing Least Squares estimator for this model

The data $\mathbf{y} = [y_1,y_2,...,y_N]^T$ is obtained from a Moving Average process expressed as

$$y[t] = x[t] + 0.6x[t-1] + 0.3x[t-2] \tag{1}$$ where $\mathbf{h} =[1,0.6,0.3]^T$ are the coefficients. In the Least Squares regression to estimate h I need to formulate the design matrix X correctly. The design matrix should be composed of X = [x[t],x[t-1],x[t-2]]. This means that each column represents a regressor, so X wil be a matrix of size N by 3 where N denotes the number of data points. The formula to estimate $\mathbf{h}$ is then $$\hat{\mathbf{h}} = (X^T X)^{-1} X^T \vec{y}\tag{2}$$

I think this can be implemented in Matlab using hat_h = pinv(X)*X*y

Question 1 : What is the lag of the model? Is the model a moving average of lag 2 or lag 3?

Question 2: I don't know how to create the design matrix X in order to estimate h. Can somebody please provide the complete implementation? Thank you

This is what I have done :

N = 100;
x = randn(1,N);
y(1) = 0.0;
y(2) = 0.0;


% Pass it through the MA model.
for t =3 : N
    y(t) = x(t) + 0.6*x(t-1) + 0.3*x(t-2);
end
SKM
  • 631
  • 12
  • 28