Learn R Programming

astsa — applied statistical time series analysis

... more than just data ... it's a palindrome


... astsa includes data sets and scripts for analyzing time series in both the frequency and time domains including state space modeling as well as supporting the Springer text, Time Series Analysis and Its Applications: With R Examples and the Chapman & Hall text Time Series: A Data Analysis Approach using R.

We do not always push the latest version of the package to CRAN, but the latest working version of the package will always be at Github.

  • The ROAD MAP is a good place to start to find all the links to the webpages for the texts and some help on using R for time series analysis.
  • See the NEWS for further details about the state of the package, how to install the latest version, and the changelog.

  • WARNING: If loaded, the package dplyr may (and probably will) corrupt the base scripts filter and lag that a time series analyst uses often. An easy fix if you’re analyzing time series (or teaching a class) is to (tell students to) do the following if dplyr is going being used:
# [1] either detach it if it's loaded and no
detach(package:dplyr)  

# [2] or fix it yourself when loading dplyr 
# this is a great idea from  https://stackoverflow.com/a/65186251
library(dplyr, exclude = c("filter", "lag"))  # remove the culprits
Lag <- dplyr::lag            # and do what the dplyr ... 
Filter <- dplyr::filter      # ... maintainer refuses to do
# then use `Lag` and `Filter` in dplyr scripts and
# `lag` and `filter` can be use as originally intended

# [3] or just take back the commands
filter = stats::filter
lag = stats::lag

# in this case, you can still use these for dplyr
Lag <- dplyr::lag     
Filter <- dplyr::filter 

Copy Link

Version

Install

install.packages('astsa')

Monthly Downloads

6,703

Version

2.2

License

GPL (>= 2)

Maintainer

David Stoffer

Last Published

January 16th, 2025

Functions in astsa (2.2)

GNP23

Quarterly U.S. GNP - updated to 2023
Hare

Snowshoe Hare
MEI

Multivariate El Nino/Southern Oscillation Index (version 1)
Lynx

Canadian Lynx
LagReg

Lagged Regression
GDP23

Quarterly U.S. GDP - updated to 2023
WBC

White Blood Cell Levels
Kfilter

Quick Kalman Filter
acf1

Plot and print ACF or PACF of a time series
SigExtract

Signal Extraction And Optimal Filtering
SV.mle

Stochastic Volatility Model with Feedback via MLE
PLT

Platelet Levels
Months

Month Labels
UnempRate

U.S. Unemployment Rate
USpop

U.S. Population - 1900 to 2010
astsa.col

astsa color palette with transparency
autoParm

autoParm - Structural Break Estimation Using AR Models
ccf2

Cross Correlation
autoSpec

autoSpec - Changepoint Detection of Narrowband Frequency Changes
arma.spec

Spectral Density of an ARMA Model
bart

Bartlett Kernel
astsa-package

Applied Statistical Time Series Analysis (more than just data)
blood

Daily Blood Work with Missing Values
bnrf1ebv

Nucleotide sequence - BNRF1 Epstein-Barr
ar.mcmc

Fit Bayesian AR Model
chicken

Monthly price of a pound of chicken
ar.boot

Bootstrap Distribution of AR Model Parameters
QQnorm

Normal Quantile-Quantile Plot
hor

Hawaiian occupancy rates
econ5

Five Quarterly Economic Series
eqexp

Earthquake and Explosion Seismic Series
gtemp_ocean

Global mean ocean temperature deviations, 1850-2023
acfm

ACF and CCF for Multiple Time Series
SV.mcmc

Fit Bayesian Stochastic Volatility Model
bnrf1hvs

Nucleotide sequence - BNRF1 of Herpesvirus saimiri
ar1miss

AR with Missing Values
acf2

Plot and print ACF and PACF of a time series
cmort

Cardiovascular Mortality from the LA Pollution study
climhyd

Lake Shasta inflow data
jj

Johnson and Johnson Quarterly Earnings Per Share
arf

Simulated ARFIMA
lag1.plot

Lag Plot - one time series
qinfl

Quarterly Inflation
gas

Gas Prices
prodn

Monthly Federal Reserve Board Production Index
fmri

fMRI - complete data set
gdp

Quarterly U.S. GDP
ffbs

Forward Filtering Backward Sampling
beamd

Infrasonic Signal from a Nuclear Explosion
fmri1

fMRI Data Used in Chapter 1
flu

Monthly pneumonia and influenza deaths in the U.S., 1968 to 1978.
birth

U.S. Monthly Live Births
oil

Crude oil, WTI spot price FOB
cardox

Monthly Carbon Dioxide Levels at Mauna Loa
nyse

Returns of the New York Stock Exchange
djia

Dow Jones Industrial Average
matrixpwr

Powers of a Square Matrix
cpg

Hard Drive Cost per GB
part

Particulate levels from the LA pollution study
mvspec

Univariate and Multivariate Spectral Estimation
qintr

Quarterly Interest Rate
sarima.sim

ARIMA Simulation
gnp

Quarterly U.S. GNP
lap.xts

LA Pollution-Mortality Study: Sampled Daily
gtemp.month

Monthly global average surface temperatures by year
dna2vector

Convert DNA Sequence to Indicator Vectors
scatter.hist

Scatterplot with Marginal Histograms
lead

Leading Indicator
polyMul

Multiplication of Two Polynomials
detrend

Detrend a Time Series
gtemp_both

Global mean land and open ocean temperature deviations, 1850-2023
rec

Recruitment (number of new fish index)
salmon

Monthly export price of salmon
lag2.plot

Lag Plot - two time series
sleep1

Sleep State and Movement Data - Group 1
sleep2

Sleep State and Movement Data - Group 2
sales

Sales
gtemp_land

Global mean land temperature deviations, 1850-2023
lap

LA Pollution-Mortality Study
stoch.reg

Frequency Domain Stochastic Regression
sp500w

Weekly Growth Rate of the Standard and Poor's 500
sunspotz

Biannual Sunspot Numbers
trend

Estimate Trend
sarima

Fit ARIMA Models
polio

Poliomyelitis cases in US
soiltemp

Spatial Grid of Surface Soil Temperatures
spec.ic

Estimate Spectral Density of a Time Series from AR Fit
sarima.for

ARIMA Forecasting
pre.white

Cross-Correlation Analysis With Automatic Prewhitening
salt

Salt Profiles
test.linear

Test Linearity of a Time Series via Normalized Bispectrum
tempr

Temperatures from the LA pollution study
so2

SO2 levels from the LA pollution study
soi

Southern Oscillation Index
tsplot

Time Series Plot
saltemp

Temperature Profiles
star

Variable Star
ssm

State Space Model
unemp

U.S. Unemployment
varve

Annual Varve Series
speech

Speech Recording
specenv

Spectral Envelope
sp500.gr

Returns of the S&P 500
FDR

Basic False Discovery Rate
EXP6

Seismic Trace of Explosion number 6
EBV

Entire Epstein-Barr Virus (EBV) Nucleotide Sequence
BCJ

Daily Returns of Three Banks
ARMAtoAR

Convert ARMA Process to Infinite AR Process
EM

EM Algorithm for State Space Models
Ksmooth

Quick Kalman Smoother
EQcount

Earthquake Counts
ENSO

El Nino - Southern Oscillation Index
EQ5

Seismic Trace of Earthquake number 5
ESS

Effective Sample Size (ESS)
Grid

A Better Add Grid to a Plot
HCT

Hematocrit Levels