Learn R Programming

astsa — applied statistical time series analysis

... more than just data ... it's also 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. Most scripts are designed to require minimal input to produce aesthetically pleasing output for ease of use in live demonstrations and course work.

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 but no longer needed
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
dlag    = dplyr::lag                           # then correct ... 
dfilter = dplyr::filter                        # ... the blunders
#  Now use `dlag` and `dfilter` 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
dlag    = dplyr::lag     
dfilter = dplyr::filter 

Copy Link

Version

Install

install.packages('astsa')

Monthly Downloads

6,176

Version

2.3

License

GPL (>= 2)

Maintainer

David Stoffer

Last Published

August 21st, 2025

Functions in astsa (2.3)

LagReg

Lagged Regression
Hare

Snowshoe Hare
GDP23

Quarterly U.S. GDP - updated to 2023
Grid

A Better Add Grid to a Plot
Ksmooth

Quick Kalman Smoother
USpop

U.S. Population - 1900 to 2010
MEI

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

Canadian Lynx
HCT

Hematocrit Levels
GNP23

Quarterly U.S. GNP - updated to 2023
Months

Month Labels
PLT

Platelet Levels
Kfilter

Quick Kalman Filter
UnempRate

U.S. Unemployment Rate
WBC

White Blood Cell Levels
SV.mcmc

Fit Bayesian Stochastic Volatility Model
SV.mle

Stochastic Volatility Model with Feedback via MLE
QQnorm

Normal Quantile-Quantile Plot
USpop20

U.S. Population - 1900 to 2020
SigExtract

Signal Extraction And Optimal Filtering
ar.boot

Bootstrap Distribution of AR Model Parameters
ar.mcmc

Fit Bayesian AR Model
acf1

Plot and print ACF or PACF of a time series
acfm

ACF and CCF for Multiple Time Series
arf

Simulated ARFIMA
arma.spec

Spectral Density of an ARMA Model
blood

Daily Blood Work with Missing Values
autoSpec

autoSpec - Changepoint Detection of Narrowband Frequency Changes
ar1miss

AR with Missing Values
acf2

Plot and print ACF and PACF of a time series
bart

Bartlett Kernel
cardox

Monthly Carbon Dioxide Levels at Mauna Loa
detrend

Detrend a Time Series
bnrf1hvs

Nucleotide sequence - BNRF1 of Herpesvirus saimiri
autoParm

autoParm - Structural Break Estimation Using AR Models
birth

U.S. Monthly Live Births
astsa.col

astsa color palette with transparency or a color wheel
ccf2

Cross Correlation
astsa-package

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

Dow Jones Industrial Average
gtemp_land

Global mean land temperature deviations, 1850-2023
bnrf1ebv

Nucleotide sequence - BNRF1 Epstein-Barr
gnp

Quarterly U.S. GNP
eqexp

Earthquake and Explosion Seismic Series
gdp

Quarterly U.S. GDP
gtemp_ocean

Global mean ocean temperature deviations, 1850-2023
dna2vector

Convert DNA Sequence to Indicator Vectors
cpg

Hard Drive Cost per GB
cmort

Cardiovascular Mortality from the LA Pollution study
gas

Gas Prices
beamd

Infrasonic Signal from a Nuclear Explosion
econ5

Five Quarterly Economic Series
chicken

Monthly price of a pound of chicken
flu

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

LA Pollution-Mortality Study: Sampled Daily
fmri1

fMRI Data Used in Chapter 1
gtemp_both

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

fMRI - complete data set
gtemp.month

Monthly global average surface temperatures by year
ffbs

Forward Filtering Backward Sampling
lap

LA Pollution-Mortality Study
hor

Hawaiian occupancy rates
lag2.plot

Lag Plot - two time series
matrixpwr

Powers of a Square Matrix
jj

Johnson and Johnson Quarterly Earnings Per Share
mvspec

Univariate and Multivariate Spectral Estimation
nyse

Returns of the New York Stock Exchange
climhyd

Lake Shasta inflow data
lag1.plot

Lag Plot - one time series
part

Particulate levels from the LA pollution study
rec

Recruitment (number of new fish index)
oil

Crude oil, WTI spot price FOB
pre.white

Cross-Correlation Analysis With Automatic Prewhitening
polio

Poliomyelitis cases in US
qinfl

Quarterly Inflation
lead

Leading Indicator
sales

Sales
polyMul

Multiplication of Two Polynomials
prodn

Monthly Federal Reserve Board Production Index
qintr

Quarterly Interest Rate
scatter.hist

Scatterplot with Marginal Histograms
sarima

Fit ARIMA Models
salmon

Monthly export price of salmon
sleep1

Sleep State and Movement Data - Group 1
sleep2

Sleep State and Movement Data - Group 2
sarima.for

ARIMA Forecasting
sarima.sim

ARIMA Simulation
so2

SO2 levels from the LA pollution study
saltemp

Temperature Profiles
salt

Salt Profiles
sp500.gr

Returns of the S&P 500
soi

Southern Oscillation Index
specenv

Spectral Envelope
sp500w

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

Variable Star
soiltemp

Spatial Grid of Surface Soil Temperatures
spec.ic

Estimate Spectral Density of a Time Series from AR Fit
stoch.reg

Frequency Domain Stochastic Regression
ssm

State Space Model
speech

Speech Recording
unemp

U.S. Unemployment
varve

Annual Varve Series
tempr

Temperatures from the LA pollution study
tspairs

Scatterplot Matrix for Time Series
tsplot

Time Series Plot
ttable

t-table summary for an lm object
sunspotz

Biannual Sunspot Numbers
test.linear

Test Linearity of a Time Series via Normalized Bispectrum
trend

Estimate Trend
EBV

Entire Epstein-Barr Virus (EBV) Nucleotide Sequence
EQcount

Earthquake Counts
ENSO

El Nino - Southern Oscillation Index
ARMAtoAR

Convert ARMA Process to Infinite AR Process
EQ5

Seismic Trace of Earthquake number 5
EXP6

Seismic Trace of Explosion number 6
FDR

Basic False Discovery Rate
ESS

Effective Sample Size (ESS)
EM

EM Algorithm for State Space Models
BCJ

Daily Returns of Three Banks