Learn R Programming

픸 핊 핋 핊 픸 ⚡ 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.

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.


WARNING: If loaded, the package dplyr may (and probably will) mask 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"))   # load without 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 

 Also, consider that dplyr is a MUCH SLOWER version of data.table. So try data.table if you have to do data manipulation. AND, when you load data.table, there are ZERO masked warnings!!!



Copy Link

Version

Install

install.packages('astsa')

Monthly Downloads

13,109

Version

2.4

License

GPL (>= 2)

Maintainer

David Stoffer

Last Published

December 15th, 2025

Functions in astsa (2.4)

Ksmooth

Quick Kalman Smoother
Grid

A Better Add Grid to a Plot
Hare

Snowshoe Hare
Kfilter

Quick Kalman Filter
MEI

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

Hematocrit Levels
SV.mcmc

Fit Bayesian Stochastic Volatility Model
USpop

U.S. Population - 1900 to 2010
QQnorm

Normal Quantile-Quantile Plot
SigExtract

Signal Extraction And Optimal Filtering
PLT

Platelet Levels
UnempRate

U.S. Unemployment Rate
Months

Month Labels
SV.mle

Stochastic Volatility Model with Feedback via MLE
MEI2

Multivariate El Nino/Southern Oscillation Index (version 2)
USpop20

U.S. Population - 1900 to 2020
WBC

White Blood Cell Levels
ar.boot

Bootstrap Distribution of AR Model Parameters
arf

Simulated ARFIMA
acfm

ACF and CCF for Multiple Time Series
ar.mcmc

Fit Bayesian AR Model
arma.spec

Spectral Density of an ARMA Model
acf2

Plot and print ACF and PACF of a time series
ar1miss

AR with Missing Values
acf1

Plot and print ACF or PACF of a time series
arma.check

Check an ARMA Model for Causality, Invertibility, and Parameter Redundancy
bart

Bartlett Kernel
birth

U.S. Monthly Live Births
autoSpec

autoSpec - Changepoint Detection of Narrowband Frequency Changes
beamd

Infrasonic Signal from a Nuclear Explosion
astsa.col

astsa color palette with transparency or a color wheel
blood

Daily Blood Work with Missing Values
astsa-package

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

autoParm - Structural Break Estimation Using AR Models
bnrf1hvs

Nucleotide sequence - BNRF1 of Herpesvirus saimiri
bnrf1ebv

Nucleotide sequence - BNRF1 Epstein-Barr
chicken

Monthly price of a pound of chicken
detrend

Detrend a Time Series
econ5

Five Quarterly Economic Series
cardox

Monthly Carbon Dioxide Levels at Mauna Loa
djia

Dow Jones Industrial Average
dna2vector

Convert DNA Sequence to Indicator Vectors
climhyd

Lake Shasta inflow data
cpg

Hard Drive Cost per GB
ccf2

Cross Correlation
cmort

Cardiovascular Mortality from the LA Pollution study
gtemp_both

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

Forward Filtering Backward Sampling
flu

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

fMRI Data Used in Chapter 1
gdp

Quarterly U.S. GDP
gnp

Quarterly U.S. GNP
gas

Gas Prices
eqexp

Earthquake and Explosion Seismic Series
gtemp.month

Monthly global average surface temperatures by year
fmri

fMRI - complete data set
hor

Hawaiian occupancy rates
lap

LA Pollution-Mortality Study
lag1.plot

Lag Plot - one time series
lag2.plot

Lag Plot - two time series
lap.xts

LA Pollution-Mortality Study: Sampled Daily
matrixpwr

Powers of a Square Matrix
lead

Leading Indicator
jj

Johnson and Johnson Quarterly Earnings Per Share
gtemp_ocean

Global mean ocean temperature deviations, 1850-2023
gtemp_land

Global mean land temperature deviations, 1850-2023
qinfl

Quarterly Inflation
qintr

Quarterly Interest Rate
pre.white

Cross-Correlation Analysis With Automatic Prewhitening
polyMul

Multiplication of Two Polynomials
polio

Poliomyelitis cases in US
mvspec

Univariate and Multivariate Spectral Estimation
nyse

Returns of the New York Stock Exchange
prodn

Monthly Federal Reserve Board Production Index
oil

Crude oil, WTI spot price FOB
part

Particulate levels from the LA pollution study
rec

Recruitment (number of new fish index)
scatter.hist

Scatterplot with Marginal Histograms
sarima.for

ARIMA Forecasting
sarima

Fit ARIMA Models
saltemp

Temperature Profiles
salt

Salt Profiles
sarima.sim

ARIMA Simulation
sleep1

Sleep State and Movement Data - Group 1
salmon

Monthly export price of salmon
sales

Sales
spec.ic

Estimate Spectral Density of a Time Series from AR Fit
specenv

Spectral Envelope
soi

Southern Oscillation Index
sp500w

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

Spatial Grid of Surface Soil Temperatures
sleep2

Sleep State and Movement Data - Group 2
speech

Speech Recording
ssm

State Space Model
sp500.gr

Returns of the S&P 500
so2

SO2 levels from the LA pollution study
ttable

t-table summary for an lm object
star

Variable Star
tempr

Temperatures from the LA pollution study
tspairs

Scatterplot Matrix for Time Series
stoch.reg

Frequency Domain Stochastic Regression
tsplot

Time Series Plot
sunspotz

Biannual Sunspot Numbers
trend

Estimate Trend
timex

Convert eXtensible Time Series Dates to Decimal Dates
test.linear

Test Linearity of a Time Series via Normalized Bispectrum
varve

Annual Varve Series
unemp

U.S. Unemployment
ARMAtoAR

Convert ARMA Process to Infinite AR Process
EQcount

Earthquake Counts
FDR

Basic False Discovery Rate
EQ5

Seismic Trace of Earthquake number 5
ESS

Effective Sample Size (ESS)
ENSO

El Nino - Southern Oscillation Index
Lynx

Canadian Lynx
EBV

Entire Epstein-Barr Virus (EBV) Nucleotide Sequence
EXP6

Seismic Trace of Explosion number 6
BCJ

Daily Returns of Three Banks
GDP23

Quarterly U.S. GDP - updated to 2023
GNP23

Quarterly U.S. GNP - updated to 2023
LagReg

Lagged Regression
EM

EM Algorithm for State Space Models