plot_trend: Trend plot

View source: R/plot_functions.R

plot_trendR Documentation

Trend plot

Description

Trend plot

Usage

plot_trend(
  y_0,
  y_hat,
  dates,
  pt_num = 4,
  col_vec = NULL,
  line_size = rep(0.75, ncol(y_hat) + 1),
  alpha_size = rep(0.75, ncol(y_hat) + 1),
  xlab = NULL,
  ylab = NULL
)

Arguments

y_0

True predict target, length n vector

y_hat

Predicted values by m different methods, n-by-m matrix, colnames well defined

dates

Date vector of class "Date".
Use lubridate and zoo to transfer original date vector to "Date" class

pt_num

Number date points (pt_num + 1) wanted on the x-axis

col_vec

A vector indicates colors of different trends.
e.g.: c("#D8DBE2", "#F46B7B", "#518DE8", "#FFBC42" )
If NULL, use ggplot default.

line_size

line size for each trend

alpha_size

degree of appearance

xlab

x-axis label

ylab

y-axis label

Value

A ggplot output

Examples

data("forecast_result")
data("raw_data_h1")
D <- raw_data_h1[!is.na(raw_data_h1$LongReturn), ]
dates <- zoo::as.Date.yearmon(D$yyyymm[-(1:180)])
y0 <- forecast_result$y[-(1:180)]
y_hat <-cbind(forecast_result$Lasso$y_hat,
              forecast_result$Lasso_Std$y_hat,
              forecast_result$ALasso$y_hat)
colnames(y_hat) <- c("lasso", "lasso_std", "alasso")
plot_trend(y0, y_hat, dates)


zhan-gao/LasForecast documentation built on Sept. 18, 2024, 9:40 p.m.