Skip to content

Commit acd4796

Browse files
committed
v2.4
2025-10-28 00:37:04
1 parent 07a4e1b commit acd4796

File tree

8 files changed

+55
-16
lines changed

8 files changed

+55
-16
lines changed

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ remotes::install_github("nickpoison/astsa/astsa_build")
4747

4848
> We'll send this version to CRAN when the 2nd edition of [Time Series: A Data Analysis Approach ...](https://www.routledge.com/Time-Series-A-Data-Analysis-Approach-Using-R/Shumway-Stoffer/p/book/9781041031642) is published. The planned publication date is Jan/Feb 2026.
4949
50+
- in `arma.spec`, added option (`redundancy.tol`) to specify how close roots have to be to report a warning of parameter redundancy or over-parameterization (default is .1).
51+
52+
> For example, `arma.spec(ar=.9, ma=-.85)` will report over-parameterization, whereas `arma.spec(ar=.9, ma=-.85, red=.05)` will not because the roots are 1/.9 ≈ 1.111 and 1/.85 ≈ 1.176, which differ by about .065.
53+
5054
- removed asking if the user wants `xts` to be installed at startup ... _apologies_ for doing what we said we would never do - it's why there is an update so soon
5155

5256
- in the meantime, 🆕 added script `timex()` that, with or without `xts` being loaded, will convert the dates in an `xts` data file to decimal dates so the data can be plotted easily using `tsplot` ... `?timex` for details (of course)

astsa_2.4.tar.gz

540 Bytes
Binary file not shown.

