covidcast_cor: Compute correlations between two 'covidcast_signal' data...

Description Usage Arguments Value

View source: R/cor.R

Description

Computes correlations between two covidcast_signal data frames, allowing for slicing by geo location, or by time. (Only the latest issue from each data frame is used for correlations.) See the correlations vignette for examples: vignette("correlation-utils", package = "covidcast")

Usage

1
2
3
4
5
6
7
8
9
covidcast_cor(
  x,
  y,
  dt_x = 0,
  dt_y = 0,
  by = c("geo_value", "time_value"),
  use = "na.or.complete",
  method = c("pearson", "kendall", "spearman")
)

Arguments

x, y

The covidcast_signal data frames to correlate.

dt_x, dt_y

Time shifts to consider for x and y, respectively, before computing correlations. Negative shifts translate into in a lag value and positive shifts into a lead value; for example, if dt = -1, then the new value on June 2 is the original value on June 1; if dt = 1, then the new value on June 2 is the original value on June 3; if dt = 0, then the values are left as is. Default is 0 for both dt_x and dt_y.

by

If "geo_value", then correlations are computed for each geo location, over all time. Each correlation is measured between two time series at the same location. If "time_value", then correlations are computed for each time, over all geo locations. Each correlation is measured between all locations at one time. Default is "geo_value".

use, method

Arguments to pass to cor(), with "na.or.complete" the default for use (different than cor()) and "pearson" the default for method (same as cor()).

Value

A data frame with first column geo_value or time_value (depending on by), and second column value, which gives the correlation.


covidcast documentation built on May 4, 2021, 9:08 a.m.