Skip to contents

Plot filtered or smoothed estimates for a selected state from a fitted revision model. Defined once for the parent class revision_model and inherited by kk_model and jvn_model objects alike; the state shown when state is not given is chosen by the concrete class.

Usage

# S3 method for class 'revision_model'
plot(x, state = NULL, type = "filtered", ...)

Arguments

x

A fitted model object inheriting from revision_model, such as a kk_model or a jvn_model.

state

String. The name of the state to visualize. If NULL, the family's default state is used: the latent true value for a jvn_model, and the first available state for a kk_model.

type

String. Type of estimate: "filtered" or "smoothed".

...

Additional arguments passed to theme_reviser.

Value

A ggplot2 object.

Details

This method requires the state estimates to be available. A model fitted with solver_options$return_states = FALSE did not retain them, and plotting it fails with a message naming that option, in the same way states(), fitted(), residuals() and predict() do.

Examples

df <- get_nth_release(
  tsbox::ts_span(
    tsbox::ts_pc(
      dplyr::filter(reviser::gdp, id == "US")
    ),
    start = "1980-01-01"
  ),
  n = 0:1
)
df <- dplyr::select(df, -c("id", "pub_date"))
df <- na.omit(df)

e <- 1 # Number of efficient release
h <- 2 # Forecast horizon
result <- kk_nowcast(df, e, h = h, model = "Kishor-Koenig")

plot(result)