Skip to content

Commit

Permalink
version 0.9.8
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-the-bayesian authored and cran-robot committed May 30, 2022
1 parent a04aa3a commit fd178e7
Show file tree
Hide file tree
Showing 64 changed files with 2,865 additions and 738 deletions.
14 changes: 7 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
Package: bsts
Version: 0.9.7
Date: 2021-06-21
Version: 0.9.8
Date: 2022-05-27
Title: Bayesian Structural Time Series
Author: Steven L. Scott <[email protected]>
Maintainer: Steven L. Scott <[email protected]>
Description: Time series regression using dynamic linear models fit using
MCMC. See Scott and Varian (2014) <DOI:10.1504/IJMMNO.2014.059942>, among many
other sources.
Depends: BoomSpikeSlab (>= 1.2.4), zoo (>= 1.8), xts, Boom (>= 0.9.7),
Depends: BoomSpikeSlab (>= 1.2.5), zoo (>= 1.8), xts, Boom (>= 0.9.10),
R(>= 3.4.0)
Suggests: testthat
LinkingTo: Boom (>= 0.9.7)
License: LGPL-2.1 | file LICENSE
LinkingTo: Boom (>= 0.9.10)
License: LGPL-2.1 | MIT + file LICENSE
Encoding: UTF-8
NeedsCompilation: yes
Packaged: 2021-06-21 15:12:04 UTC; steve
Packaged: 2022-05-29 22:58:07 UTC; steve
Repository: CRAN
Date/Publication: 2021-07-02 04:30:07 UTC
Date/Publication: 2022-05-30 07:00:12 UTC
506 changes: 2 additions & 504 deletions LICENSE

Large diffs are not rendered by default.

