arima_plot: arima_plot: This uses the output from 'run_arima' to create a...

View source: R/arima-spikes-onegeo.R

arima_plotR Documentation

arima_plot: This uses the output from run_arima to create a figure showing the difference between the actual and expected searches for a single geography.

Description

arima_plot: This uses the output from run_arima to create a figure showing the difference between the actual and expected searches for a single geography.

Usage

arima_plot(
  df,
  geo = "US",
  title = NULL,
  xlab = "Date",
  xfmt = date_format("%b %Y"),
  ylab = "Query Fraction\n(Per 10 Million Searches)",
  outfn = "./output/fig.pdf",
  beginplot,
  endplot,
  lbreak = "1 year",
  linelabel = "Interruption",
  linelabelpos = 0.02,
  ylim = NULL,
  hicol = NA,
  locol = NA,
  nucol = NA,
  opcol = NA,
  colorscheme = "red",
  polyalpha = 0.9,
  interrupt,
  width = 6,
  height = 3,
  lwd = 0.3,
  save = T,
  extend = F,
  labels = T,
  bootnum = 1000,
  alpha = 0.05,
  labsize = 0.5
)

Arguments

df

The dataframe as outputted by run_arima.

geo

The column name of the geography of searches that you want.

title

The title of the figure. The default is no title.

xlab

The label for the x axis

ylab

The label for the y axis

outfn

Where to save the plot.

beginplot

The date you want the plot to start

endplot

The date you want the plot to end.

lbreak

The distance between tick marks in the x axis, i.e., "one year" or "3 month"

linelabel

Label next to the vertical interruption line

interrupt

The date of the interruption (should be the same as run_arima)

width

Width of the plot in inches

height

Height of the plot in inches

lwd

Line width

save

Default is True. If False, the plot is not saved.

Examples

arima_plot(
           df,
           title = "Searches to Purchase Cigarettes - US",
           xlab = "Date",
           ylab = "Query Fraction",
           outfn = './output/fig.pdf',
           beginplot = "2019-09-01",
           endplot = "2020-01-15",
           lbreak = "1 year",
           linelabel = "Tobacco 21 Signed",
           interrupt = ymd("2019-12-19"),
           width = 6,
           height = 3,
           lwd = 0.3,
           save = T
           )

tlcaputi/gtrendR documentation built on Nov. 3, 2022, 10:46 p.m.