inst/doc/qpmR-quickstart.R

## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>",
                      fig.width = 7, fig.height = 5)

## -----------------------------------------------------------------------------
library(qpmR)
m <- qpm_template("bkl")
m

## -----------------------------------------------------------------------------
sol <- qpm_solve(m)
sol

## ----error = TRUE-------------------------------------------------------------
try({
qpm_solve(qpm_calibrate(m, c2 = -0.5))
})

## -----------------------------------------------------------------------------
ir <- irf(sol, shock = "eps_i", horizon = 16)
ir
plot(ir, vars = c("i", "r", "pi", "y_gap", "q", "pi4"))

## -----------------------------------------------------------------------------
histq <- simulate(sol, nsim = 48, seed = 7, burn = 20)
fc <- qpm_forecast(sol, from = histq, horizon = 12)
fc
plot(fc, vars = c("pi", "i", "y_gap", "q"))

## -----------------------------------------------------------------------------
qpm_lint(m)

## -----------------------------------------------------------------------------
m_food <- add_block(qpm_template("bkl"), block_food_cpi(weight = 0.45))
plot(irf(qpm_solve(m_food), shock = "eps_pifood", horizon = 16),
     vars = c("pi_food", "pi", "pi_core", "i"))

## -----------------------------------------------------------------------------
peak_q <- function(m) {
  ir <- irf(qpm_solve(m), shock = "eps_prem", horizon = 12, size = 1)
  max(abs(ir$value[ir$variable == "q"]))
}
c(float   = peak_q(qpm_template("bkl")),
  managed = peak_q(add_block(qpm_template("bkl"), block_fx_intervention(1))),
  peg     = peak_q(add_block(qpm_template("bkl"), block_fx_intervention(4))))

## -----------------------------------------------------------------------------
qpm_diff(qpm_template("bkl"), m_food)

## -----------------------------------------------------------------------------
mcz <- qpm_calibrate(qpm_template("bkl", trends = "rw"),
                     pi_tar = 2, istar_ss = 2, pistar_ss = 2,
                     prem_ss = 1, a5 = 0.4)
cz <- czechia[czechia$period >= "1999",
              c("period", "pi4", "i", "q", "dy_obs", "istar", "pistar")]
fit <- qpm_filter(mcz, cz)
fit

## -----------------------------------------------------------------------------
plot(fit, vars = c("y_gap", "dy_bar", "r_bar", "q_gap"))

## -----------------------------------------------------------------------------
dec <- qpm_decompose(fit)
plot(dec, var = "pi4", periods = (fit$n_obs - 33):fit$n_obs)

## -----------------------------------------------------------------------------
fc <- qpm_forecast(qpm_solve(mcz), from = fit, horizon = 12)
plot(fc, vars = c("pi4", "i", "y_gap", "q"))

## -----------------------------------------------------------------------------
base <- qpm_forecast(qpm_solve(mcz), from = fit, horizon = 12)
hold <- qpm_condition(base,
                      i = stats::setNames(rep(3.5, 4), base$periods[1:4]),
                      anticipated = TRUE, instruments = "eps_i")
hold

## -----------------------------------------------------------------------------
judged <- add_judgment(base, pi4 = stats::setNames(0.4, base$periods[3]),
                       author = "prices desk",
                       rationale = "announced energy-tariff increase")
judgment_log(judged)

## -----------------------------------------------------------------------------
czA <- cz[cz$period <= "2025-Q4", ]
rA <- qpm_round("2026-Q1 March", mcz, czA, horizon = 12)
rB <- qpm_round("2026-Q3 September", mcz, cz, horizon = 12)
rB <- add_judgment(rB, pi4 = c("2027-Q1" = 0.4), author = "prices desk",
                   rationale = "announced energy-tariff increase")
rev <- compare_rounds(rA, rB, variables = c("pi4", "i", "y_gap"))
print(rev, variables = "pi4", periods = "2027-Q1")
plot(rev, variable = "pi4")

## -----------------------------------------------------------------------------
verify_round(rB)

## ----eval = FALSE-------------------------------------------------------------
# chart_pack(rB, "chart_pack.pdf")
# qpm_report(rB, "mpr.html", compare_to = rA)

Try the qpmR package in your browser

Any scripts or data that you put into this service are public.

qpmR documentation built on Sept. 29, 2026, 5:10 p.m.