2
$\begingroup$

I am trying to eliminate seasonality from a time series using Wiener-Kolmogorov filter, I am following the methodology explained in here this paper about signal extraction which is the same followed in this paper.

Following the paper I am able to reproduce figures 12 and 13 using the following MATLAB code:

clear
clc
close all

data = [
1955    32058   1960    37043   1965    42306   1970    46228   1975    53859   1980    61087   1985    65886   1990    83175
1955.25 34034   1960.25 39429   1965.25 44524   1970.25 48922   1975.25 55667   1980.25 59936   1985.25 66822   1990.25 85015
1955.5  34878   1960.5  39365   1965.5  45346   1970.5  50435   1975.5  56462   1980.5  62511   1985.5  70092   1990.5  88774
1955.75 36166   1960.75 40898   1965.75 46317   1970.75 52288   1975.75 58592   1980.75 63651   1985.75 73942   1990.75 90563
1956    32614   1961    37850   1966    43296   1971    47254   1976    53509   1981    60104   1986    69431   1991    82077
1956.25 34360   1961.25 40292   1966.25 46064   1971.25 50353   1976.25 55260   1981.25 60409   1986.25 71929   1991.25 82356
1956.5  34666   1961.5  40352   1966.5  45710   1971.5  52035   1976.5  57050   1981.5  62403   1986.5  75874   1991.5  86445
1956.75 36465   1961.75 41705   1966.75 46480   1971.75 54497   1976.75 59847   1981.75 64486   1986.75 78388   1991.75 89037
1957    32767   1962    38438   1967    43327   1972    50173   1977    53426   1982    59964   1987    72642   1992    80846
1957.25 35241   1962.25 41410   1967.25 46217   1972.25 53405   1977.25 54469   1982.25 60271   1987.25 74897   1992.25 82650
1957.5  35598   1962.5  41143   1967.5  47378   1972.5  55138   1977.5  56523   1982.5  63352   1987.5  80127   1992.5  86941
1957.75 37398   1962.75 42934   1967.75 49063   1972.75 58036   1977.75 60474   1982.75 66265   1987.75 83568   1992.75 89509
1958    33964   1963    39559   1968    46489   1973    54685   1978    56839   1983    62549   1988    78377   1993    82982
1958.25 35816   1963.25 42967   1968.25 46729   1973.25 56166   1978.25 57523   1983.25 63135   1988.25 80349   1993.25 84341
1958.5  36324   1963.5  43707   1968.5  48066   1973.5  57861   1978.5  60163   1983.5  66658   1988.5  86593   1993.5  89489
1958.75 38510   1963.75 44641   1968.75 49925   1973.75 59903   1978.75 62384   1983.75 68858   1988.75 89272   1993.75 92461
1959    34901   1964    41500   1969    45467   1974    53065   1979    58697   1984    63958   1989    82052   1994    85825
1959.25 37756   1964.25 44122   1969.25 47682   1974.25 55198   1979.25 62282   1984.25 65077   1989.25 84045   1994.25 86606
1959.5  37927   1964.5  44597   1969.5  48494   1974.5  57026   1979.5  61533   1984.5  66738   1989.5  88490   1994.5  91575
1959.75 40329   1964.75 45825   1969.75 50723   1974.75 60028   1979.75 64700   1984.75 70713   1989.75 90819   1994.75 94364];

data = [data(:,1:2:end) data(:,2:2:end)];
data = [data(1:end/2)' data(end/2+1:end)'];
n = length(data(:,2));
coeff = [ones(n,1) [1:n]']\log(data(:,2));
y = log(data(:,2))-(coeff(1)+coeff(2)*[1:n])';

cutoffint = 10;
seqnml = 2*pi*(0:n-1)/n;
tmp = seqnml'*[1:10];
alpha = [mean(y) y'*cos(tmp)*2/n];
beta = [0 y'*sin(tmp)*2/n];
seqcutoffint = 2*pi*[1:cutoffint]/n;
seqnml = 0:n-1;
tmp = seqcutoffint'*seqnml;
x = alpha(2:end)*cos(tmp) + beta(2:end)*sin(tmp);
x = x+alpha(1);

figure;
subplot(2,1,1);
plot(data(:,1),y)
hold on
plot(data(:,1),x,'r')
subplot(2,1,2);
plot(data(:,1),data(:,2))
hold on
plot(data(:,1),exp(x+(coeff(1)+coeff(2)*[1:n]))','r')

How to get the coefficients of a Wiener-Kolmogorov filter in order to remove seasonality from a time series?

$\endgroup$
  • $\begingroup$ I know that in this previous post I suggested you to make this question. However, the question is a bit broad to be covered in a post and looks more oriented towards code development (off-topic in this site as mentioned in the previous post). In line with my previous recommendation, I expected you to review the theory and make a more specific question focusing on a statistical concept or an issue where you may have got stuck. Anyway, I will try to give you some clues in the answer below. $\endgroup$ – javlacalle Jan 20 '17 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.