Commit fdf2936
committed
Introduce construct.model parameter
construct.model is a function that takes modeling data (NA in
post.period) and returns a bsts model.
This invocation:
go <- function(data) {
y <- data[, 1]
sdy <- sd(y, na.rm = TRUE)
sd.prior <- SdPrior(sigma.guess = 0.01 * sdy,
upper.limit = sdy,
sample.size = 32)
ss <- AddLocalLevel(list(), y, sigma.prior = sd.prior)
bsts.model <- bsts(y, state.specification = ss, niter = 100,
seed = 1, ping = 0)
}
impact <- CausalImpact(data, pre.period, post.period,
construct.model = go)
is equivalent to:
model.args <- list(niter = 100)
impact <- CausalImpact(data, pre.period, post.period, model.args)
. This change provides an interface that has RunWithData's flexibility
with pre- and post-period, and RunWithBstsModel's full configurability
of the model. For example, the caller can now specify a custom model
where the post-period is before the end of the data, which isn't
possible with the previous interface.1 parent 7e0f59f commit fdf2936
2 files changed
Lines changed: 49 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
| 138 | + | |
| 139 | + | |
139 | 140 | | |
140 | 141 | | |
141 | 142 | | |
| |||
147 | 148 | | |
148 | 149 | | |
149 | 150 | | |
| 151 | + | |
150 | 152 | | |
151 | 153 | | |
152 | 154 | | |
| |||
213 | 215 | | |
214 | 216 | | |
215 | 217 | | |
216 | | - | |
| 218 | + | |
| 219 | + | |
217 | 220 | | |
218 | 221 | | |
219 | 222 | | |
| |||
278 | 281 | | |
279 | 282 | | |
280 | 283 | | |
| 284 | + | |
| 285 | + | |
281 | 286 | | |
282 | 287 | | |
283 | 288 | | |
| |||
341 | 346 | | |
342 | 347 | | |
343 | 348 | | |
344 | | - | |
| 349 | + | |
| 350 | + | |
345 | 351 | | |
346 | 352 | | |
347 | 353 | | |
| |||
352 | 358 | | |
353 | 359 | | |
354 | 360 | | |
355 | | - | |
| 361 | + | |
356 | 362 | | |
357 | 363 | | |
358 | 364 | | |
| |||
364 | 370 | | |
365 | 371 | | |
366 | 372 | | |
367 | | - | |
| 373 | + | |
368 | 374 | | |
369 | 375 | | |
370 | 376 | | |
| |||
375 | 381 | | |
376 | 382 | | |
377 | 383 | | |
| 384 | + | |
378 | 385 | | |
379 | 386 | | |
380 | 387 | | |
| |||
409 | 416 | | |
410 | 417 | | |
411 | 418 | | |
412 | | - | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
413 | 429 | | |
414 | 430 | | |
415 | 431 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
593 | 593 | | |
594 | 594 | | |
595 | 595 | | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
596 | 623 | | |
597 | 624 | | |
598 | 625 | | |
| |||
0 commit comments