Title: | Time Series, Analysis and Application |
---|---|
Description: | Accompanies the book Rainer Schlittgen and Cristina Sattarhoff (2020) <https://www.degruyter.com/view/title/575978> "Angewandte Zeitreihenanalyse mit R, 4. Auflage" . The package contains the time series and functions used therein. It was developed over many years teaching courses about time series analysis. |
Authors: | Rainer Schlittgen |
Maintainer: | Rainer Schlittgen <[email protected]> |
License: | GPL |
Version: | 1.0.4 |
Built: | 2025-01-29 03:07:35 UTC |
Source: | https://github.com/cran/tsapp |
Monthly numbers of road traffic accidents with personal injury in BRD
ACCIDENT
ACCIDENT
ACCIDENT is a univariate time series of length 528, start January 1974, frequency = 12
Monthly numbers of road traffic accidents with personal injury
< https://www-genesis.destatis.de/genesis//online?operation=table&code=46241-0002&
levelindex=0&levelid=1583749114977>
data(ACCIDENT) ## maybe tsp(ACCIDENT) ; plot(ACCIDENT)
data(ACCIDENT) ## maybe tsp(ACCIDENT) ; plot(ACCIDENT)
acfmat
computes a sequence of autocorrelation matrices for a multivariate time seriesacfmat
computes a sequence of autocorrelation matrices for a multivariate time series
acfmat(y, lag.max)
acfmat(y, lag.max)
y |
multivariate time series |
lag.max |
maximum number of lag |
out list with components:
M |
array with autocovariance matrices |
M1 |
array with indicators if autocovariances are significantly greater (+), lower (-) than the critical value or insignificant (.) at 95 percent level |
data(ICECREAM) out <- acfmat(ICECREAM,7)
data(ICECREAM) out <- acfmat(ICECREAM,7)
acfpacf
produces a plot of the acf and the pacf of a time seriesacfpacf
produces a plot of the acf and the pacf of a time series
acfpacf(x, lag, HV = "H")
acfpacf(x, lag, HV = "H")
x |
the series, a vector or a time series |
lag |
scalar, maximal lag to be plotted |
HV |
character, controls division of graphic window: "H" horizontal, "V" vertical, default is "H" |
data(LYNX) acfpacf(log(LYNX),15,HV="H")
data(LYNX) acfpacf(log(LYNX),15,HV="H")
Alcohol Demand, UK, 1870-1938.
ALCINCOME
ALCINCOME
ALCINCOME is a threevariate time series of length 69 and 3 variables; start 1870, frequency = 1
log consumption per head
log real income per head
log real price
Durbin & Watson (1951) <https://doi.org/10.1093/biomet/38.1-2.159>
data(ALCINCOME) ## maybe tsp(ALCINCOME) ; plot(ALCINCOME)
data(ALCINCOME) ## maybe tsp(ALCINCOME) ; plot(ALCINCOME)
armathspec
determines the theoretical spectrum of an arma processarmathspec
determines the theoretical spectrum of an arma process
armathspec(a, b, nf, s = 1, pl = FALSE)
armathspec(a, b, nf, s = 1, pl = FALSE)
a |
ar-coefficients |
b |
ma-coefficients |
nf |
scalar, the number of equally spaced frequencies |
s |
variance of error process |
pl |
logical, if TRUE, the spectrum is plotted, FALSE for no plot |
out (nf+1,2) matrix, the frequencies and the spectrum
out <-armathspec(c(0.3,-0.5),c(-0.8,0.7),50,s=1,pl=FALSE)
out <-armathspec(c(0.3,-0.5),c(-0.8,0.7),50,s=1,pl=FALSE)
aspectratio
determines the aspect ratio to plot a time seriesaspectratio
determines the aspect ratio to plot a time series
aspectratio(y)
aspectratio(y)
y |
time series |
a scalar, the aspect ratio
data(GDP) a <- aspectratio(GDP)
data(GDP) a <- aspectratio(GDP)
bandfilt
does a bandpass filtering of a time seriesbandfilt
does a bandpass filtering of a time series
bandfilt(y, q, pl, pu)
bandfilt(y, q, pl, pu)
y |
the series, a vector or a time series |
q |
scalar, half of length of symmetric weights |
pl |
scalar, lower periodicity ( >= 2 ) |
pu |
scalar, upper periodicity ( > pl ) |
yf (n,1) vector, the centered filtered time series with NA's at beginning and ending
data(GDP) yf <- bandfilt(GDP,5,2,6) plot(GDP); lines(yf+mean(GDP),col="red")
data(GDP) yf <- bandfilt(GDP,5,2,6) plot(GDP); lines(yf+mean(GDP),col="red")
Monthly beer production in Australia: megalitres. Includes ale and stout. Does not include beverages with alcohol percentage less than 1.15.
BEER
BEER
BEER is a univariate time series of length 476, start January 1956, end Aug 1995, frequency = 12
Monthly production of beer in Australia
R package tsdl <https://github.com/FinYang/tsdl>
data(BEER) ## maybe tsp(BEER) ; plot(BEER)
data(BEER) ## maybe tsp(BEER) ; plot(BEER)
bispeces
performs indirect bivariate spectral estimation of two series y1, y2 using lagwindowsbispeces
performs indirect bivariate spectral estimation of two series y1, y2 using lagwindows
bispeces(y1, y2, q, win = "bartlett")
bispeces(y1, y2, q, win = "bartlett")
y1 |
vector, the first time series |
y2 |
vector, the second time series |
q |
number of covariances used for indirect spectral estimation |
win |
lagwindow (possible: "bartlett", "parzen", "tukey") |
out data frame with columns:
f |
frequencies 0, 1/n, 2/n, ... (<= 1/2 ) |
coh |
estimated coherency at Fourier frequencies 0,1/n, ... |
ph |
estimated phase at Fourier frequencies 0,1/n, ... |
data(ICECREAM) y <- ICECREAM out <- bispeces(y[,1],y[,2],8,win="bartlett")
data(ICECREAM) y <- ICECREAM out <- bispeces(y[,1],y[,2],8,win="bartlett")
Weekly number of births in New York
BLACKOUT
BLACKOUT
BLACKOUT is a univariate time series of length 313, 1961 – 1966
Weekly numbers of births in New York
Izenman, A. J., and Zabell, S. L. (1981) <https://www.sciencedirect.com/science/article/abs/pii/ 0049089X81900181>
data(BLACKOUT) ## maybe tsp(BLACKOUT) ; plot(BLACKOUT)
data(BLACKOUT) ## maybe tsp(BLACKOUT) ; plot(BLACKOUT)
BoxCox
determines the power of a Box-Cox transformation to stabilize the variance of a time seriesBoxCox
determines the power of a Box-Cox transformation to stabilize the variance of a time series
BoxCox(y, seg, Plot = FALSE)
BoxCox(y, seg, Plot = FALSE)
y |
the series, a vector or a time series |
seg |
scalar, number of segments |
Plot |
logical, should a plot be produced? |
l scalar, the power of the Box-Cox transformation
data(INORDER) lambda <-BoxCox(INORDER,6,Plot=FALSE)
data(INORDER) lambda <-BoxCox(INORDER,6,Plot=FALSE)
U.S. annual coffee consumption
COFFEE
COFFEE
COFFEE is a univariate time series of length 61; start 1910, frequency = 1
annual coffee-consumption USA, logarithmic transformed
R package tsdl <https://github.com/FinYang/tsdl>
data(COFFEE) ## maybe tsp(COFFEE) ; plot(COFFEE)
data(COFFEE) ## maybe tsp(COFFEE) ; plot(COFFEE)
Market value of DAX
DAX
DAX
DAX is a multivariate time series of length 12180 and 4 variables
Day of the week
Month
Year
Market value
data(DAX) ## maybe tsp(DAX) ; plot(DAX)
data(DAX) ## maybe tsp(DAX) ; plot(DAX)
Incidences of insulin-dependent diabetes mellitus
DIABETES
DIABETES
DIABETES is a univariate time series of length 72, start January 1979, frequency = 12
Incidences of insulin-dependent diabetes mellitus
Waldhoer, T., Schober, E. and Tuomilehto, J. (1997) <https://www.sciencedirect.com/science/
article/abs/pii/S0895435696003344>
data(DIABETES) ## maybe tsp(DIABETES) ; plot(DIABETES)
data(DIABETES) ## maybe tsp(DIABETES) ; plot(DIABETES)
Running yield of public bonds in Austria and Germany
DOMINANCE
DOMINANCE
DOMINANCE is a bivariate time series of length 167:
Interest rate Germany
Interest rate Austria
Jaenicke, J. and Neck, R. (1996) <https://doi.org/10.17713/ajs.v25i2.555>
data(DOMINANCE) ## maybe tsp(DOMINANCE) ; plot(DOMINANCE)
data(DOMINANCE) ## maybe tsp(DOMINANCE) ; plot(DOMINANCE)
dynspecest
performs a dynamic spectrum estimationdynspecest
performs a dynamic spectrum estimation
dynspecest(y, nseg, nf, e, theta = 0, phi = 15, d, Plot = FALSE)
dynspecest(y, nseg, nf, e, theta = 0, phi = 15, d, Plot = FALSE)
y |
time series or vector |
nseg |
number of segments for which the spectrum is estimated |
nf |
number of equally spaced frequencies |
e |
equal bandwidth |
theta |
azimuthal viewing direction, see R function persp |
phi |
colatitude viewing direction, see R function persp |
d |
a value to vary the strength of the perspective transformation, see R function persp |
Plot |
logical, schould a plot be generated? |
out list with components
f |
frequencies, vector of length nf |
t |
time, vector of length nseg |
spec |
the spectral estimates, (nf,nt)-matrix |
data(IBM) y <- diff(log(IBM)) out <- dynspecest(y,60,50,0.2,theta=0,phi=15,d=1,Plot=FALSE)
data(IBM) y <- diff(log(IBM)) out <- dynspecest(y,60,50,0.2,theta=0,phi=15,d=1,Plot=FALSE)
ENGINES is an alias for MACHINES
ENGINES
ENGINES
ENGINES is a univariate time series of length 188, start January 1972 frequency = 12
Incoming orders for engines
data(ENGINES) ## maybe tsp(ENGINES) ; plot(ENGINES)
data(ENGINES) ## maybe tsp(ENGINES) ; plot(ENGINES)
Portfolio-Insurance-Strategies
FINANCE
FINANCE
FINANCE is a multivariate time series of length 7529:
first Portfolio-Insurance-Strategy
second Portfolio-Insurance-Strategy
third Portfolio-Insurance-Strategy
fourth Portfolio-Insurance-Strategy
money market investment
Dichtl, H. and Drobetz, W. (2011) <doi:10.1016/j.jbankfin.2010.11.012>
data(FINANCE) ## maybe tsp(FINANCE) ; plot(FINANCE)
data(FINANCE) ## maybe tsp(FINANCE) ; plot(FINANCE)
Germany's gross domestic product adjusted for price changes
GDP
GDP
GDP is a univariate time series of length 159, start January 1970, frequency = 4
Gross domestic product adjusted for price changes
<https://www-genesis.destatis.de/genesis//online?operation=table&code=81000-0002&levelindex
=0&levelid=1583750132341>
data(GDP) ## maybe tsp(GDP) ; plot(GDP)
data(GDP) ## maybe tsp(GDP) ; plot(GDP)
Germany's gross domestic product, values of Laspeyres index to base 2000
GDPORIG
GDPORIG
GDPORIG is a univariate time series of length 159, start January 1970, frequency = 4
gross domestic product, values of Laspeyres index to the base 2000
<https://www-genesis.destatis.de/genesis//online?operation=table&code=81000-0002&levelindex
=0&levelid=1583750132341>
data(GDPORIG) ## maybe tsp(GDPORIG) ; plot(GDPORIG)
data(GDPORIG) ## maybe tsp(GDPORIG) ; plot(GDPORIG)
Grangercaus
determines three values of BIC from a twodimensional VAR processGrangercaus
determines three values of BIC from a twodimensional VAR process
Grangercaus(x, y, p)
Grangercaus(x, y, p)
x |
first time series |
y |
second time series |
p |
maximal order of VAR process |
out list with components
BIC |
vector of length 3: |
BIC1 | minimum aic value for all possible lag structures |
BIC2 | minimum aic value when Y is not included as regressor in the equation for X |
BIC3 | minimum aic value when X is not included as regressor in the equation for Y |
out1 |
output of function lm for regression equation for x-series |
out2 |
output of function lm for regression equation for y-series |
data(ICECREAM) out <- Grangercaus(ICECREAM[,1],ICECREAM[,2],3)
data(ICECREAM) out <- Grangercaus(ICECREAM[,1],ICECREAM[,2],3)
HAC
computes the central quantity (the meat) in the HAC covariance matrix estimator, also called
sandwich estimator. HAC is the abbreviation for "heteroskedasticity and autocorrelation consistent".HAC Covariance Matrix Estimation
HAC
computes the central quantity (the meat) in the HAC covariance matrix estimator, also called
sandwich estimator. HAC is the abbreviation for "heteroskedasticity and autocorrelation consistent".
HAC(mcond, method = "Bartlett", bw)
HAC(mcond, method = "Bartlett", bw)
mcond |
a q-dimensional multivariate time series. In the case of OLS regression with q regressors mcond contains the series of the form regressor*residual (see example below). |
method |
kernel function, choose between "Truncated", "Bartlett", "Parzen", "Tukey-Hanning", "Quadratic Spectral". |
bw |
bandwidth parameter, controls the number of lags considered in the estimation. |
mat a (q,q)-matrix
Heberle, J. and Sattarhoff, C. (2017) <doi:10.3390/econometrics5010009> "A Fast Algorithm for the Computation of HAC Covariance Matrix Estimators"
data(MUSKRAT) y <- ts(log10(MUSKRAT)) n <- length(y) t <- c(1:n) t2 <- t^2 out2 <- lm(y ~ t +t2) mat_xu <- matrix(c(out2$residuals,t*out2$residuals, t2*out2$residuals),nrow=62,ncol=3) hac <- HAC(mat_xu, method="Bartlett", 4) mat_regr<- matrix(c(rep(1,62),t,t2),nrow=62,ncol=3) mat_q <- t(mat_regr)%*%mat_regr/62 vcov_HAC <- solve(mat_q)%*%hac%*%solve(mat_q)/62 # vcov_HAC is the HAC covariance matrix estimation for the OLS coefficients.
data(MUSKRAT) y <- ts(log10(MUSKRAT)) n <- length(y) t <- c(1:n) t2 <- t^2 out2 <- lm(y ~ t +t2) mat_xu <- matrix(c(out2$residuals,t*out2$residuals, t2*out2$residuals),nrow=62,ncol=3) hac <- HAC(mat_xu, method="Bartlett", 4) mat_regr<- matrix(c(rep(1,62),t,t2),nrow=62,ncol=3) mat_q <- t(mat_regr)%*%mat_regr/62 vcov_HAC <- solve(mat_q)%*%hac%*%solve(mat_q)/62 # vcov_HAC is the HAC covariance matrix estimation for the OLS coefficients.
Cardiac frequency of a patient
HEARTBEAT
HEARTBEAT
HEARTBEAT is a univariate time series of length 30:
cardiac frequency of a patient
data(HEARTBEAT) ## maybe tsp(HEARTBEAT) ; plot(HEARTBEAT)
data(HEARTBEAT) ## maybe tsp(HEARTBEAT) ; plot(HEARTBEAT)
HSV's position in the first German soccer league
HSV
HSV
HSV is a univariate time series of length 47:
HSV's position in the first German soccer league
<https://www.transfermarkt.de/hamburger-sv/platzierungen/verein/41>
data(HSV) ## maybe tsp(HSV) ; plot(HSV)
data(HSV) ## maybe tsp(HSV) ; plot(HSV)
IBM's stock price
IBM
IBM
IBM is a univariate time series of length 369, start 17 May 1961
IBM's daily stock price
Box, G. E. P. and Jenkins, G. M. (1970, ISBN: 978-0816210947) "Time series analysis: forecasting and control"
data(IBM) ## maybe tsp(IBM) ; plot(IBM)
data(IBM) ## maybe tsp(IBM) ; plot(IBM)
Temperature and consumption of ice cream
ICECREAM
ICECREAM
ICECREAM is a bivariate time series of length 160:
consumption of ice cream
Temperature in Fahrenheit degrees
Hand, D. J., et al. (1994, ISBN: 9780412399206) "A Handbook of Small Data Sets"
data(ICECREAM) ## maybe tsp(ICECREAM) ; plot(ICECREAM)
data(ICECREAM) ## maybe tsp(ICECREAM) ; plot(ICECREAM)
init_values
is an auxiliary function for rlassoHAC, for fitting linear models with
the method of least squares where only the variables in X with highest correlations
are considered; taken from package hdm.init_values
is an auxiliary function for rlassoHAC, for fitting linear models with
the method of least squares where only the variables in X with highest correlations
are considered; taken from package hdm.
init_values(X, y, number = 5, intercept = TRUE)
init_values(X, y, number = 5, intercept = TRUE)
X |
Regressors (matrix or object can be coerced to matrix). |
y |
Dependent variable(s). |
number |
How many regressors in X should be considered. |
intercept |
Logical. If TRUE, intercept is included which is not penalized. |
init_values returns a list containing the following components:
residuals |
Residuals. |
coefficients |
Estimated coefficients. |
Victor Chernozhukov, Chris Hansen, Martin Spindler (2016). hdm: High-Dimensional Metrics, R Journal, 8(2), 185-199. URL https://journal.r-project.org/archive/2016/RJ-2016-040/index.html.
Income orders of a company
INORDER
INORDER
INORDER is a univariate time series of length 237, start January 1968, frequency =12
Income orders of a company
data(INORDER) ## maybe tsp(INORDER) ; plot(INORDER)
data(INORDER) ## maybe tsp(INORDER) ; plot(INORDER)
interpol
help function for misslsinterpol
help function for missls
interpol(rho, xcent)
interpol(rho, xcent)
rho |
autocorrelation function |
xcent |
centered time series |
z new version of xcent
kweightsHAC
help function for HACkweightsHAC
help function for HAC
kweightsHAC( kernel = c("Truncated", "Bartlett", "Parzen", "Tukey-Hanning", "Quadratic Spectral"), dimN, bw )
kweightsHAC( kernel = c("Truncated", "Bartlett", "Parzen", "Tukey-Hanning", "Quadratic Spectral"), dimN, bw )
kernel |
kernel function, choose between "Truncated", "Bartlett", "Parzen", "Tukey-Hanning", "Quadratic Spectral". |
dimN |
number of observations |
bw |
bandwidth parameter |
ww weights
Subsoil water level and precipitation at pilot well L921
L921
L921
L921 is a trivariate time series of length 335:
Day
Water level
Supplemented water level
data(L921) ## maybe tsp(L921) ; plot(L921)
data(L921) ## maybe tsp(L921) ; plot(L921)
lagwinba
Bartlett's Lag-window for indirect spectrum estimationlagwinba
Bartlett's Lag-window for indirect spectrum estimation
lagwinba(NL)
lagwinba(NL)
NL |
number of lags used for estimation |
win vector, one-sided weights
win <-lagwinba(5)
win <-lagwinba(5)
lagwinpa
Parzen's Lag-window for indirect spectrum estimationlagwinpa
Parzen's Lag-window for indirect spectrum estimation
lagwinpa(NL)
lagwinpa(NL)
NL |
number of lags used for estimation |
win vector, one-sided weights
win <- lagwinpa(5)
win <- lagwinpa(5)
lagwintu
Tukey's Lag-window for indirect spectrum estimationlagwintu
Tukey's Lag-window for indirect spectrum estimation
lagwintu(NL)
lagwintu(NL)
NL |
number of lags used for estimation |
win vector, one-sided weights
win <- lagwintu(5)
win <- lagwintu(5)
lambdaCalculationHAC
is an auxiliary function for rlassoHAC; it calculates the penalty parameters.lambdaCalculationHAC
is an auxiliary function for rlassoHAC; it calculates the penalty parameters.
lambdaCalculationHAC( X.dependent.lambda = FALSE, c = 2, gamma = 0.1, kernel, bands, bns, lns, nboot, y = NULL, x = NULL )
lambdaCalculationHAC( X.dependent.lambda = FALSE, c = 2, gamma = 0.1, kernel, bands, bns, lns, nboot, y = NULL, x = NULL )
X.dependent.lambda |
Logical, TRUE, if the penalization parameter depends on the design of the matrix x. FALSE, if independent of the design matrix (default). |
c |
Constant for the penalty with default c = 2 . |
gamma |
Constant for the penalty with default gamma=0.1. |
kernel |
String kernel function, choose between "Truncated", "Bartlett", "Parzen", "Tukey-Hanning", "Quadratic Spectral". |
bands |
Constant bandwidth parameter. |
bns |
Block length. |
lns |
Number of blocks. |
nboot |
Number of bootstrap iterations. |
y |
Residual which is used for calculation of the variance or the data-dependent loadings. |
x |
Regressors (vector, matrix or object can be coerced to matrix). |
lambda0 |
Penalty term |
Ups0 |
Penalty loadings, vector of length p (no. of regressors) |
lambda |
This is lambda0 * Ups0 |
penalty |
Summary of the used penalty function. |
Victor Chernozhukov, Chris Hansen, Martin Spindler (2016). hdm: High-Dimensional Metrics, R Journal, 8(2), 185-199. URL https://journal.r-project.org/archive/2016/RJ-2016-040/index.html.
lambdaCalculationLoad
is an auxiliary function for rlassoLoad; it calculates the penalty parameters
with predefined loadings.lambdaCalculationLoad
is an auxiliary function for rlassoLoad; it calculates the penalty parameters
with predefined loadings.
lambdaCalculationLoad( X.dependent.lambda = FALSE, c = 2, gamma = 0.1, load, bns, lns, nboot, y = NULL, x = NULL )
lambdaCalculationLoad( X.dependent.lambda = FALSE, c = 2, gamma = 0.1, load, bns, lns, nboot, y = NULL, x = NULL )
X.dependent.lambda |
Logical, TRUE, if the penalization parameter depends on the design of the matrix x. FALSE, if independent of the design matrix (default). |
c |
Constant for the penalty with default c = 2 . |
gamma |
Constant for the penalty with default gamma=0.1. |
load |
Penalty loadings, vector of length p (no. of regressors). |
bns |
Block length. |
lns |
Number of blocks. |
nboot |
Number of bootstrap iterations. |
y |
Residual which is used for calculation of the variance or the data-dependent penalty. |
x |
Regressors (vector, matrix or object can be coerced to matrix). |
lambda0 |
Penalty term |
Ups0 |
Penalty loadings, vector of length p (no. of regressors) |
lambda |
This is lambda0 * Ups0 |
penalty |
Summary of the used penalty function |
Victor Chernozhukov, Chris Hansen, Martin Spindler (2016). hdm: High-Dimensional Metrics, R Journal, 8(2), 185-199. URL https://journal.r-project.org/archive/2016/RJ-2016-040/index.html.
ldrec
does Levinson-Durbin recursion for determing all coefficients a(i,j)ldrec
does Levinson-Durbin recursion for determing all coefficients a(i,j)
ldrec(a)
ldrec(a)
a |
(p+1,1)-vector of acf of a time series: acov(0),...,acov(p) or 1,acor(1),..,acor(p) |
mat (p,p+2)-matrix, coefficients in lower triangular, pacf in colum p+2 and Q(p) in colum p+1
data(HEARTBEAT) a <- acf(HEARTBEAT,5,plot=FALSE) mat <- ldrec(a$acf)
data(HEARTBEAT) a <- acf(HEARTBEAT,5,plot=FALSE) mat <- ldrec(a$acf)
Daily subsoil water level and precipitation at pilot well Lith
LITH
LITH
LITH is a bivariate time series of length 1347:
precipitation amount
water level
data(LITH) ## maybe tsp(LITH) ; plot(LITH)
data(LITH) ## maybe tsp(LITH) ; plot(LITH)
LjungBoxPierceTest
determines the test statistic and p values for several lags for a residual seriesLjungBoxPierceTest
determines the test statistic and p values for several lags for a residual series
LjungBoxPierceTest(y, n.par = 0, maxlag = 48)
LjungBoxPierceTest(y, n.par = 0, maxlag = 48)
y |
the series of residuals, a vector or a time series |
n.par |
number of parameters which had been estimated |
maxlag |
maximal lag up to which the test statistic is computed, default is maxlag = 48 |
BT matrix with columns: lags, degrees of freedom, test statistic, p-value
data(COFFEE) out <- arima(COFFEE,order=c(1,0,0)) BT <- LjungBoxPierceTest(out$residuals,1,20)
data(COFFEE) out <- arima(COFFEE,order=c(1,0,0)) BT <- LjungBoxPierceTest(out$residuals,1,20)
Level of Luteinzing hormone of a cow
LUHORMONE
LUHORMONE
LUHORMONE is a bivariate time series of length 29:
Time in minutes
Level of the Luteinzing-hormone
Annual lynx trappings in a region of North-West Canada. Taken from Andrews and Herzberg (1985).
LYNX
LYNX
LYNX is a univariate time series of length 114; start 1821 frequency = 1
annual lynx trappings in a region of North-west Canada
Andrews, D. F. and Herzberg, A. M. (1985) "Data" <https://www.springer.com/gp/book/9781461295631>
data(LYNX) ## maybe tsp(LYNX) ; plot(LYNX)
data(LYNX) ## maybe tsp(LYNX) ; plot(LYNX)
Size of populations of lynxes and snow hares
LYNXHARE
LYNXHARE
LYNXHARE is a simulated bivariate time series from a VAR[1]-model of length 100:
Number of lynxes
Number of snow hares
data(LYNXHARE)
data(LYNXHARE)
Number of incoming orders for machines
MACHINES
MACHINES
MACHINES is a univariate time series of length 188, start January 1972 frequency = 12
Incoming orders for machines
data(MACHINES) ## maybe tsp(MACHINES) ; plot(MACHINES)
data(MACHINES) ## maybe tsp(MACHINES) ; plot(MACHINES)
Atmospheric CO2 concentrations (ppmv) derived from in situ air samples collected at Mauna Loa Observatory, Hawaii
MAUNALOA
MAUNALOA
MAUNALOA is a univariate time series of length 735; start March 1958, frequency = 12
CO2-concentration at Mauna Loa
Keeling, C. D. , Piper, S. C., Bacastow, R. B., Wahlen, M. , Whorf, T. P., Heimann, M., and Meijer, H. A. (2001) <https://library.ucsd.edu/dc/object/bb3859642r>
data(MAUNALOA) ## maybe tsp(MAUNALOA) ; plot(MAUNALOA)
data(MAUNALOA) ## maybe tsp(MAUNALOA) ; plot(MAUNALOA)
Stock market price of MDAX
MDAX
MDAX
MDAX is a multivariate time series of length 6181 and 4 variables
Day of the week
Month
Year
Opening stock market price
<https://www.onvista.de/index/MDAX-Index-323547>
data(MDAX) ## maybe tsp(MDAX) ; plot(MDAX[,3])
data(MDAX) ## maybe tsp(MDAX) ; plot(MDAX[,3])
Melanoma incidence in Connecticut
MELANOM
MELANOM
MELANOM is a multivariate time series of length 45 and 3 variables
Population
Incidence
Sunspots
Andrews, D. F. and Herzberg, A. M. (1985) "Data" <https://www.springer.com/gp/book/9781461295631>
data(MELANOM) ## maybe tsp(MELANOM) ; plot(MELANOM[,-1])
data(MELANOM) ## maybe tsp(MELANOM) ; plot(MELANOM[,-1])
mfraccheck
computes the absolute empirical moments of the differenced series for various lags
and moment orders. E.g. for lag = 3 and moment order = 1 the average absolute value of
the differences with lag 3 will be computed. By default, the maximum lag is determined
so that the differenced series contains at lest 50 observations.multifractal check
mfraccheck
computes the absolute empirical moments of the differenced series for various lags
and moment orders. E.g. for lag = 3 and moment order = 1 the average absolute value of
the differences with lag 3 will be computed. By default, the maximum lag is determined
so that the differenced series contains at lest 50 observations.
mfraccheck(p, q_max)
mfraccheck(p, q_max)
p |
the series |
q_max |
maximum moment order |
out list with components:
moments |
matrix with lagmax raws and q_max columns containing the values of the absolute empirical moments |
lagmax |
the maximum lag for differencing |
data(NIKKEI) p <- NIKKEI out <- mfraccheck(log(p),5) mom <- ts(out$moments,start=1) ts.plot(mom, log ="xy",xlab="lag",ylab="abs. empirical moments", lty=c(1:5))
data(NIKKEI) p <- NIKKEI out <- mfraccheck(log(p),5) mom <- ts(out$moments,start=1) ts.plot(mom, log ="xy",xlab="lag",ylab="abs. empirical moments", lty=c(1:5))
missar
Substitution of missing values in a time series by
conditional exspectations of AR(p) modelsmissar
Substitution of missing values in a time series by
conditional exspectations of AR(p) models
missar(x, p, iterout = 0)
missar(x, p, iterout = 0)
x |
vector, the time series |
p |
integer, the maximal order of ar polynom 0 < p < 18, |
iterout |
if = 1, iteration history is printed |
out list with elements
a |
(p,p)-matrix, estimated ar coefficients for ar-models |
y |
(n,1)-vector, completed time series |
iterhist |
matrix, NULL or the iteration history |
Miller R.B., Ferreiro O. (1984) <doi.org/10.1007/978-1-4684-9403-7_12> "A Strategy to Complete a Time Series with Missing Observations"
data(HEARTBEAT) x <- HEARTBEAT x[c(20,21)] <- NA out <- missar(x,2)
data(HEARTBEAT) x <- HEARTBEAT x[c(20,21)] <- NA out <- missar(x,2)
missls
substitutes missing values in a time series using the LS approach with ARMA modelsmissls
substitutes missing values in a time series using the LS approach with ARMA models
missls(x, p = 0, tol = 0.001, theo = 0)
missls(x, p = 0, tol = 0.001, theo = 0)
x |
vector, the time series |
p |
integer, the order of polynom alpha(B)/beta(B) |
tol |
tolerance that can be set; it enters via tol*sd(x,na.rm=TRUE) |
theo |
(k,1)-vector, prespecified Inverse ACF, IACF (starting at lag 1) |
y completed time series
S. R. Brubacher and G. Tunnicliffe Wilson (1976) <https://www.jstor.org/stable/2346678> "Interpolating Time Series with Application to the Estimation of Holiday Effects on Electricity Demand Journal of the Royal Statistical Society"
data(HEARTBEAT) x <- HEARTBEAT x[c(20,21)] <- NA out <- missls(x,p=2,tol=0.001,theo=0)
data(HEARTBEAT) x <- HEARTBEAT x[c(20,21)] <- NA out <- missls(x,p=2,tol=0.001,theo=0)
moveav
smoothes a time series by moving averagesmoveav
smoothes a time series by moving averages
moveav(y, q)
moveav(y, q)
y |
the series, a vector or a time series |
q |
scalar, span of moving average |
g vector, smooth component
data(GDP) g <- moveav(GDP,12) plot(GDP) ; lines(g,col="red")
data(GDP) g <- moveav(GDP,12) plot(GDP) ; lines(g,col="red")
movemed
smoothes a time series by moving mediansmovemed
smoothes a time series by moving medians
movemed(y, q)
movemed(y, q)
y |
the series, a vector or a time series |
q |
scalar, span of moving median |
g vector, smooth component
data(BIP) g <- movemed(GDP,12) plot(GDP) ; t <- seq(from = 1970, to = 2009.5,by=0.25) ; lines(t,g,col="red")
data(BIP) g <- movemed(GDP,12) plot(GDP) ; t <- seq(from = 1970, to = 2009.5,by=0.25) ; lines(t,g,col="red")
Annual trade of muskrat pelts
MUSKRAT
MUSKRAT
MUSKRAT is a univariate time series of length 62; start 1848, frequency = 1
annual trade of muskrat pelts
<https://archive.uea.ac.uk/~gj/book/data/mink.dat>
data(MUSKRAT) ## maybe tsp(MUSKRAT) ; plot(MUSKRAT)
data(MUSKRAT) ## maybe tsp(MUSKRAT) ; plot(MUSKRAT)
Daily values of the Japanese stock market index Nikkei 225 between 02.02.2000 and 20.10.2020
NIKKEI
NIKKEI
NIKKEI is a univariate time series of length 5057
Daily values of Nikkei
Heber, G., Lunde, A., Shephard, N. and Sheppard, K. (2009) "Oxford-Man Institute's realized library, version 0.3", Oxford-Man Institute, University of Oxford, Oxford <https://realized.oxford-man.ox.ac.uk/data>
data(NIKKEI) ## maybe plot(NIKKEI)
data(NIKKEI) ## maybe plot(NIKKEI)
outidentify
performs one iteration of Wei's iterative procedure to identify impact, locations and type
of outliers in arma processesoutidentify
performs one iteration of Wei's iterative procedure to identify impact, locations and type
of outliers in arma processes
outidentify(x, object, alpha = 0.05, robust = FALSE)
outidentify(x, object, alpha = 0.05, robust = FALSE)
x |
vector, the time series |
object |
output of a model fit with the function arima (from stats) |
alpha |
the level of the tests for deciding which value is to be considered an outlier |
robust |
logical, should the standard error be computed robustly? |
out list with elements
outlier |
matrix with time index (ind), type of outlier (1 = AO, 2 = IO) and value of test statistic (lambda) |
arima.out |
output of final arima model where the outliers are incorporated as fixed regressors |
data(SPRUCE) out <- arima(SPRUCE,order=c(2,0,0)) out2 <- outidentify(SPRUCE,out,alpha=0.05, robust = FALSE)
data(SPRUCE) out <- arima(SPRUCE,order=c(2,0,0)) out2 <- outidentify(SPRUCE,out,alpha=0.05, robust = FALSE)
Amount of an Oxygen isotope
OXYGEN
OXYGEN
OXYGEN is a matrix with 164 rows and 2 columns
Time
DELTA18O
Belecher, J., Hampton, J. S., and Tunnicliffe Wilson, T. (1994, ISSN: 1369-7412) "Parameterization of Continuous Time Autoregressive Models for Irregularly Sampled Time Series Data"
data(OXYGEN) ## maybe plot(OXYGEN[,1],OXYGEN[,2],type="l"); rug(OXYGEN[,1])
data(OXYGEN) ## maybe plot(OXYGEN[,1],OXYGEN[,2],type="l"); rug(OXYGEN[,1])
pacfmat
sequence of partial autocorrelation matrices and related statistics for a multivariate time seriespacfmat
sequence of partial autocorrelation matrices and related statistics for a multivariate time series
pacfmat(y, lag.max)
pacfmat(y, lag.max)
y |
multivariate time series |
lag.max |
maximum number of lag |
out list with components:
M |
array with matrices of partial autocovariances divided by their standard error |
M1 |
array with indicators if partial autocovariances are significantly greater (+), lower (-) than the critical value or insignificant (.) |
R |
array with matrices of partial autocovariances |
S |
matrix of diagonals of residual covariances (row-wise) |
Test |
test statistic |
pval |
p value of test |
data(ICECREAM) out <- pacfmat(ICECREAM,7)
data(ICECREAM) out <- pacfmat(ICECREAM,7)
Two measurements at a paper machine
PAPER
PAPER
PAPER is a bivariate time series of length 160
High
Weight
Janacek, G. J. & Swift, L. (1993, ISBN: 978-0139184598) "Time Series: Forecasting, Simulation, Applications"
data(PAPER) ## maybe tsp(PAPER) ; plot(PAPER)
data(PAPER) ## maybe tsp(PAPER) ; plot(PAPER)
periodogram
determines the periodogram of a time seriesperiodogram
determines the periodogram of a time series
periodogram(y, nf, ACF = FALSE, type = "cov")
periodogram(y, nf, ACF = FALSE, type = "cov")
y |
(n,1) vector, the time series or an acf at lags 0,1,...,n-1 |
nf |
scalar, the number of equally spaced frequencies; not necessay an integer |
ACF |
logical, FALSE, if y is ts, TRUE, if y is acf |
type |
c("cov","cor"), area under spectrum, can be variance or normed to 1. |
out (floor(nf/2)+1,2) matrix, the frequencies and the periodogram
data(WHORMONE) ## periodogram at Fourier frequencies and frequencies 0 and 0.5 out <-periodogram(WHORMONE,length(WHORMONE)/2,ACF=FALSE,type="cov")
data(WHORMONE) ## periodogram at Fourier frequencies and frequencies 0 and 0.5 out <-periodogram(WHORMONE,length(WHORMONE)/2,ACF=FALSE,type="cov")
periodotest
computes the p-value of the test for a hidden periodicityperiodotest
computes the p-value of the test for a hidden periodicity
periodotest(y)
periodotest(y)
y |
vector, the time series |
pval the p-value of the test
data(PIGPRICE) y <- PIGPRICE out <- stl(y,s.window=6) e <- out$time.series[,3] out <- periodotest(e)
data(PIGPRICE) y <- PIGPRICE out <- stl(y,s.window=6) e <- out$time.series[,3] out <- periodotest(e)
perwinba
Bartlett-Priestley window for direct spectral estimationperwinba
Bartlett-Priestley window for direct spectral estimation
perwinba(e, n)
perwinba(e, n)
e |
equal bandwidth (at most n frequencies are used for averaging) |
n |
length of time series |
w weights (symmetric)
data(WHORMONE) w <- perwinba(0.1,length(WHORMONE))
data(WHORMONE) w <- perwinba(0.1,length(WHORMONE))
perwinda
Daniell window for direct spectral estimationperwinda
Daniell window for direct spectral estimation
perwinda(e, n)
perwinda(e, n)
e |
equal bandwidth (at most n frequencies are used for averaging) |
n |
length of time series |
w weights (symmetric)
data(WHORMONE) w <- perwinda(0.1,length(WHORMONE))
data(WHORMONE) w <- perwinda(0.1,length(WHORMONE))
perwinpa
Parzen's window for direct spectral estimationperwinpa
Parzen's window for direct spectral estimation
perwinpa(e, n)
perwinpa(e, n)
e |
equal bandwidth (at most n frequencies are used for averaging) |
n |
length of time series |
w weights (symmetric)
data(WHORMONE) w <- perwinpa(0.1,length(WHORMONE))
data(WHORMONE) w <- perwinpa(0.1,length(WHORMONE))
pestep
help function for missarpestep
help function for missar
pestep(f, xt)
pestep(f, xt)
f |
IACF, inverse ACF |
xt |
segment of the time series |
xt new version of xt
Monthly prices for pigs
PIGPRICE
PIGPRICE
PIGPRICE is a univariate time series of length 240; start January 1894, frequency =12
Monthly prices for pigs
Hanau, A. (1928) "Die Prognose der Schweinepreise"
data(PIGPRICE) ## maybe tsp(PIGPRICE) ; plot(PIGPRICE)
data(PIGPRICE) ## maybe tsp(PIGPRICE) ; plot(PIGPRICE)
polymake
generates the coefficients of an AR process given the zeros of the
characteristic polynomial. The norm of the roots must be greater than one for stationary processes.polymake
generates the coefficients of an AR process given the zeros of the
characteristic polynomial. The norm of the roots must be greater than one for stationary processes.
polymake(r)
polymake(r)
r |
vector, the zeros of the characteristic polynomial |
C coefficients (a[1],a[2],...,a[p]) of the polynomial 1 - a[1]z -a[2]z^2 -...- a[p]z^p
C <- polymake(c(2,-1.5,3))
C <- polymake(c(2,-1.5,3))
Peak power demand in Berlin
PPDEMAND
PPDEMAND
PPDEMAND is a univariate time series of length 37; start 1955, frequency = 1
annual peak power demand in Berlin, Megawatt
Fiedler, H. (1979) "Verschiedene Verfahren zur Prognose des des Stromspitzenbedarfs in Berlin (West)"
data(PPDEMAND) ## maybe tsp(PPDEMAND) ; plot(PPDEMAND)
data(PPDEMAND) ## maybe tsp(PPDEMAND) ; plot(PPDEMAND)
Production index of manufacturing industries
PRODINDEX
PRODINDEX
PRODINDEX is a univariate time series of length 119:
Production index of manufacturing industries
Statistisches Bundesamt (2009) <https://www-genesis.destatis.de/genesis/online>
data(PRODINDEX) ## maybe tsp(PRODINDEX) ; plot(PRODINDEX)
data(PRODINDEX) ## maybe tsp(PRODINDEX) ; plot(PRODINDEX)
psifair
is a psi-function for robust estimationpsifair
is a psi-function for robust estimation
psifair(u)
psifair(u)
u |
vector |
out transformed vector
out <- psifair(c(3.3,-0.7,2.1,1.8))
out <- psifair(c(3.3,-0.7,2.1,1.8))
psihuber
is a psi-function for robust estimationpsihuber
is a psi-function for robust estimation
psihuber(u)
psihuber(u)
u |
vector |
out transformed vector
out <- psihuber(c(3.3,-0.7,2.1,1.8))
out <- psihuber(c(3.3,-0.7,2.1,1.8))
Annual amount of rainfall in Los Angeles
RAINFALL
RAINFALL
RAINFALL is a univariate time series of length 119; start 1878, frequency = 1
Amount of rainfall in Los Angeles
LA Times (January 28. 1997)
data(RAINFALL) ## maybe tsp(RAINFALL) ; plot(RAINFALL)
data(RAINFALL) ## maybe tsp(RAINFALL) ; plot(RAINFALL)
Monthly sales of Australian red wine (1000 l)
REDWINE
REDWINE
REDWINE is a univariate time series of length 187; start January 1980, frequency =12
Monthly sales of Australian red wine
R package tsdl <https://github.com/FinYang/tsdl>
data(REDWINE) ## maybe tsp(REDWINE) ; plot(REDWINE)
data(REDWINE) ## maybe tsp(REDWINE) ; plot(REDWINE)
rlassoHAC
performs Lasso estimation under heteroscedastic and autocorrelated non-Gaussian disturbances.rlassoHAC
performs Lasso estimation under heteroscedastic and autocorrelated non-Gaussian disturbances.
rlassoHAC( x, y, kernel = "Bartlett", bands = 10, bns = 10, lns = NULL, nboot = 5000, post = TRUE, intercept = TRUE, model = TRUE, X.dependent.lambda = FALSE, c = 2, gamma = NULL, numIter = 15, tol = 10^-5, threshold = NULL, ... )
rlassoHAC( x, y, kernel = "Bartlett", bands = 10, bns = 10, lns = NULL, nboot = 5000, post = TRUE, intercept = TRUE, model = TRUE, X.dependent.lambda = FALSE, c = 2, gamma = NULL, numIter = 15, tol = 10^-5, threshold = NULL, ... )
x |
Regressors (vector, matrix or object can be coerced to matrix). |
y |
Dependent variable (vector, matrix or object can be coerced to matrix). |
kernel |
Kernel function, choose between "Truncated", "Bartlett" (by default), "Parzen", "Tukey-Hanning", "Quadratic Spectral". |
bands |
Bandwidth parameter with default bands=10. |
bns |
Block length with default bns=10. |
lns |
Number of blocks with default lns = floor(T/bns). |
nboot |
Number of bootstrap iterations with default nboot=5000. |
post |
Logical. If TRUE (default), post-Lasso estimation is conducted, i.e. a refit of the model with the selected variables. |
intercept |
Logical. If TRUE, intercept is included which is not penalized. |
model |
Logical. If TRUE (default), model matrix is returned. |
X.dependent.lambda |
Logical, TRUE, if the penalization parameter depends on the design of the matrix x. FALSE (default), if independent of the design matrix. |
c |
Constant for the penalty, default value is 2. |
gamma |
Constant for the penalty, default gamma=0.1/log(T) with T=data length. |
numIter |
Number of iterations for the algorithm for the estimation of the variance and data-driven penalty, ie. loadings. |
tol |
Constant tolerance for improvement of the estimated variances. |
threshold |
Constant applied to the final estimated lasso coefficients. Absolute values below the threshold are set to zero. |
... |
further parameters |
rlassoHAC returns an object of class "rlasso". An object of class "rlasso" is a list containing at least the following components:
coefficients |
Parameter estimates. |
beta |
Parameter estimates (named vector of coefficients without intercept). |
intercept |
Value of the intercept. |
index |
Index of selected variables (logical vector). |
lambda |
Data-driven penalty term for each variable, product of lambda0 (the penalization parameter) and the loadings. |
lambda0 |
Penalty term. |
loadings |
Penalty loadings, vector of lenght p (no. of regressors). |
residuals |
Residuals, response minus fitted values. |
sigma |
Root of the variance of the residuals. |
iter |
Number of iterations. |
call |
Function call. |
options |
Options. |
model |
Model matrix (if model = TRUE in function call). |
Victor Chernozhukov, Chris Hansen, Martin Spindler (2016). hdm: High-Dimensional Metrics, R Journal, 8(2), 185-199. URL https://journal.r-project.org/archive/2016/RJ-2016-040/index.html.
set.seed(1) T = 100 #sample size p = 20 # number of variables b = 5 # number of variables with non-zero coefficients beta0 = c(rep(10,b), rep(0,p-b)) rho = 0.1 #AR parameter Cov = matrix(0,p,p) for(i in 1:p){ for(j in 1:p){ Cov[i,j] = 0.5^(abs(i-j)) } } C <- chol(Cov) X <- matrix(rnorm(T*p),T,p)%*%C eps <- arima.sim(list(ar=rho), n = T+100) eps <- eps[101:(T+100)] Y = X%*%beta0 + eps reg.lasso.hac1 <- rlassoHAC(X, Y,"Bartlett") #lambda is chosen independent of regressor #matrix X by default. bn = 10 # block length bwNeweyWest = 0.75*(T^(1/3)) reg.lasso.hac2 <- rlassoHAC(X, Y,"Bartlett", bands=bwNeweyWest, bns=bn, nboot=5000, X.dependent.lambda = TRUE, c=2.7)
set.seed(1) T = 100 #sample size p = 20 # number of variables b = 5 # number of variables with non-zero coefficients beta0 = c(rep(10,b), rep(0,p-b)) rho = 0.1 #AR parameter Cov = matrix(0,p,p) for(i in 1:p){ for(j in 1:p){ Cov[i,j] = 0.5^(abs(i-j)) } } C <- chol(Cov) X <- matrix(rnorm(T*p),T,p)%*%C eps <- arima.sim(list(ar=rho), n = T+100) eps <- eps[101:(T+100)] Y = X%*%beta0 + eps reg.lasso.hac1 <- rlassoHAC(X, Y,"Bartlett") #lambda is chosen independent of regressor #matrix X by default. bn = 10 # block length bwNeweyWest = 0.75*(T^(1/3)) reg.lasso.hac2 <- rlassoHAC(X, Y,"Bartlett", bands=bwNeweyWest, bns=bn, nboot=5000, X.dependent.lambda = TRUE, c=2.7)
rlassoLoad
performs Lasso estimation under heteroscedastic and autocorrelated non-Gaussian disturbances
with predefined penalty loadings.rlassoLoad
performs Lasso estimation under heteroscedastic and autocorrelated non-Gaussian disturbances
with predefined penalty loadings.
rlassoLoad( x, y, load, bns = 10, lns = NULL, nboot = 5000, post = TRUE, intercept = TRUE, model = TRUE, X.dependent.lambda = FALSE, c = 2, gamma = NULL, numIter = 15, tol = 10^-5, threshold = NULL, ... )
rlassoLoad( x, y, load, bns = 10, lns = NULL, nboot = 5000, post = TRUE, intercept = TRUE, model = TRUE, X.dependent.lambda = FALSE, c = 2, gamma = NULL, numIter = 15, tol = 10^-5, threshold = NULL, ... )
x |
Regressors (vector, matrix or object can be coerced to matrix). |
y |
Dependent variable (vector, matrix or object can be coerced to matrix). |
load |
Penalty loadings, vector of length p (no. of regressors). |
bns |
Block length with default bns=10. |
lns |
Number of blocks with default lns = floor(T/bns). |
nboot |
Number of bootstrap iterations with default nboot=5000. |
post |
Logical. If TRUE (default), post-Lasso estimation is conducted, i.e. a refit of the model with the selected variables. |
intercept |
Logical. If TRUE, intercept is included which is not penalized. |
model |
Logical. If TRUE (default), model matrix is returned. |
X.dependent.lambda |
Logical, TRUE, if the penalization parameter depends on the design of the matrix x. FALSE (default), if independent of the design matrix. |
c |
Constant for the penalty default is 2. |
gamma |
Constant for the penalty default gamma=0.1/log(T) with T=data length. |
numIter |
Number of iterations for the algorithm for the estimation of the variance and data-driven penalty. |
tol |
Constant tolerance for improvement of the estimated variances. |
threshold |
Constant applied to the final estimated lasso coefficients. Absolute values below the threshold are set to zero. |
... |
further parameters |
rlassoLoad returns an object of class "rlasso". An object of class "rlasso" is a list containing at least the following components:
coefficients |
Parameter estimates. |
beta |
Parameter estimates (named vector of coefficients without intercept). |
intercept |
Value of the intercept. |
index |
Index of selected variables (logical vector). |
lambda |
Data-driven penalty term for each variable, product of lambda0 (the penalization parameter) and the loadings. |
lambda0 |
Penalty term. |
loadings |
Penalty loadings, vector of lenght p (no. of regressors). |
residuals |
Residuals, response minus fitted values. |
sigma |
Root of the variance of the residuals. |
iter |
Number of iterations. |
call |
Function call. |
options |
Options. |
model |
Model matrix (if model = TRUE in function call). |
Victor Chernozhukov, Chris Hansen, Martin Spindler (2016). hdm: High-Dimensional Metrics, R Journal, 8(2), 185-199. URL https://journal.r-project.org/archive/2016/RJ-2016-040/index.html.
set.seed(1) T = 100 #sample size p = 20 # number of variables b = 5 # number of variables with non-zero coefficients beta0 = c(rep(10,b), rep(0,p-b)) rho = 0.1 #AR parameter Cov = matrix(0,p,p) for(i in 1:p){ for(j in 1:p){ Cov[i,j] = 0.5^(abs(i-j)) } } C <- chol(Cov) X <- matrix(rnorm(T*p),T,p)%*%C eps <- arima.sim(list(ar=rho), n = T+100) eps <- eps[101:(T+100)] Y = X%*%beta0 + eps fit1 = rlasso(X, Y, penalty = list(homoscedastic = "none", lambda.start = 2*0.5*sqrt(T)*qnorm(1-0.1/(2*p))), post=FALSE) beta = fit1$beta intercept = fit1$intercept res = Y - X %*% beta - intercept * rep(1, length(Y)) load = rep(0,p) for(i in 1:p){ load[i] = sqrt(lrvar(X[,i]*res)*T) } reg.lasso.load1 <- rlassoLoad(X,Y,load) #lambda is chosen independent of regressor #matrix X by default. bn = 10 # block length reg.lasso.load2 <- rlassoLoad(X, Y,load, bns=bn, nboot=5000, X.dependent.lambda = TRUE, c=2.7)
set.seed(1) T = 100 #sample size p = 20 # number of variables b = 5 # number of variables with non-zero coefficients beta0 = c(rep(10,b), rep(0,p-b)) rho = 0.1 #AR parameter Cov = matrix(0,p,p) for(i in 1:p){ for(j in 1:p){ Cov[i,j] = 0.5^(abs(i-j)) } } C <- chol(Cov) X <- matrix(rnorm(T*p),T,p)%*%C eps <- arima.sim(list(ar=rho), n = T+100) eps <- eps[101:(T+100)] Y = X%*%beta0 + eps fit1 = rlasso(X, Y, penalty = list(homoscedastic = "none", lambda.start = 2*0.5*sqrt(T)*qnorm(1-0.1/(2*p))), post=FALSE) beta = fit1$beta intercept = fit1$intercept res = Y - X %*% beta - intercept * rep(1, length(Y)) load = rep(0,p) for(i in 1:p){ load[i] = sqrt(lrvar(X[,i]*res)*T) } reg.lasso.load1 <- rlassoLoad(X,Y,load) #lambda is chosen independent of regressor #matrix X by default. bn = 10 # block length reg.lasso.load2 <- rlassoLoad(X, Y,load, bns=bn, nboot=5000, X.dependent.lambda = TRUE, c=2.7)
robsplinedecomp
decomposes a vector into trend, season and irregular component
by robustified spline approach; a time series attribute is lostrobsplinedecomp
decomposes a vector into trend, season and irregular component
by robustified spline approach; a time series attribute is lost
robsplinedecomp(y, d, alpha, beta, Plot = FALSE)
robsplinedecomp(y, d, alpha, beta, Plot = FALSE)
y |
the series, a vector or a time series |
d |
seasonal period |
alpha |
smoothing parameter for trend component (the larger alpha is, the smoother will the smooth component g be) |
beta |
smoothing parameter for seasonal component |
Plot |
logical, should a plot be produced? |
out list with the elements trend, season, residual
data(GDP) out <- robsplinedecomp(GDP,4,2,10,Plot=FALSE)
data(GDP) out <- robsplinedecomp(GDP,4,2,10,Plot=FALSE)
RS
rescaled adjusted range statisticRS
rescaled adjusted range statistic
RS(x, k)
RS(x, k)
x |
univariate time series |
k |
length of the segments for which the statistic is computed. Starting with t=1, the segments do not overlap. |
(l,3)-matrix, 1. column: k, second column: starting time of segment, third column: value of RS statistic.
data(TREMOR) R <- RS(TREMOR,10)
data(TREMOR) R <- RS(TREMOR,10)
Monthly sales of a company
SALES
SALES
SALES is a univariate time series of length 77:
monthly sales of a company
Newton, H. J. (1988, ISBN: 978-0534091989): "TIMESLAB: A time series analysis laboraty"
data(SALES) ## maybe tsp(SALES) ; plot(SALES)
data(SALES) ## maybe tsp(SALES) ; plot(SALES)
CO2-Concentration obtained in Schauinsland, Germany
SCHAUINSLAND
SCHAUINSLAND
SCHAUINSLAND is a univariate time series of length 72:
CO2-Concentration obtained in Schauinsland
<http://cdiac.ornl.gov/trends/co2/uba/uba-sc.html>
data(SCHAUINSLAND) ## maybe tsp(SCHAUINSLAND) ; plot(SCHAUINSLAND)
data(SCHAUINSLAND) ## maybe tsp(SCHAUINSLAND) ; plot(SCHAUINSLAND)
simpledecomp
decomposes a vector into trend, season and irregular component
by linear regression approachsimpledecomp
decomposes a vector into trend, season and irregular component
by linear regression approach
simpledecomp(y, trend = 0, season = 0, Plot = FALSE)
simpledecomp(y, trend = 0, season = 0, Plot = FALSE)
y |
the series, a vector or a time series |
trend |
order of trend polynomial |
season |
period of seasonal component |
Plot |
logical, should a plot be produced? |
out: (n,3) matrix
1. column |
smooth component |
2. column |
seasonal component |
3. column |
irregular component |
data(GDP) out <- simpledecomp(GDP,trend=3,season=4,Plot=FALSE)
data(GDP) out <- simpledecomp(GDP,trend=3,season=4,Plot=FALSE)
smoothls
smoothes a time series by Whittaker graduation.
The function depends on the package Matrix.smoothls
smoothes a time series by Whittaker graduation.
The function depends on the package Matrix.
smoothls(y, beta = 0)
smoothls(y, beta = 0)
y |
the series, a vector or a time series |
beta |
smoothing parameter >=0 (the larger beta is, the smoother will g be) |
g vector, smooth component
data(GDP) g <- smoothls(GDP,12) plot(GDP) t <- seq(from = tsp(GDP)[1], to = tsp(GDP)[2],by=1/tsp(GDP)[3]) ; lines(t,g,col="red")
data(GDP) g <- smoothls(GDP,12) plot(GDP) t <- seq(from = tsp(GDP)[1], to = tsp(GDP)[2],by=1/tsp(GDP)[3]) ; lines(t,g,col="red")
smoothrb
smoothes a time series robustly by using Huber's psi-function.
The initialisation uses a moving median.smoothrb
smoothes a time series robustly by using Huber's psi-function.
The initialisation uses a moving median.
smoothrb(y, beta = 0, q = NA)
smoothrb(y, beta = 0, q = NA)
y |
the series, a vector or a time series |
beta |
smoothing parameter (The larger beta is, the smoother will the smooth component g be.) |
q |
length of running median which is used to get initial values |
g vector, the smooth component
data(GDP) g <- smoothrb(GDP,8,q=8) plot(GDP) ; t <- seq(from = 1970, to = 2009.5,by=0.25) ; lines(t,g,col="red")
data(GDP) g <- smoothrb(GDP,8,q=8) plot(GDP) ; t <- seq(from = 1970, to = 2009.5,by=0.25) ; lines(t,g,col="red")
specest
direct spectral estimation of series y
using periodogram window winspecest
direct spectral estimation of series y
using periodogram window win
specest( y, nf, e, win = c("perwinba", "perwinpa", "perwinda"), conf = 0, type = "cov" )
specest( y, nf, e, win = c("perwinba", "perwinpa", "perwinda"), conf = 0, type = "cov" )
y |
(n,1) vector, the ts |
nf |
number of equally spaced frequencies |
e |
equal bandwidth, must be 0 <= e <0.5 |
win |
string, name of periodogram window (possible: "perwinba", "perwinpa", "perwinda") |
conf |
scalar, the level for confidence intervals |
type |
c("cov","cor"), area under spectrum is variance or is normed to 1. |
est (nf+1,2)- or (nf+1,4)-matrix:
column 1: |
frequencies 0, 1/n, 2/n, ..., m/n |
column 2: |
the estimated spectrum |
column 3+4: |
the confidence bounds |
data(WHORMONE) est <- specest(WHORMONE,50,0.05,win = c("perwinba","perwinpa","perwinda"),conf=0,type="cov")
data(WHORMONE) est <- specest(WHORMONE,50,0.05,win = c("perwinba","perwinpa","perwinda"),conf=0,type="cov")
specplot
plot of spectral estimatespecplot
plot of spectral estimate
specplot(s, Log = FALSE)
specplot(s, Log = FALSE)
s |
(n,2) or (n,4) matrix, output of specest |
Log |
logical, if TRUE, the logs of the spectral estimates are shown |
data(WHORMONE) est <- specest(WHORMONE,50,0.05,win = c("perwinba","perwinpa"),conf=0,type="cov") specplot(est,Log=FALSE)
data(WHORMONE) est <- specest(WHORMONE,50,0.05,win = c("perwinba","perwinpa"),conf=0,type="cov") specplot(est,Log=FALSE)
splinedecomp
decomposes a time series into trend, season and irregular component
by spline approach.splinedecomp
decomposes a time series into trend, season and irregular component
by spline approach.
splinedecomp(x, d, alpha, beta, Plot = FALSE)
splinedecomp(x, d, alpha, beta, Plot = FALSE)
x |
the series, a vector or a time series |
d |
seasonal period |
alpha |
smoothing parameter for trend component (The larger alpha is, the smoother will the smooth component g be.) |
beta |
smoothing parameter for seasonal component |
Plot |
logical, should a plot be produced? |
out (n,3) matrix:
1. column |
smooth component |
2. column |
seasonal component |
3. column |
irregular component |
data(GDP) out <- splinedecomp(GDP,4,2,4,Plot=FALSE)
data(GDP) out <- splinedecomp(GDP,4,2,4,Plot=FALSE)
Annual logging of spruce wood.
SPRUCE
SPRUCE
SPRUCE is a univariate time series of length 42:
Annual logging of spruce wood
data(SPRUCE) ## maybe tsp(SPRUCE) ; plot(SPRUCE)
data(SPRUCE) ## maybe tsp(SPRUCE) ; plot(SPRUCE)
statcheck
determines the means, standard deviations and acf's of segmets of a time series
and plots the acf's for the segments.statcheck
determines the means, standard deviations and acf's of segmets of a time series
and plots the acf's for the segments.
statcheck(y, d)
statcheck(y, d)
y |
the series, a vector or a time series |
d |
scalar, number of segments |
out list with components:
ms |
matrix with means and standard deviations of the segments |
ac |
matrix with acf's, the first column: acf of the series, the others: acf's of the segments |
data(COFFEE) out <- statcheck(COFFEE,4)
data(COFFEE) out <- statcheck(COFFEE,4)
subsets
determines all subsets of a set of n elements (labelled by 1,2,...,n ).subsets
determines all subsets of a set of n elements (labelled by 1,2,...,n ).
subsets(n)
subsets(n)
n |
scalar, integer >= 1 |
mat (2^n,n)-matrix, each row gives the membership indicators of the elements 1,2,...,n
out <- subsets(4)
out <- subsets(4)
symplot
produces a symmetry plotsymplot
produces a symmetry plot
symplot(y)
symplot(y)
y |
the series, a vector or a time series |
data(LYNX) symplot(LYNX)
data(LYNX) symplot(LYNX)
taper
taper modification of a time seriestaper
taper modification of a time series
taper(y, part)
taper(y, part)
y |
the time series |
part |
scalar, 0 <= part <= 0.5, part of modification (at each end of y) |
tp tapered time series
data(WHORMONE) out <-taper(WHORMONE,0.3) plot(WHORMONE) lines(out,col="red")
data(WHORMONE) out <-taper(WHORMONE,0.3) plot(WHORMONE) lines(out,col="red")
Monthly community taxes in Germany (billions EURO)
TAXES
TAXES
TAXES is a univariate time series of length 246; start January 1999, frequency = 12
monthly community taxes in Germany
<https://www-genesis.destatis.de/genesis/online?operation=previous&levelindex=1&step=1&titel=
Tabellenaufbau&levelid=1583748637039>
data(TAXES) ## maybe tsp(TAXES) ; plot(TAXES)
data(TAXES) ## maybe tsp(TAXES) ; plot(TAXES)
Mean thickness of annual tree rings
TREERING
TREERING
TREERING is a multivariate time series of length 66 with 3 variables:
mean thickness of annual tree rings
mean temperature of the year
amount of rain of the year
<https://ltrr.arizona.edu/>
data(TREERING) ## maybe tsp(TREERING) ; plot(TREERING)
data(TREERING) ## maybe tsp(TREERING) ; plot(TREERING)
Measurements of physiological tremor
TREMOR
TREMOR
TREMOR is a univariate time series of length 400.
Tremor
data(TREMOR) ## maybe tsp(TREMOR) ; plot(TREMOR)
data(TREMOR) ## maybe tsp(TREMOR) ; plot(TREMOR)
tsmat
constructs a (n-p+1,p) matrix from a time series
where the first column is the shortened series y[p],...,y[n], the second is y[p-1],...,y[n-1], etc.tsmat
constructs a (n-p+1,p) matrix from a time series
where the first column is the shortened series y[p],...,y[n], the second is y[p-1],...,y[n-1], etc.
tsmat(y, p)
tsmat(y, p)
y |
the series, a vector or a time series of length n |
p |
desired number of columns |
mat (n-p+1,p) matrix
out <- tsmat(c(1:20),4)
out <- tsmat(c(1:20),4)
Population of USA
USAPOP
USAPOP
USAPOP is a univariate time series of length 39; start 1630, frequency = 0.1
Population of USA
<https://www.worldometers.info/world-population/us-population/>
data(USAPOP) ## maybe tsp(USAPOP) ; plot(USAPOP)
data(USAPOP) ## maybe tsp(USAPOP) ; plot(USAPOP)
vartable
determines table of variate differencesvartable
determines table of variate differences
vartable(y, season)
vartable(y, season)
y |
the series, a vector or a time series ( no NA's ) |
season |
scalar, period of seasonal component |
d matrix with ratios of variances for differend numbers of simple and seasonal differencing
data(GDP) out <- vartable(GDP,4)
data(GDP) out <- vartable(GDP,4)
Concentration of growth hormone of a bull
WHORMONE
WHORMONE
WHORMONE is a univariate time series of length 97:
Concentration of growth hormone of a bull
Newton, H. J. (1988, ISBN: 978-0534091989): "TIMESLAB: A time series analysis laboraty"
data(WHORMONE) ## maybe tsp(WHORMONE) ; plot(WHORMONE)
data(WHORMONE) ## maybe tsp(WHORMONE) ; plot(WHORMONE)
wntest
graphical test for white noise for a time series or a series of regression residualswntest
graphical test for white noise for a time series or a series of regression residuals
wntest(e, a, k = 0)
wntest(e, a, k = 0)
e |
vector, the time series (k = 0) or residuals (k > 0) |
a |
scalar, level of significance |
k |
scalar >= 0, number of regressors used to compute e as residuals |
tp vector, value of test statistic and p-value
data(WHORMONE) out <- wntest(WHORMONE,0.05,0)
data(WHORMONE) out <- wntest(WHORMONE,0.05,0)