plot.network_interpolation: Plot method for network interpolation output

View source: R/network.interpolation.R

plot.network_interpolationR Documentation

Plot method for network interpolation output

Description

S3 plot method for objects returned by network.interpolation.

Depending on type, the method can display:

  • interpolated series through time,

  • uncertainty width,

  • reference-network availability,

  • summary diagnostics,

  • synthetic-gap validation metrics,

  • interval coverage,

  • actual versus interpolated validation points,

  • seasonal validation diagnostics.

Jump-corrected post-gap points are marked in the interpolation plot when jump correction was enabled in network.interpolation.

Usage

## S3 method for class 'network_interpolation'
plot(
  x,
  type = c("interpolation", "uncertainty", "availability", "summary", "validation",
    "coverage", "compare", "seasonal_error"),
  series = NULL,
  start = NULL,
  end = NULL,
  show_pi = TRUE,
  show_fit = FALSE,
  free_y = TRUE,
  ncol = 1,
  summary_metric = c("n_imputed", "n_remaining_na", "n_missing_input", "mean_pi_width",
    "median_pi_width", "mean_ref_n", "median_ref_n", "n_gap_jumps_removed",
    "max_abs_gap_jump"),
  validation_metric = c("MAE", "MAPE", "MdAPE", "RMSE", "Bias", "Success_rate",
    "Mean_PI_width", "Mean_ref_n", "End_value_abs_diff", "Max_abs_diff_within_gap"),
  seasonal_metric = c("mean_error", "mean_abs_error", "mean_abs_pct_error", "rmse",
    "coverage"),
  compare_colour = c("series", "gap_steps"),
  facet = TRUE,
  empty = c("plot", "error"),
  ...
)

Arguments

x

Object returned by network.interpolation.

type

Character. Plot type. One of "interpolation", "uncertainty", "availability", "summary", "validation", "coverage", "compare", or "seasonal_error".

series

Optional character vector of focal series names to plot.

start

Optional start datetime for time-based plots.

end

Optional end datetime for time-based plots.

show_pi

Logical. If TRUE, show 95% prediction intervals in the interpolation plot where available.

show_fit

Logical. If TRUE, show model-implied fitted values in the interpolation plot where available.

free_y

Logical. If TRUE, facets use free y scales where applicable.

ncol

Integer. Number of facet columns.

summary_metric

Character metric used when type = "summary". One of "n_imputed", "n_remaining_na", "n_missing_input", "mean_pi_width", "median_pi_width", "mean_ref_n", "median_ref_n", "n_gap_jumps_removed", or "max_abs_gap_jump".

validation_metric

Character metric used when type = "validation". One of "MAE", "MAPE", "MdAPE", "RMSE", "Bias", "Success_rate", "Mean_PI_width", "Mean_ref_n", "End_value_abs_diff", or "Max_abs_diff_within_gap".

seasonal_metric

Character metric used when type = "seasonal_error". One of "mean_error", "mean_abs_error", "mean_abs_pct_error", "rmse", or "coverage".

compare_colour

Character. Colouring used when type = "compare". One of "series" or "gap_steps".

facet

Logical. If TRUE, use faceting where supported.

empty

Character. Behavior when no suitable data are available: "plot" returns an informative empty plot and "error" throws an error.

...

Further arguments passed through the generic.

Details

Plot types:

"interpolation"

Shows original and interpolated focal series through time. Imputed points are highlighted. If jump correction was applied, corrected post-gap points are marked in green.

"uncertainty"

Shows the width of the prediction interval through time.

"availability"

Shows the number of valid reference sensors available at each step.

"summary"

Shows per-series summary diagnostics produced by the interpolation run.

"validation"

Shows synthetic-gap recovery metrics across tested gap lengths.

"coverage"

Shows how often true values fall inside the nominal 95% prediction interval across gap lengths.

"compare"

Scatter plot of actual versus interpolated values from synthetic-gap validation.

"seasonal_error"

Shows how validation error varies through the season, summarized by day of year.

Validation-based plots require that network.interpolation(..., assess = TRUE) was used to create x.

Value

A ggplot2 object.

See Also

network.interpolation

Examples


#library(dendRoAnalyst)
#data("gf_nepa17")

#df1 <- gf_nepa17
#df1[40:50, "T2"] <- NA

#ref <- cbind(gf_nepa17, gf_nepa17[, 2:3], gf_nepa17[, 2:3])
#colnames(ref) <- c("Time", "T1", "T2", "T3", "T4", "T5", "T6")

#out <- network.interpolation(
#  df1, ref,
#  niMethod = "proportional",
#  n_boot = 100,
#  assess = TRUE,
#  assess_lengths_steps = c(1, 2, 4),
#  correct_gap_jumps = TRUE,
#  jump_threshold = 0.05
#)

#plot(out)
#plot(out, type = "uncertainty")
#plot(out, type = "availability")
#plot(out, type = "summary", summary_metric = "n_gap_jumps_removed")
#plot(out, type = "validation", validation_metric = "MAPE")
#plot(out, type = "coverage")
#plot(out, type = "compare")
#plot(out, type = "seasonal_error", seasonal_metric = "mean_abs_error")



dendRoAnalyst documentation built on May 20, 2026, 5:07 p.m.