astsa_build/R/arma.spec.R

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
arma.spec <-
2-
function(ar=0, ma=0, var.noise=1, n.freq=500, main=NULL,
2+
function(ar=0, ma=0, var.noise=1, n.freq=500, main=NULL, redundancy.tol=.1,
33
frequency=1, ylim=NULL, plot=TRUE, ...)
44
{
55
check <- 0
@@ -16,10 +16,16 @@ function(ar=0, ma=0, var.noise=1, n.freq=500, main=NULL,
1616
xfreq <- frequency
1717
ar.order <- length(ar)
1818
ma.order <- length(ma)
19-
# check (near) parameter redundancy [i.e. are any roots (approximately) equal]
19+
# check (near) parameter redundancy [i.e. are any roots (approximately) equal]
20+
if (redundancy.tol < 0) {
21+
redundancy.tol=.1
22+
cat("\n'redundancy.tol' cannot be negative and has been reset to its default value\n\n")
23+
}
24+
red.count = 0
2025
for (i in 1:ar.order) {
2126
if ( (ar[1] == 0 && ar.order == 1) || (ma[1] == 0 && ma.order == 1) ) break
22-
if(any(abs(z.ar[i]-z.ma[1:ma.order]) < 1e-01)) {cat("WARNING: Parameter Redundancy", "\n"); break}
27+
if(any(abs(z.ar[i]-z.ma[1:ma.order]) < redundancy.tol))
28+
{cat("WARNING: Parameter Redundancy", "\n"); red.count=1; break}
2329
}
2430

2531
freq <- seq.int(0, 0.5, length.out = n.freq)
@@ -42,10 +48,14 @@ function(ar=0, ma=0, var.noise=1, n.freq=500, main=NULL,
4248
}
4349
Ylab = 'spectrum'
4450
Xlab = ifelse(xfreq>1, paste('frequency \u00D7', xfreq), 'frequency')
45-
m1 = min(spec)
46-
m2 = max(spec)
47-
yspread = (m2 - m1)/var.noise
48-
if (is.null(ylim) & yspread < 1) ylim = c(max(m1-2*var.noise, 0.1*var.noise), m2+2*var.noise)
51+
# m1 = min(spec)
52+
# m2 = max(spec)
53+
# yspread = (m2 - m1)/var.noise
54+
# if (is.null(ylim) & yspread < 1) ylim = c(max(m1-2*var.noise, 0.1*var.noise), m2+2*var.noise)
55+
if (red.count > 0) {
56+
ylim = c(10e-6, 10*max(spec))
57+
main = "White Noise (or close to it)"
58+
}
4959
tsplot(freq*xfreq, spec, xlab=Xlab, ylab=Ylab, main=main, ylim=ylim, ...)
5060
}
5161
return(invisible(spg.out))

astsa_build/man/MEI.Rd

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ temperatures (unlike \code{soi} and \code{ENSO}).
1616
}
1717
\details{For full details, see \kbd{https://psl.noaa.gov/enso/mei.old/mei.html}.
1818
Multivariate ENSO Index (MEI) is a combined score on the six main observed variables over the tropical Pacific. These six variables are: sea-level pressure (P), zonal (U) and meridional (V) components of the surface wind, sea surface temperature (S), surface air temperature (A), and total cloudiness fraction of the sky (C). These observations have been collected and published in ICOADS for many years. The MEI is computed separately for each of twelve sliding bi-monthly seasons (Dec/Jan, Jan/Feb,..., Nov/Dec). After spatially filtering the individual fields into clusters, the MEI is calculated as the first unrotated Principal Component (PC) of all six observed fields combined. This is accomplished by normalizing the total variance of each field first, and then performing the extraction of the first PC on the co-variance matrix of the combined fields. In order to keep the MEI comparable, all seasonal values are standardized with respect to each season and to the 1950-93 reference period.
19+
20+
Weak El Niño: MEI is between +0.5 and +1.0.\cr
21+
Moderate El Niño: MEI is between +1.0 and +1.5.\cr
22+
Strong El Niño: MEI is between +1.5 and +2.0.\cr
23+
Very Strong El Niño: MEI is at or above +2.0.\cr
24+
Values below the negative of these indicate La Niña conditions.
1925
}
2026
\source{
2127
\kbd{https://psl.noaa.gov/enso/mei.old/table.html}
@@ -33,7 +39,8 @@ The webpages for the texts and some help on using R for time series analysis can
3339
\seealso{\code{\link{soi}, \link{ENSO}, \link{MEI2}}
3440
}
3541
\examples{
36-
tsplot(cbind(MEI, MEI2), spag=TRUE, col=astsa.col(2*2:1, .6), addLegend=TRUE, lwd=2)
42+
tsplot(cbind(MEI, MEI2), spag=TRUE, col=2*2:1, addLegend=TRUE, nym=2, gg=TRUE)
43+
3744

3845
tspairs(ts.intersect(MEI, MEI2), location='top')
3946

astsa_build/man/MEI2.Rd

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ For details, see \kbd{https://www.psl.noaa.gov/enso/mei} and \code{\link{MEI}},
1818

1919
The key differences between MEI version 2 and version 1 are the input variables used, the source of the data, and the dates of the historical record. MEI version 2 relies on reanalysis data using modern numerical weather models to process and combine historical weather observations into a comprehensive, globally complete, and consistent dataset of past weather and climate and satellite data. This eliminates inconsistencies caused by relying on potentially less reliable ship observations, especially in earlier decades. The switch from cloud cover fraction to Outgoing Longwave Radiation (OLR) provides a more direct and accurate measurement of atmospheric convection, a critical component of ENSO. Despite the differences, MEI version 2 and the original MEI version 1 are very highly correlated for the overlapping period.
2020

21+
Weak El Niño: MEI is between +0.5 and +1.0.\cr
22+
Moderate El Niño: MEI is between +1.0 and +1.5.\cr
23+
Strong El Niño: MEI is between +1.5 and +2.0.\cr
24+
Very Strong El Niño: MEI is at or above +2.0.\cr
25+
Values below the negative of these indicate La Niña conditions.
2126
}
2227
\source{
2328
\kbd{https://www.psl.noaa.gov/enso/mei}
@@ -35,7 +40,7 @@ The webpages for the texts and some help on using R for time series analysis can
3540
\seealso{\code{\link{soi}, \link{ENSO}, \link{MEI}}
3641
}
3742
\examples{
38-
tsplot(cbind(MEI, MEI2), spag=TRUE, col=astsa.col(2*2:1, .6), addLegend=TRUE, lwd=2)
43+
tsplot(cbind(MEI, MEI2), spag=TRUE, col=2*2:1, addLegend=TRUE, nym=2, gg=TRUE)
3944

4045
tspairs(ts.intersect(MEI, MEI2), location='top')
4146

astsa_build/man/arma.spec.Rd

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
common zeros.
77
}
88
\usage{
9-
arma.spec(ar = 0, ma = 0, var.noise = 1, n.freq = 500, main = NULL,
10-
frequency = 1, ylim = NULL, plot = TRUE, ...)
9+
arma.spec(ar = 0, ma = 0, var.noise = 1, n.freq = 500, main = NULL, redundancy.tol=.1,
10+
frequency = 1, ylim = NULL, plot = TRUE, ...)
1111
}
1212
\arguments{
1313
\item{ar}{vector of AR parameters
@@ -19,6 +19,8 @@ arma.spec(ar = 0, ma = 0, var.noise = 1, n.freq = 500, main = NULL,
1919
\item{n.freq}{number of frequencies
2020
}
2121
\item{main}{title of graphic; default is "ARMA" with orders "(p, q)"
22+
}
23+
\item{redundancy.tol}{tolerance for reporting parameter redundancy
2224
}
2325
\item{frequency}{for seasonal models, adjusts the frequency scale
2426
}
@@ -31,10 +33,17 @@ arma.spec(ar = 0, ma = 0, var.noise = 1, n.freq = 500, main = NULL,
3133
}
3234
\details{The basic call is \code{arma.spec(ar, ma)} where \code{ar} and \code{ma} are vectors
3335
containing the model parameters. Use \code{log='y'} if you want the plot on
34-
a log scale. If the model is not causal or invertible an error message is given. If
35-
there are approximate common zeros, a spectrum will be displayed and a warning will be given;
36+
a log scale. If the model is not causal or invertible an error message is given.
37+
38+
If there are approximate common zeros, a spectrum will be displayed and a warning will be given;
3639
e.g., \code{arma.spec(ar= .9, ma= -.9)} will yield a warning and the plot will be the
3740
spectrum of white noise. Note for example that \code{arma.spec(ar=1, ma=1)} will bring up an error with warnings that the model is not causal and not invertible.
41+
42+
To evaluate parameter redundancy, the roots of the AR and MA polynomials are examined for closeness, with \code{redundancy.tol} determining closeness. For example, using the default (\code{.1}), \code{arma.spec(ar=.9, ma=-.85)} will report over-parameterization, whereas
43+
\code{arma.spec(ar=.9, ma=-.85, red=.05)} will not because the roots are \code{1/.9 = 1.111}
44+
and \code{1/.85 = 1.176}, which are about \code{.065} apart.
45+
46+
3847
}
3948
\value{ \item{freq }{frequencies - returned invisibly}
4049
\item{spec }{ spectral ordinates - returned invisibly }

astsa_build/man/econ5.Rd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Multiple time series with 161 observations (rows) on the following 5 numeric var
1010
}
1111
\source{Young, P.C. and Pedregal, D.J. (1999). Macro-economic relativity: government spending, private investment and unemployment in the USA 1948-1998. \emph{Structural Change and Economic Dynamics}, 10, 359-380.
1212
}
13+
\note{
14+
\code{unemp} is in percentage (of the labor force), and the others are in 1982 Billions USD.
15+
}
1316
\references{You can find demonstrations of astsa capabilities at
1417
\href{https://github.com/nickpoison/astsa/blob/master/fun_with_astsa/fun_with_astsa.md}{FUN WITH ASTSA}.
1518

@@ -21,6 +24,7 @@ The webpages for the texts and some help on using R for time series analysis can
2124
\url{https://nickpoison.github.io/}.
2225
}
2326
\examples{
24-
tsplot(diff(log(econ5)), ncolm=2, col=2:6, lwd=2)
27+
tsplot(econ5, ncolm=2, col=2:6, lwd=2, title=colnames(econ5),
28+
ylab=c('\%', rep('Billions-USD', 4)))
2529
}
2630
\keyword{datasets}

astsa_build/man/eqexp.Rd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ long = c(
6969
55.2)
7070

7171
event = c(
72-
"EQ","EQ","EQ","EQ","EQ","EQ","EQ","EQ",
73-
"EX","EX","EX","EX","EX","EX","EX","EX",
72+
"EQ1","EQ2","EQ3","EQ4","EQ5","EQ6","EQ7","EQ8",
73+
"EX1","EX2","EX3","EX4","EX5","EX6","EX7","EX8",
7474
"NZ")
7575

7676

0 commit comments

Comments
 (0)