Title: | Seasonal Adjustment by Frequency Analysis |
---|---|
Description: | Decompose a time series into seasonal, trend and irregular components using transformations to amplitude-frequency domain. |
Authors: | Francisco Parra <[email protected]> |
Maintainer: | Francisco Parra <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.6 |
Built: | 2024-10-29 05:46:50 UTC |
Source: | https://github.com/cran/descomponer |
Gets the auxiliary matrix to vector in time domain, pre-multiplies the vector by the orthogonal matrix,W, and its transpose, Parra F. (2013)
cdf(y)
cdf(y)
y |
a vector of the observed time-serie values |
a matrix of sine and cosine waves adjusted to time-serie
Francisco Parra
Harvey, A.C. (1978), Linear Regression in the Frequency Domain, International Economic Review, 19, 507-512.
Parra, F. (2014), Amplitude time-frequency regression, (http://econometria.wordpress.com/2013/08/21/estimation-of-time-varying-regression-coefficients/)
n<-100;x<-seq(0,24*pi,length=n);y<-sin(x)+rnorm(n,sd=.3) cdf(y)
n<-100;x<-seq(0,24*pi,length=n);y<-sin(x)+rnorm(n,sd=.3) cdf(y)
A vector: celec, Miles de Tep, 1995 a 2013
data(celec)
data(celec)
Instituto Nacional de Estadistica Spain
Decompose a time series into seasonal, trend and irregular components using the transform amplitude-frequency domain to time series.
descomponer(y,frequency,type)
descomponer(y,frequency,type)
y |
a Vector of the observed time-serie values |
frequency |
Number of times in each unit time interval |
type |
lineal (1), quadratic(2) |
One could use a value of 7 for frequency when the data are sampled daily, and the natural time period is a week, or 4 and 12 when the data are sampled quarterly and monthly and the natural time period is a year.
Transforms the time series in amplitude-frequency domain, by a band spectrum regresion (Parra, F. ,2013) of the serie y_t and a OLS lineal trend, in which regression is carried out in the low and the sesaonal amplitude-frequency_t .The low frequency are the periodicity a n/2*frequency or (n-1)/2*frequency , if n is odd. The seasonal frequency are the periodicity: 2n/2*frequency,3n/2*frequency,4n/2*frequency,.. .
Use the "sort.data.frame" function, Kevin Wright (http://tolstoy.newcastle.edu.au/R/help/04/07/1076.html).
Slow computer in time series higher 1000 data.
The output is a data.frame object.
y |
The Vector of the observed time-serievalues |
TDST |
The trend and seasonal time serie of y |
TD |
The trend time serie of y |
ST |
The seasonal time serie of y |
IR |
The remainder time serie of y |
regresoresTD |
The regressors matrix use to the trend estimated |
regresoresST |
The regressors matrix use to the seasonal estimated |
coeficientesTD |
The coefficient vector use to the trend estimated |
coeficientesSD |
The coefficient vector use to the seasonal estimated |
Harvey, A.C. (1978), Linear Regression in the Frequency Domain, International Economic Review, 19, 507-512.
Parra, F. (2014), Amplitude time-frequency regression, (http://econometria.wordpress.com/2013/08/21/estimation-of-time-varying-regression-coefficients/)
data(ipi) datos <- descomponer(ipi,12,2) plot(ts(datos$datos,frequency=12))
data(ipi) datos <- descomponer(ipi,12,2) plot(ts(datos$datos,frequency=12))
Make a prediction for a rdf object
estimardf(a,b)
estimardf(a,b)
a |
a model rdf |
b |
An optional data frame in which to look for variables with which to predict. If omitted, the fitted values are used. |
Use predict.lm, with interval="prediction"
Slow computer in time series higher 1000 data.
fit |
vector or matrix as above |
DURBIN, J., "Tests for Serial Correlation in Regression Analysis based on the Periodogram ofLeast-Squares Residuals," Biometrika, 56, (No. 1, 1969), 1-15.
Engle, Robert F. (1974), Band Spectrum Regression,International Economic Review 15,1-11.
Harvey, A.C. (1978), Linear Regression in the Frequency Domain, International Economic Review, 19, 507-512.
Parra, F. (2014), Amplitude time-frequency regression, (http://econometria.wordpress.com/2013/08/21/estimation-of-time-varying-regression-coefficients/)
data(PIB) data(celec) mod1=rdf(celec,PIB) newdata=c(20000) estimardf(mod1,newdata)
data(PIB) data(celec) mod1=rdf(celec,PIB) newdata=c(20000) estimardf(mod1,newdata)
Make a Fourier Flexible Form Regression
FFF(y,x)
FFF(y,x)
y |
a Vector of the dependent variable |
x |
a Vector of the independent variable |
The regresion FFF use LM for fitted into the serie y_t and the fourier coefficients expansion described in Gallant (1984).
The output is a data.frame object.
fitted |
The time - serie fitted |
X |
The X time - series fourier coefficients |
residuals |
The time - serie fitted |
DURBIN, J., "Tests for Serial Correlation in Regression Analysis based on the Periodogram ofLeast-Squares Residuals," Biometrika, 56, (No. 1, 1969), 1-15.
Engle, Robert F. (1974), Band Spectrum Regression,International Economic Review 15,1-11.
Harvey, A.C. (1978), Linear Regression in the Frequency Domain, International Economic Review, 19, 507-512.
Gallant; A. R.(1984), The Fourier Flexible Form. Amer. J. Agr. Econ.66(1984):204-15.
Parra, F. (2014), Amplitude time-frequency regression, (http://econometria.wordpress.com/2013/08/21/estimation-of-time-varying-regression-coefficients/)
Parra, F.(2021), Econometria con Series de Fourier (https://econometria.files.wordpress.com/2020/12/curso-de-econometria-avanzado.pdf)
data(PIB) data(celec) FFF(celec,PIB)
data(PIB) data(celec) FFF(celec,PIB)
Plotting the trend and seasonal of time series.
gdescomponer(y,freq,type,year,q)
gdescomponer(y,freq,type,year,q)
y |
a vector of the observed time-serie values |
freq |
Number of times in each unit time interval |
type |
lineal (1), quadratic(2) |
year |
the year of the first observation |
q |
the time of the first observation |
Parra, F. (2014), Amplitude time-frequency regression, (http://econometria.wordpress.com/2013/08/21/estimation-of-time-varying-regression-coefficients/)
data(ipi) gdescomponer(ipi,12,1,2002,1)
data(ipi) gdescomponer(ipi,12,1,2002,1)
Transforms the data from the amplitude-time domain the amplitude-frequency domain pre-multiplied by the orthogonal matrix ,W, whose elements are defined in Harvey A.C. (1978).
gdf(y)
gdf(y)
y |
a vector of the observed time-series values |
a vector of the estimated coefficients fourier
Francisco Parra
Harvey, A.C. (1978), Linear Regression in the Frequency Domain, International Economic Review, 19, 507-512.
Parra, F. (2014), Amplitude time-frequency regression, (http://econometria.wordpress.com/2013/08/21/estimation-of-time-varying-regression-coefficients/)
n<-100;x<-seq(0,24*pi,length=n);y<-sin(x)+rnorm(n,sd=.3) gdf(y)
n<-100;x<-seq(0,24*pi,length=n);y<-sin(x)+rnorm(n,sd=.3) gdf(y)
Transforms the data from the amplitude-frequency domain the amplitude-time domain pre-multiplied by inverse of the orthogonal matrix ,W, whose elements are defined in Harvey A.C. (1978).
gdt(y)
gdt(y)
y |
a vector of the coefficients fourier |
a vector of the observed time-series values
Francisco Parra
Harvey, A.C. (1978), Linear Regression in the Frequency Domain, International Economic Review, 19, 507-512.
Parra, F. (2014), Amplitude time-frequency regression, (http://econometria.wordpress.com/2013/08/21/estimation-of-time-varying-regression-coefficients/)
n<-100;x<-seq(0,24*pi,length=n);y<-sin(x)+rnorm(n,sd=.3) coef <- gdf(y) gdt(coef)
n<-100;x<-seq(0,24*pi,length=n);y<-sin(x)+rnorm(n,sd=.3) coef <- gdf(y) gdt(coef)
Plotting method for specturm calculate by periodograma function.
gperiodograma(y)
gperiodograma(y)
y |
a vector of the observed time-serie values |
Parra, F. (2014), Amplitude time-frequency regression, (http://econometria.wordpress.com/2013/08/21/estimation-of-time-varying-regression-coefficients/)
n<-100;x<-seq(0,24*pi,length=n);y<-sin(x)+rnorm(n,sd=.3) gperiodograma(y)
n<-100;x<-seq(0,24*pi,length=n);y<-sin(x)+rnorm(n,sd=.3) gperiodograma(y)
Plotting cumulative periodogram test.
gtd(y)
gtd(y)
y |
a vector of the observed time-serie values |
Parra, F. (2014), Amplitude time-frequency regression, (http://econometria.wordpress.com/2013/08/21/estimation-of-time-varying-regression-coefficients/)
data(PIB) gtd(PIB)
data(PIB) gtd(PIB)
A vector: IPI, Base: 2010. Enero 2002 a Abril 2014
data(ipi)
data(ipi)
Instituto Nacional de Estadistica Spain
Orthogonal matrix defined in Harvey (1978)
MW(n)
MW(n)
n |
rows and columuns number |
Orthogonal matrix of n X n dimensions
Francisco Parra
Harvey, A.C. (1978), Linear Regression in the Frequency Domain, International Economic Review, 19, 507-512.
MW(80)
MW(80)
Calculates and displays the spectrum of the time serie
periodograma(y)
periodograma(y)
y |
a vector of the observed time-serie values |
frecuencia |
Vector of frequencies at which the spectral density is estimated. The units are the reciprocal of cycles per unit time. |
omega |
Is calculated by pi*frecuencia/(n/2) |
periodos |
n/frecuencia |
densidad |
Vector of estimates of the spectral density at frequencies corresponding to frecuencia. |
Parra, F. (2014), Amplitude time-frequency regression, (http://econometria.wordpress.com/2013/08/21/estimation-of-time-varying-regression-coefficients/)
n<-100;x<-seq(0,24*pi,length=n);y<-sin(x)+rnorm(n,sd=.3) periodograma(y)
n<-100;x<-seq(0,24*pi,length=n);y<-sin(x)+rnorm(n,sd=.3) periodograma(y)
A vector: PIB, Base: 2010. 1995 a 2013
data(PIB)
data(PIB)
Instituto Nacional de Estadistica Spain
Make a prediction for a rdf object
predictFFF(y,x,new)
predictFFF(y,x,new)
y |
a Vector of the dependent variable |
x |
a Vector of the independent variable |
new |
A data frame in which to look for variables with which to predict. If omitted, the fitted values are used. |
Use predict.lm, with interval="confidence"
fit |
vector or matrix as above |
DURBIN, J., "Tests for Serial Correlation in Regression Analysis based on the Periodogram ofLeast-Squares Residuals," Biometrika, 56, (No. 1, 1969), 1-15.
Engle, Robert F. (1974), Band Spectrum Regression,International Economic Review 15,1-11.
Harvey, A.C. (1978), Linear Regression in the Frequency Domain, International Economic Review, 19, 507-512.
Gallant; A. R.(1984), The Fourier Flexible Form. Amer. J. Agr. Econ.66(1984):204-15.
Parra, F. (2014), Amplitude time-frequency regression, (http://econometria.wordpress.com/2013/08/21/estimation-of-time-varying-regression-coefficients/)
Parra, F.(2021), Econometria con Series de Fourier (https://econometria.files.wordpress.com/2020/12/curso-de-econometria-avanzado.pdf)
data("ipi") t=seq(1:length(ipi)) Mod1=FFF(ipi,t) plot(ipi) lines(Mod1$fitted) new=(length(t)+1):(length(t)+12) Mod2=predictFFF(ipi,t,new)
data("ipi") t=seq(1:length(ipi)) Mod1=FFF(ipi,t) plot(ipi) lines(Mod1$fitted) new=(length(t)+1):(length(t)+12) Mod2=predictFFF(ipi,t,new)
Make a prediction for a rdf object
predictrdf(a,b)
predictrdf(a,b)
a |
a model rdf |
b |
An optional data frame in which to look for variables with which to predict. If omitted, the fitted values are used. |
Use predict.lm, with interval="prediction"
Slow computer in time series higher 1000 data.
fit |
vector or matrix as above |
DURBIN, J., "Tests for Serial Correlation in Regression Analysis based on the Periodogram ofLeast-Squares Residuals," Biometrika, 56, (No. 1, 1969), 1-15.
Engle, Robert F. (1974), Band Spectrum Regression,International Economic Review 15,1-11.
Harvey, A.C. (1978), Linear Regression in the Frequency Domain, International Economic Review, 19, 507-512.
Parra, F. (2014), Amplitude time-frequency regression, (http://econometria.wordpress.com/2013/08/21/estimation-of-time-varying-regression-coefficients/)
data(PIB) data(celec) mod1=rdf(celec,PIB) newdata=c(100) predictrdf(mod1,newdata)
data(PIB) data(celec) mod1=rdf(celec,PIB) newdata=c(100) predictrdf(mod1,newdata)
Make a Band Spectrum Regression using the comun frequencies in cross-spectrum .
rdf(y,x)
rdf(y,x)
y |
a Vector of the dependent variable |
x |
a Vector of the independent variable |
Transforms the time series in amplitude-frequency domain, order the fourier coefficient by the comun frequencies in cross-spectrum, make a band spectrum regresion (Parra, F. ,2013) of the serie y_t and x_t for every set of fourier coefficients, and select the model to pass the Durbin test in the significance chosen.
If not find significance for Band Spectrum Regression, make a OLS.
The generalized cross validation (gcv), is caluculated by: gcv=n*sse/((n-k)^2)
where "sse" is the residual sums of squares, "n" the observation, and k the coefficients used in the band spectrum regression.
Slow computer in time series higher 1000 data.
The output is a data.frame object.
datos$Y |
The Y time-serie |
datos$X |
The X time-serie |
datos$F |
The time - serie fitted |
datos$reg |
The error time-serie |
Fregresores |
The matrix of regressors choosen in frequency domain |
Tregresores |
The matrix of regressors choosen in time domain |
Nregresores |
The coefficient number of fourier chosen |
sse |
Residual sums of squares |
gcv |
Generalized Cross Validation |
DURBIN, J., "Tests for Serial Correlation in Regression Analysis based on the Periodogram ofLeast-Squares Residuals," Biometrika, 56, (No. 1, 1969), 1-15.
Engle, Robert F. (1974), Band Spectrum Regression,International Economic Review 15,1-11.
Harvey, A.C. (1978), Linear Regression in the Frequency Domain, International Economic Review, 19, 507-512.
Parra, F. (2014), Amplitude time-frequency regression, (http://econometria.wordpress.com/2013/08/21/estimation-of-time-varying-regression-coefficients/)
data(PIB) data(celec) rdf(celec,PIB)
data(PIB) data(celec) rdf(celec,PIB)
Cumulative periodogram test.
td(y)
td(y)
y |
a vector of the observed time-serie values |
The output is a data.frame object.
s2 |
Cumulative periodogram. |
min |
Is calculated by -c+(t/length(y)) |
max |
Is calculated by c+(t/length(y)) |
Parra, F. (2014), Amplitude time-frequency regression, (http://econometria.wordpress.com/2013/08/21/estimation-of-time-varying-regression-coefficients/)
data(PIB) td(PIB)
data(PIB) td(PIB)