88 changes: 63 additions & 25 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
04a6318b347189653b1153fbbaab9bba *DESCRIPTION
7eb09e6fd83eb49ed22911c3b2f06744 *LICENSE
e43a0befcaecfac83ffe6d9ab28fc76a *NAMESPACE
77060bb31e06c8bce2996840a62ec823 *DESCRIPTION
ccd3022578bbd36b69595f56cd8d83e5 *LICENSE
1570eae7bf1ed9a241feeacb9404345b *NAMESPACE
ceb07fe9db975f5c42496dfaa33a5d14 *R/add.ar.R
f4f62d5be00d37a5ef3af326bc790b15 *R/add.dynamic.regression.R
a2207f7a3e1753f1f3add83cc6b9dd7f *R/add.generalized.local.linear.trend.R
14576ffbd475455ed2de73f12a331a67 *R/add.local.level.R
455e93d3831f44a1eb1e0f6a648da27a *R/add.local.level.R
f9d3fe80f95e42e2cc4c2444c22bfbfd *R/add.local.linear.trend.R
f0c5dc316a9e9472ea4073a526f93ac0 *R/add.monthly.annual.cycle.R
c55b4c89ff05f1a9c4e9fd18b7fdcc54 *R/add.random.walk.holiday.R
21e49e3ebe10ffac95c24260320a921d *R/add.regression.holiday.R
73166e6d26a0faba0f61fe9f477a35aa *R/add.regression.holiday.R
19adabb8f2d359cbab78194c4c598a6e *R/add.seasonal.R
d4f5df46c6a15e0d4e47ede074775446 *R/add.semilocal.linear.trend.R
f965dd362d2321286bea83acd0b40c2d *R/add.static.intercept.R
Expand All @@ -17,18 +17,18 @@ c69a20b8a59408f1c7e47c51c180b36b *R/add.student.local.linear.trend.R
a98db043d454fecd68c910546bdecf64 *R/bsts.R
642f82708acd5ce362948999df6aaf2d *R/compare.bsts.models.R
994c84adfa23228d724050d98c6a560e *R/date.functions.R
6fe231fe1d4debe9e9edeb92eb269869 *R/diagnostics.R
7512979ef565815e645dfc2dbab35bd8 *R/diagnostics.R
c73dd1a226eb5c0d9010c99f53b47dea *R/dirm.R
f9fd8b0d488304fedbf69e65cfa9917b *R/format.learning.data.R
cd4f60ef6f034426065ac031ee9bd537 *R/format.timestamps.R
769da1aee699d16ed0209b0f050c111e *R/holiday.R
958b7e37110dd2b656fa7d8eef0c023d *R/mbsts.R
14b5d35d71c65d0c33ffa731332c9201 *R/mbsts.plots.R
7e69ee574371cee18b230095b0c14890 *R/mbsts.R
eec0ca1439df1847694a4205a9fc9a5c *R/mbsts.plots.R
53d1cd68e9ec96ad82ec6ed3d108df5d *R/mixed.frequency.R
63bc374c03e9d515b6aca12da8729631 *R/plot_seasonal_effect.R
9855bc34d9b463799387b55ac2184112 *R/plots.R
408c9fa167d8a809727fb221448cc028 *R/predict.bsts.R
55b01ea970a54ee73360d9bcd3c1930a *R/predict.mbsts.R
e1be491d9c0fbfb9d837ea5d5e619f07 *R/predict.bsts.R
f3655b4b3b11fd7977dc3e05a3cade6c *R/predict.mbsts.R
09187c9baabe7cdb4a0301f38b5648f1 *R/summary.bsts.R
04dc0efa0ef403afd48e252eba7e7271 *R/utils.R
e707d635a33700be517ad31745786dc7 *data/gdp.RData
Expand All @@ -38,6 +38,23 @@ e96e68697531b9dbeffbded63b4ee8a2 *data/iclaims.RData
371264a117afb763845fd25ac0492c60 *data/rsxfs.RData
38a19670e134d95d2cc0ed134abe3539 *data/shark.RData
761daf2618eaf1014ccc6500f3c82e61 *data/turkish.RData
0465bac211a2e128119a6fbd17f19c56 *inst/tests/tests/testthat.R
2c297be76520a1e86a59e50ffce13d00 *inst/tests/tests/testthat/test-ar.R
630452660972de113c484c1dd4d52269 *inst/tests/tests/testthat/test-autoar.R
172df9e68c0f7876dcaade3768c2d5f9 *inst/tests/tests/testthat/test-date-range.R
0126f04464776f5b1b05c32d25d25f55 *inst/tests/tests/testthat/test-dirm.R
3de38eb5bcb72ddf38c3b818d9518c0d *inst/tests/tests/testthat/test-dynamic-regression.R
236c11dceb0ea37b1966a706f7ac3a62 *inst/tests/tests/testthat/test-goog.R
8e8e34dbc5a1d1735ec663091bcd03a9 *inst/tests/tests/testthat/test-holidays.R
5c8960cc0a588cb58e49ab39b39cf683 *inst/tests/tests/testthat/test-multivariate.R
b8cf1c7b59eede2825f50fea5feac4c1 *inst/tests/tests/testthat/test-plot-components.R
abadc45049de045297dc88b776546d08 *inst/tests/tests/testthat/test-poisson.R
5c420ef79df05489ab47c1ee48ee0323 *inst/tests/tests/testthat/test-prediction-errors.R
e91ff5f823c6acbff0b7b7d6810a82a8 *inst/tests/tests/testthat/test-prediction.R
74913baa6a0f8135591ba1c6d7b7e46e *inst/tests/tests/testthat/test-regressionholiday.R
ebe710afd159f82025b7c8b9d6e6d237 *inst/tests/tests/testthat/test-seasonal.R
6c0c26d250eb86a7f004138b65297c90 *inst/tests/tests/testthat/test-student.R
9f6f10bf2045923b08f20734cef76b22 *inst/tests/tests/testthat/test-trig.R
0465bac211a2e128119a6fbd17f19c56 *inst/tests/testthat.R
2c297be76520a1e86a59e50ffce13d00 *inst/tests/testthat/test-ar.R
630452660972de113c484c1dd4d52269 *inst/tests/testthat/test-autoar.R
Expand All @@ -46,7 +63,7 @@ e96e68697531b9dbeffbded63b4ee8a2 *data/iclaims.RData
3de38eb5bcb72ddf38c3b818d9518c0d *inst/tests/testthat/test-dynamic-regression.R
236c11dceb0ea37b1966a706f7ac3a62 *inst/tests/testthat/test-goog.R
8e8e34dbc5a1d1735ec663091bcd03a9 *inst/tests/testthat/test-holidays.R
848315909ef88fa686dde81314d830c3 *inst/tests/testthat/test-multivariate.R
5c8960cc0a588cb58e49ab39b39cf683 *inst/tests/testthat/test-multivariate.R
b8cf1c7b59eede2825f50fea5feac4c1 *inst/tests/testthat/test-plot-components.R
abadc45049de045297dc88b776546d08 *inst/tests/testthat/test-poisson.R
5c420ef79df05489ab47c1ee48ee0323 *inst/tests/testthat/test-prediction-errors.R
Expand All @@ -67,7 +84,7 @@ c6aeacc25ac38af7be02246a9994d21f *man/add.monthly.annual.cycle.Rd
3168e8a6a9d823b0ef79dd27f7caf8ef *man/add.random.walk.holiday.Rd
3860412aa5279acee97dc3bbf9e73502 *man/add.seasonal.Rd
ec2b5eb7a98faf7b6651e4de4bbaa9ca *man/add.semilocal.linear.trend.Rd
ff357b94cc6095840d6fe1da30e1359f *man/add.shared.local.level.Rd
87c92d50dd2354ba63cbcaf82f6fff9b *man/add.shared.local.level.Rd
253bb74766c2d284a73fb56ec7b33fa9 *man/add.static.intercept.Rd
b02be1b8b61962090baccf3f454fa372 *man/add.student.local.linear.trend.Rd
dd0f4a731a23a55e13853e991fd64d2c *man/add.trig.Rd
Expand All @@ -94,6 +111,7 @@ e7b9351ff2f8b0c117c1b2377303603d *man/geometric.sequence.Rd
cf7b7d18e7252f5eccd0341eb26a6d82 *man/last.day.in.month.Rd
d001026a7f503a1d7e4c3139b193bfe5 *man/match.week.to.month.Rd
5c321a7f4189941f9d151f71627da8d2 *man/max.window.width.Rd
576c4c6a098bada394edefb47521ed30 *man/mbsts.Rd
43b82cce35af62b441d08cda809329a1 *man/mixed.frequency.Rd
4c9639c7bfb85396081677060adc4541 *man/month.distance.Rd
129cf408079a8ce4c6fea7e5e1c54515 *man/named.holidays.Rd
Expand All @@ -104,7 +122,10 @@ d001026a7f503a1d7e4c3139b193bfe5 *man/match.week.to.month.Rd
6cab6053d05412eda8ea76b96595e315 *man/plot.bsts.prediction.Rd
9f639c8f4318529cf31ccc7b62ef84de *man/plot.bsts.predictors.Rd
e00a3f3667c8ac2aec7154523fba3211 *man/plot.holiday.Rd
1dc97ef1111f0cc768eac3d92ccca506 *man/predict.bsts.Rd
a54a818a128f6c40fe332821d93b8d2b *man/plot.mbsts.Rd
53762a8e87f5fffcb00bf3fa0b966926 *man/plot.mbsts.prediction.Rd
8b77f922bc4a9fc2f8d79a8a7de0ab34 *man/predict.bsts.Rd
b312861f047c0bb60e6cc045baf7bbc9 *man/predict.mbsts.Rd
e619692503d8decbd92a7c39b9d68327 *man/quarter.Rd
abbc96c6de587b36dc1af2113a5845ce *man/regression.holiday.Rd
c5b649ab31e29840874340433e251ccf *man/regularize.timestamps.Rd
Expand All @@ -127,31 +148,48 @@ d99ce4ef93988dc2e1b7279ab92be31e *src/aggregate_time_series.cc
8c5caf631398cd06050d059691d443e3 *src/bsts_init.cc
604673026495a954489f5e86602bc48f *src/create_dynamic_intercept_state_model.cpp
2d60cd8ba33ef34e0238517e07bf7c9c *src/create_dynamic_intercept_state_model.h
3c36c0dc370bec5d41d595f71403f718 *src/create_shared_state_model.cpp
e348872535b6a2fda297739ea91d7b6c *src/create_shared_state_model.h
09f4b4e16bba358e1b4c462ae2b5e7a6 *src/create_state_model.cpp
74533455e40f6d52661548ec47182a25 *src/create_shared_state_model.cpp
06586064da9cccf1136dd127958adefe *src/create_shared_state_model.h
776cfc2e6f5b39a8354601ceaf73905b *src/create_state_model.cpp
f8f89c660dc8cf6920e8694d25b99671 *src/create_state_model.h
4a0ab82799effea8a0f2998cfb9302f7 *src/dirm.cc
3b6fc2c846615a9e79fdd8f49539da26 *src/dynamic_intercept_model_manager.cc
f698985e6d5832df83a7ec75e44fcbce *src/dynamic_intercept_model_manager.cc
f4b47e0c03ea817b60f652813b16fb06 *src/dynamic_intercept_model_manager.h
e6f88ebc8a3c65c29fd14268e57fe4d9 *src/get_date_ranges.cc
b95582788ae274e41af2e10f568209aa *src/mbsts.cc
cf13c9e432dda0d3468449ec04dc4804 *src/mbsts.cc
4bc3088809b3d5525ee65288bf8aa959 *src/mixed_frequency.cc
5719cbcd19da21c199d82c1f163b2abd *src/model_manager.cc
8992bcf3e4c473fc26d7d5fb1a744b55 *src/model_manager.h
7ce877770f10b81a6a6cf2f0d47a055d *src/multivariate_gaussian_model_manager.cc
93eae1ab5fe99f38d0c643687ce02683 *src/multivariate_gaussian_model_manager.h
82d4ded6a46e394a9e9bfabeb59d9621 *src/state_space_gaussian_model_manager.cc
bc75e43ff4ec384d60484d3adee324ba *src/model_manager.cc
17d5861e914a1658a6ec202fce330e6a *src/model_manager.h
c25fa6519d37e732f1ffc9016596a23d *src/multivariate_gaussian_model_manager.cc
d1cd0b01191824fd3e84d41bcedd276a *src/multivariate_gaussian_model_manager.h
74e7f2c3bc45e9f519ed32dcfcc4f134 *src/state_space_gaussian_model_manager.cc
2bedea75559c6e5f0a0bd7d3af6090e8 *src/state_space_gaussian_model_manager.h
a432aebec2404eb926fe13e9bcb5fb25 *src/state_space_logit_model_manager.cc
3f80d659d96c0f9d08cab47a32a2a9b7 *src/state_space_logit_model_manager.h
7c476ba4d8a46e5de51c0aa2738d477d *src/state_space_poisson_model_manager.cc
e216be891919e3263441168f35507631 *src/state_space_poisson_model_manager.h
d12a59708f82f866ed02944f5431bb59 *src/state_space_regression_model_manager.cc
7ac07cf5d57c124a845c31baeb64f782 *src/state_space_regression_model_manager.h
c3e2c5e82908e0b2f98b248f5db8cfae *src/state_space_student_model_manager.cc
0af65cdc6fe068f8fc2df588f4898f05 *src/state_space_student_model_manager.cc
70d7c3d65ab85979568d692b4a217f9f *src/state_space_student_model_manager.h
b8f60bed801663863a327aa8bd4d367e *src/timestamp_info.cc
1c682544f82b2cf9331c827ec6c3f0cf *src/timestamp_info.h
758355f181bebfed943c020342250e5e *src/utils.cc
9b299499f0d977e24d5e96e61872bf62 *src/utils.h
02c97999019ae7fc533919fff4029385 *src/utils.h
0465bac211a2e128119a6fbd17f19c56 *tests/testthat.R
2c297be76520a1e86a59e50ffce13d00 *tests/testthat/test-ar.R
630452660972de113c484c1dd4d52269 *tests/testthat/test-autoar.R
172df9e68c0f7876dcaade3768c2d5f9 *tests/testthat/test-date-range.R
0126f04464776f5b1b05c32d25d25f55 *tests/testthat/test-dirm.R
3de38eb5bcb72ddf38c3b818d9518c0d *tests/testthat/test-dynamic-regression.R
236c11dceb0ea37b1966a706f7ac3a62 *tests/testthat/test-goog.R
8e8e34dbc5a1d1735ec663091bcd03a9 *tests/testthat/test-holidays.R
5c8960cc0a588cb58e49ab39b39cf683 *tests/testthat/test-multivariate.R
b8cf1c7b59eede2825f50fea5feac4c1 *tests/testthat/test-plot-components.R
abadc45049de045297dc88b776546d08 *tests/testthat/test-poisson.R
5c420ef79df05489ab47c1ee48ee0323 *tests/testthat/test-prediction-errors.R
e91ff5f823c6acbff0b7b7d6810a82a8 *tests/testthat/test-prediction.R
74913baa6a0f8135591ba1c6d7b7e46e *tests/testthat/test-regressionholiday.R
ebe710afd159f82025b7c8b9d6e6d237 *tests/testthat/test-seasonal.R
6c0c26d250eb86a7f004138b65297c90 *tests/testthat/test-student.R
9f6f10bf2045923b08f20734cef76b22 *tests/testthat/test-trig.R
13 changes: 9 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export(AcfDist,
MaxWindowWidth,
MaxWindowWidth.default,
MaxWindowWidth.DateRangeHoliday,
# mbsts,
mbsts,
MonthDistance,
MonthPlot,
NamedHoliday,
Expand All @@ -88,6 +88,10 @@ export(AcfDist,
PlotBstsState,
PlotDynamicRegression,
PlotHoliday,
plot.mbsts,
plot.mbsts.prediction,
predict.mbsts,
PlotMbstsSeriesMeans,
PlotSeasonalEffect,
predict.bsts,
Quarter,
Expand Down Expand Up @@ -117,11 +121,12 @@ S3method(predict, bsts)
S3method(residuals, bsts)

S3method(plot, bsts.prediction)

S3method(plot, bsts.mixed)

# S3method(plot, mbsts)
# S3method(predict, mbsts)
# S3method(plot, mbsts.prediction)
S3method(plot, mbsts)
S3method(predict, mbsts)
S3method(plot, mbsts.prediction)

# Plot methods for specific state components
S3method(plot, StateModel)
Expand Down
28 changes: 14 additions & 14 deletions R/add.local.level.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

AddSharedLocalLevel <- function(state.specification,
response,
nfactors,
nfactors,
coefficient.prior = NULL,
initial.state.prior = NULL,
timestamps = NULL,
Expand All @@ -31,8 +31,8 @@ AddSharedLocalLevel <- function(state.specification,
##
## For identification purposes, the variance of eta[t] is the identity matrix,
## and the coefficient matrix Z It is zero above the diagonal. This means
## that the first time series is only affected by the first factor. The
## second is affected by the first and second factors, etc.
## that the first factor affects all time series, the second affects all but
## the first series, the third affects all but the first two, etc.
##
## Args:
## state.specification: A list of state components to which a shared local
Expand All @@ -44,12 +44,11 @@ AddSharedLocalLevel <- function(state.specification,
## coefficient.prior: An object (or a list of objects) inheriting from
## SpikeSlabPriorBase. If a list is passed it must have 'nseries'
## elements, where 'nseries' is the number of time series being modeled.
## If a single object is passed it will be copied into a list of 'nseries'
## identical prior objects. List element i specifies the prior
## distribution on the set of observation coefficients for time series i.
## Note that identifiability constriants will be imposed by underlying
## code, so that if series k < 'nfactors', only the first 'k' factors will
## have positive prior probability for series k.
## List element i specifies the prior distribution on the set of
## observation coefficients for time series i (i.e. the i'th column of the
## observation coefficients. If a single list element is passed it will
## be copied 'nseries' times, and the spike component will be modified to
## impose the lower triangular constrint.
## initial.state.prior: An object created by MvnPrior giving the prior
## distribution on the values of the initial state (i.e. the state as of
## the first observation).
Expand All @@ -70,7 +69,7 @@ AddSharedLocalLevel <- function(state.specification,
if (missing(state.specification)) state.specification <- list()
stopifnot(is.list(state.specification))
stopifnot(is.numeric(nfactors), length(nfactors) == 1, nfactors >= 1)

if (!missing(response)) {
stopifnot(is.numeric(response))
if (is.matrix(response)) {
Expand All @@ -90,12 +89,13 @@ AddSharedLocalLevel <- function(state.specification,

nfactors <- as.integer(nfactors)
stopifnot(length(nfactors) == 1)

##----------------------------------------------------------------------
# Set the prior on the observation coefficients.
## Set the prior on the observation coefficients.
##----------------------------------------------------------------------
# The coefficients Z satisfy Y[t] = Z * alpha, so the coefficients have
# 'nseries' rows and 'nfactors' columns.
# 'nseries' rows and 'nfactors' columns. Each list element describes the
# coefficients for a column.
if (is.null(coefficient.prior)) {
coefficient.prior <- list()
for (i in 1:nseries) {
Expand All @@ -114,7 +114,7 @@ AddSharedLocalLevel <- function(state.specification,
}
stopifnot(is.list(coefficient.prior),
all(sapply(coefficient.prior, inherits, "ConditionalZellnerPrior")))

##----------------------------------------------------------------------
## Set the prior on the initial state.
##----------------------------------------------------------------------
Expand Down
13 changes: 6 additions & 7 deletions R/add.regression.holiday.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ AddRegressionHoliday <- function(state.specification = NULL,
variable.names <- colnames(coefficients)
old.mai <- par("mai")
old.mai[1] <- max(strheight(variable.names, units = "inches"))
old.mai[2] <- max(strwidth(variable.names, units = "inches")) +
old.mai[2] <- max(strwidth(variable.names, units = "inches")) +
strwidth(" -- ", units = "inches")
oldpar <- par(mai = old.mai)
on.exit(par(oldpar))
Expand All @@ -99,7 +99,7 @@ AddRegressionHoliday <- function(state.specification = NULL,
new.holiday.index <- (1:ncol(coefficients))[colnames(coefficients) != ""][-1]
coefficients <- coefficients[, ncol(coefficients):1]
new.holiday.index <- 1 + ncol(coefficients) - new.holiday.index

boxplot(coefficients, horizontal = TRUE, ylim = ylim, las = 1, cex = .6, ...)
abline(v = 0, lty = 3)
abline(h = new.holiday.index + .5, lty = 3)
Expand Down Expand Up @@ -190,7 +190,7 @@ plot.HierarchicalRegressionHolidayStateModel <- function(x,
if (is.null(.FindStateSpecification(state.specification, bsts.object))) {
stop("The state specification is not part of the bsts object.")
}

coefficient.array <- bsts.object$holiday.coefficients
if (is.null(burn)) {
burn <- 0
Expand All @@ -205,13 +205,13 @@ plot.HierarchicalRegressionHolidayStateModel <- function(x,
colnames(coefficients) <- rep("", ncol(coefficients))
colnames(coefficients)[seq(from = 1, by = holiday.window.size,
len = number.of.holidays)] <- dimnames(coefficient.array)[[2]]

start <- 0
for (i in 1:number.of.holidays) {
coefficients[, start + (1:holiday.window.size)] <- coefficient.array[, i, ]
start <- start + holiday.window.size
}

.PlotHolidayRegressionCoefficients(coefficients, ylim, ...)
title("Hierarchical Regression\nHoliday Effects")
return(invisible(NULL))
Expand Down Expand Up @@ -257,7 +257,7 @@ AddHierarchicalRegressionHoliday <- function(
if (length(holiday.list) < 3) {
stop("You need 3 or more holidays to fit the hierarchical model in ",
"AddHierarchicalRegressionHolidayModel.")
}
}
if (missing(state.specification)) {
state.specification <- list()
}
Expand Down Expand Up @@ -299,4 +299,3 @@ AddHierarchicalRegressionHoliday <- function(
state.specification[[length(state.specification) + 1]] <- spec
return(state.specification)
}

2 changes: 1 addition & 1 deletion R/diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ bsts.prediction.errors <- function(bsts.object,
cutpoints <- max(bsts.object$timestamp.info$timestamp.mapping)
}
}

if (!is.null(cutpoints) && length(cutpoints) > 0) {
stopifnot(length(cutpoints) <= bsts.object$number.of.time.points,
all(cutpoints > 0),
Expand Down
Loading

0 comments on commit fd178e7

Please sign in to comment.