Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Help with Kalman filter with S&P 500 index
    조회 수: 2 (최근 30일)
  
       이전 댓글 표시
    
I am using S&P 500 index time series and using Kalman filter to fit it using the combination of weights * 3 previous index values (y-3, y-2, y-1). I am doing it recursively and updating the estimation of the weights at each step. The weights should converge to a final value, faster or slower depending on the ratio of W and V error signal. When I test different values of V and W it makes no difference to the speed of convergence of the parameters. The code is below:
I = eye(W);
flag = 0;
     for i = W+1:(size(data))
         %generate X
         for window = 1:W
            X(i-W,window) = data(i-(W+1-window));
         end
            %set theta and P or use previous value
            if (flag == 0)
                theta = t ;
                P = alpha*I;
                flag = 1;
            else
                P = P;
            end
            %calculate prediction
            x_tmp = X(i-W,:)';
            y_hat = theta' * x_tmp;
            %gather the weights and the Y's
            weights(i-W,:) = theta;
            estimated(i-W,:) = y_hat;
            %calc error
            e = data(i) - y_hat;
            err(i-W,:) = e;
            %calc Kalman gain
            K = (P*x_tmp)/(2500 + x_tmp'*P*x_tmp);
            %update theta and P
            theta = theta + K*e;
            P = (I - K*x_tmp')*P;
     end
  end
답변 (0개)
이 질문은 마감되었습니다.
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

