Skip to contents

Plot the estimated OSEM Model

Usage

# S3 method for class 'osem'
plot(
  x,
  title = "OSEM Model Output",
  exclude.exogenous = TRUE,
  order.as.run = FALSE,
  interactive = FALSE,
  first_date = NULL,
  grepl_variables = NULL,
  linewidth = 1,
  return.data = FALSE,
  ...
)

Arguments

x

An object of class osem, which is the output from the run_model function.

title

Character. Title of the plot. Default is "OSEM Model Output".

exclude.exogenous

Logical. Should exogenous values be plotted? Default is FALSE.

order.as.run

Logical. Should the plots be arranged in the way that the model was run? Default FALSE.

interactive

Logical. Should the resulting plot be launched in an interactive way (the plotly package is required for this).

first_date

Character. First date value to be shown. Must be a character value that can be turned into a date using as.Date() or NULL.

grepl_variables

Regular Expression Character. Can be used to select variables to be plotted. Experimental feature so use with care.

linewidth

Numeric. Linewidth argument for the plot. Default is 1.

return.data

Logical. Do not return a plot but rather just the final dataset that has been created for the plot.

...

Additional arguments passed to the plotting function.

Value

A ggplot object or a tibble/data.frame with the data used for plotting, depending on the value of return.data.

Examples

spec <- dplyr::tibble(
type = c(
  "d",
  "d",
  "n"
),
dependent = c(
  "StatDiscrep",
  "TOTS",
  "Import"
),
independent = c(
  "TOTS - FinConsExpHH - FinConsExpGov - GCapitalForm - Export",
  "GValueAdd + Import",
  "FinConsExpHH + GCapitalForm"
)
)
# \donttest{
a <- run_model(specification = spec, dictionary = NULL,
inputdata_directory = NULL, primary_source = "download",
save_to_disk = NULL, present = FALSE)
#> Dataset query already saved in cache_list.json...
#> Reading cache file /tmp/RtmpzOCInM/eurostat/b1a6002baab7fb27796d86df4c53dad9.rds
#> Table  namq_10_a10  read from cache file:  /tmp/RtmpzOCInM/eurostat/b1a6002baab7fb27796d86df4c53dad9.rds
#> Dataset query already saved in cache_list.json...
#> Reading cache file /tmp/RtmpzOCInM/eurostat/c6c39fa9ea0f07bf8f64918ffb8ff05f.rds
#> Table  namq_10_gdp  read from cache file:  /tmp/RtmpzOCInM/eurostat/c6c39fa9ea0f07bf8f64918ffb8ff05f.rds
#> 
#> --- Estimation begins ---
#> Estimating Import = FinConsExpHH + GCapitalForm 
#> Constructing TOTS = GValueAdd + Import 
#> Constructing StatDiscrep = TOTS - FinConsExpHH - FinConsExpGov - GCapitalForm - Export 

plot(a)

# }