| Title: | Analyzing Revisions in Real-Time Time Series Vintages |
|---|---|
| Description: | Analyzes revisions in real-time time series vintages. The package converts between wide revision triangles and tidy long vintages, extracts selected releases, computes revision series, visualizes vintage paths, and summarizes revision properties such as bias, dispersion, autocorrelation, and news-noise diagnostics. It also identifies efficient releases and estimates state-space models for revision nowcasting. Methods are based on Howrey (1978) <doi:10.2307/1924972>, Jacobs and Van Norden (2011) <doi:10.1016/j.jeconom.2010.04.010>, and Kishor and Koenig (2012) <doi:10.1198/jbes.2010.08169>. |
| Authors: | Marc Burri [aut, cre, cph] (ORCID: <https://orcid.org/0000-0001-8974-9090>), Philipp Wegmueller [aut, cph] |
| Maintainer: | Marc Burri <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.1 |
| Built: | 2026-04-01 08:20:55 UTC |
| Source: | https://github.com/ropensci/reviser |
Generic function to provide diagnostic summaries for revision analysis objects.
diagnose(object, ...)diagnose(object, ...)
object |
An object for which diagnostics are desired. |
... |
Additional arguments passed to methods. |
Method-specific diagnostic output.
Other revision analysis:
diagnose.revision_summary(),
get_first_efficient_release(),
get_revision_analysis(),
print.lst_efficient(),
print.revision_summary(),
summary.lst_efficient(),
summary.revision_summary()
# Example usage with revision analysis results df <- dplyr::select( get_nth_release( na.omit( tsbox::ts_pc( dplyr::filter(reviser::gdp, id == "US") ) ), n = 0:3 ), -"pub_date" ) final_release <- dplyr::select( get_nth_release( na.omit( tsbox::ts_pc( dplyr::filter(reviser::gdp, id == "US") ) ), n = "latest" ), -"pub_date" ) # Get revision analysis results results <- get_revision_analysis(df, final_release, degree = 5) # Diagnose revision quality diagnose(results)# Example usage with revision analysis results df <- dplyr::select( get_nth_release( na.omit( tsbox::ts_pc( dplyr::filter(reviser::gdp, id == "US") ) ), n = 0:3 ), -"pub_date" ) final_release <- dplyr::select( get_nth_release( na.omit( tsbox::ts_pc( dplyr::filter(reviser::gdp, id == "US") ) ), n = "latest" ), -"pub_date" ) # Get revision analysis results results <- get_revision_analysis(df, final_release, degree = 5) # Diagnose revision quality diagnose(results)
Provides a quick diagnostic summary of revision quality with color-coded pass/fail indicators for key metrics.
## S3 method for class 'revision_summary' diagnose(object, alpha = 0.05, ...)## S3 method for class 'revision_summary' diagnose(object, alpha = 0.05, ...)
object |
An object of class |
alpha |
Significance level for hypothesis tests. Default is 0.05. |
... |
Additional arguments (not used). |
A tibble with diagnostic results.
Other revision analysis:
diagnose(),
get_first_efficient_release(),
get_revision_analysis(),
print.lst_efficient(),
print.revision_summary(),
summary.lst_efficient(),
summary.revision_summary()
# Example usage with revision analysis results df <- dplyr::select( get_nth_release( na.omit( tsbox::ts_pc( dplyr::filter(reviser::gdp, id == "US") ) ), n = 0:3 ), -"pub_date" ) final_release <- dplyr::select( get_nth_release( na.omit( tsbox::ts_pc( dplyr::filter(reviser::gdp, id == "US") ) ), n = "latest" ), -"pub_date" ) # Get revision analysis results results <- get_revision_analysis(df, final_release, degree = 5) # Diagnose revision quality diagnose(results)# Example usage with revision analysis results df <- dplyr::select( get_nth_release( na.omit( tsbox::ts_pc( dplyr::filter(reviser::gdp, id == "US") ) ), n = 0:3 ), -"pub_date" ) final_release <- dplyr::select( get_nth_release( na.omit( tsbox::ts_pc( dplyr::filter(reviser::gdp, id == "US") ) ), n = "latest" ), -"pub_date" ) # Get revision analysis results results <- get_revision_analysis(df, final_release, degree = 5) # Diagnose revision quality diagnose(results)
A collection of real-time datasets.
gdpgdp
A tibble with quarterly observations and 4 variables:
Date of the observation
Publication date of the vintage
Numeric, real GDP (seasonally adjusted)
Country code
GDP: Quarterly Vintages (Billions of real dollars, seasonally adjusted)
Timeframe: Q1 1980 - Q4 2024
Real-Time Vintages: Q4 2002 - Q4 2024
All the data is from the realtime database of Indergand and Leist (2014). Countries:
CHE:
Switzerland
Source: SECO
US:
United States
Sources: FRED, OECD
EA:
Euro Area
Sources: Eurostat, OECD
JP:
Japan
Sources: Cabinet Office (Japan), OECD
Indergand, R., Leist, S. A Real-Time Data Set for Switzerland. Swiss J Economics Statistics 150, 331–352 (2014). doi:10.1007/BF03399410
# Load gdp dataset data(gdp) head(gdp)# Load gdp dataset data(gdp) head(gdp)
Computes the number of days between the publication date (pub_date) of a
release and the time period (time) end date for each record in
the dataset.
get_days_to_release(df)get_days_to_release(df)
df |
A data frame containing data vintages. The data frame must
include the columns |
The function calculates the difference between pub_date and time
for each row in the dataset. The result is expressed as the number of days
between the release publication date and the corresponding time period end.
If the dataset is in wide format, it will first be transformed into long
format using vintages_long.
A data frame with an additional column days_to_release
representing the number of days between the publication date (pub_date)
and the time period (time) for each release.
Other revision utilities:
get_first_release(),
get_fixed_release(),
get_latest_release(),
get_nth_release(),
get_releases_by_date(),
get_revisions()
# Example data df <- dplyr::filter(reviser::gdp, id == "US") # Calculate days to release df_with_days <- get_days_to_release(df)# Example data df <- dplyr::filter(reviser::gdp, id == "US") # Calculate days to release df_with_days <- get_days_to_release(df)
Identifies the first release in a sequence of vintages that is "efficient" relative to the final release. A release is deemed efficient if it satisfies specific conditions of unbiasedness and efficiency, tested using a Mincer-Zarnowitz type linear regression and hypothesis testing.
get_first_efficient_release( df, final_release, significance = 0.05, test_all = FALSE, robust = TRUE )get_first_efficient_release( df, final_release, significance = 0.05, test_all = FALSE, robust = TRUE )
df |
A data frame of class
|
final_release |
A data frame containing the final release data. This must include the columns:
|
significance |
A numeric value specifying the significance level for
the hypothesis test (default is |
test_all |
A logical value indicating whether to test all releases,
even after finding the first efficient release (default is |
robust |
A logical value indicating whether to use robust HAC standard
errors (default is |
The function performs the following steps:
Validates inputs and ensures both df and final_release are in the
correct format.
Iteratively tests each release for efficiency using a linear regression model of the form:
The null hypothesis for efficiency is:
(no bias)
(efficiency)
Uses heteroskedasticity and autocorrelation consistent (HAC) standard
errors for robust hypothesis testing.
Stops testing when the first efficient release is found (unless
test_all = TRUE).
If no efficient release is found, a warning is issued.
A list of class lst_efficient with the following elements:
e: The index of the first efficient release. (0 indexed)
data: A long-format data frame containing the vintage data with the
final release appended.
models: A list of linear regression models fitted for each release.
tests: A list of hypothesis test results for each release.
Aruoba, S. Boragan, "Revisions Are Not Well Behaved", Journal of Money, Credit and Banking, 40(2-3), 319-340, 2008.
Other revision analysis:
diagnose(),
diagnose.revision_summary(),
get_revision_analysis(),
print.lst_efficient(),
print.revision_summary(),
summary.lst_efficient(),
summary.revision_summary()
# Example data df <- get_nth_release( tsbox::ts_pc(dplyr::filter(reviser::gdp, id == "US")), n = 0:3 ) final_release <- get_nth_release( tsbox::ts_pc(dplyr::filter(reviser::gdp, id == "US")), n = 10 ) # Identify the first efficient release result <- get_first_efficient_release( df, final_release, significance = 0.05, robust = FALSE ) result <- get_first_efficient_release(df, final_release, significance = 0.05) # Access the index of the first efficient release result$e# Example data df <- get_nth_release( tsbox::ts_pc(dplyr::filter(reviser::gdp, id == "US")), n = 0:3 ) final_release <- get_nth_release( tsbox::ts_pc(dplyr::filter(reviser::gdp, id == "US")), n = 10 ) # Identify the first efficient release result <- get_first_efficient_release( df, final_release, significance = 0.05, robust = FALSE ) result <- get_first_efficient_release(df, final_release, significance = 0.05) # Access the index of the first efficient release result$e
Filters the input dataset to return the earliest release (or vintage) for each time period.
get_first_release(df, diagonal = FALSE)get_first_release(df, diagonal = FALSE)
df |
A data frame containing data vintages. The data frame must
include the columns |
diagonal |
Logical. If |
For each time period, the function identifies the release with the earliest
publication date (pub_date). A new column release is added and labels
all rows in the resulting data frame as release_0. If diagonal is set
to TRUE, the function only returns the real first releases. That is
historic values for which no vintages exist are not returned.
A filtered data frame containing only the first release(s).
The resulting data frame is assigned the class tbl_release to
indicate its structure.
Other revision utilities:
get_days_to_release(),
get_fixed_release(),
get_latest_release(),
get_nth_release(),
get_releases_by_date(),
get_revisions()
# Example data df <- dplyr::filter(reviser::gdp, id == "US") # Get the first release for each time period first_release <- get_first_release(df)# Example data df <- dplyr::filter(reviser::gdp, id == "US") # Get the first release for each time period first_release <- get_first_release(df)
Some statistical agencies make a final revision of their data after a certain period of time in a give month in the year. This function extracts values from a given month or quarter a specified number of years after the initial release.
get_fixed_release(df, years, month = NULL, quarter = NULL)get_fixed_release(df, years, month = NULL, quarter = NULL)
df |
A data frame containing columns |
years |
A single whole number of years after |
month |
An optional parameter specifying the target month as a name
("July") or an integer (7). Cannot be used with |
quarter |
An optional parameter specifying the target quarter (1-4).
Cannot be used with |
A filtered data frame containing values matching the specified criteria.
Other revision utilities:
get_days_to_release(),
get_first_release(),
get_latest_release(),
get_nth_release(),
get_releases_by_date(),
get_revisions()
df <- dplyr::filter(reviser::gdp, id == "US") dta <- get_fixed_release(df, month = "July", years = 3) dta <- get_fixed_release(df, month = 7, years = 3) dta <- get_fixed_release(df, quarter = 3, years = 3)df <- dplyr::filter(reviser::gdp, id == "US") dta <- get_fixed_release(df, month = "July", years = 3) dta <- get_fixed_release(df, month = 7, years = 3) dta <- get_fixed_release(df, quarter = 3, years = 3)
Filters the input dataset to return the most recent release (or vintage) for each time period.
get_latest_release(df)get_latest_release(df)
df |
A data frame containing data vintages. The data frame must include
the columns |
For each time period, the function identifies the release with the latest
publication date (pub_date) and adds a column release that labels the
release as release_N, where N is the release index (zero indexed).
A filtered data frame containing only the most recent release(s).
The resulting data frame is assigned the class tbl_release to indicate
its structure.
Other revision utilities:
get_days_to_release(),
get_first_release(),
get_fixed_release(),
get_nth_release(),
get_releases_by_date(),
get_revisions()
# Example data df <- dplyr::filter(reviser::gdp, id == "US") # Get the latest release for each time period latest_release <- get_latest_release(df)# Example data df <- dplyr::filter(reviser::gdp, id == "US") # Get the latest release for each time period latest_release <- get_latest_release(df)
Filters the input dataset to return the Nth release (or vintage) of data for each time period. The function supports selecting the first, latest, or a specific numbered release.
get_nth_release(df, n = 0, diagonal = FALSE)get_nth_release(df, n = 0, diagonal = FALSE)
df |
A data frame containing data vintages. The data frame must include the columns:
|
n |
The release number to extract. Accepts:
|
diagonal |
Logical. If |
The behavior depends on the value of n:
Non-negative integer: The function retrieves the Nth release for each time period (e.g., 0 = first release, 1 = second release, etc.).
"first": Retrieves the first release for each time
period (via get_first_release).
"latest": Retrieves the most recent release for each time
period (via get_latest_release).
A filtered data frame containing only the specified release(s).
The resulting data frame is assigned the class tbl_release to indicate
its structure. If diagonal is set to TRUE, the function only returns the
real first releases. That is historic values for which no vintages exist
are not returned.
Other revision utilities:
get_days_to_release(),
get_first_release(),
get_fixed_release(),
get_latest_release(),
get_releases_by_date(),
get_revisions()
# Example data df <- dplyr::filter(reviser::gdp, id == "US") # Get the first release (n = 0) first_release <- get_nth_release(df, n = 0) # Get the latest release latest_release <- get_nth_release(df, n = "latest") # Get the second release (n = 1) second_release <- get_nth_release(df, n = 1) # Get the first and second release (n = 0:1) releases <- get_nth_release(df, n = 0:1)# Example data df <- dplyr::filter(reviser::gdp, id == "US") # Get the first release (n = 0) first_release <- get_nth_release(df, n = 0) # Get the latest release latest_release <- get_nth_release(df, n = "latest") # Get the second release (n = 1) second_release <- get_nth_release(df, n = 1) # Get the first and second release (n = 0:1) releases <- get_nth_release(df, n = 0:1)
Filters the input dataset to return the releases corresponding to a specific time period (date).
get_releases_by_date(df, date)get_releases_by_date(df, date)
df |
A data frame containing data vintages. The data frame must
include the columns |
date |
A Date object specifying the time period (date) for which releases should be retrieved. |
This function filters the input data based on the specified date in the
time column. The input dataset must have the pub_date and time columns,
with time being the period to match against the given date. If the
dataset is in wide format, it will first be transformed into long format
using the helper function vintages_long.
A data frame containing the releases for the specified date.
The returned data frame will include the same structure as the input,
filtered to only include rows matching the date in the time column.
Other revision utilities:
get_days_to_release(),
get_first_release(),
get_fixed_release(),
get_latest_release(),
get_nth_release(),
get_revisions()
# Example data df <- dplyr::filter(reviser::gdp, id == "US") # Get releases for a specific date date <- as.Date("2020-04-01") releases_on_date <- get_releases_by_date(df, date)# Example data df <- dplyr::filter(reviser::gdp, id == "US") # Get releases for a specific date date <- as.Date("2020-04-01") releases_on_date <- get_releases_by_date(df, date)
Calculates a comprehensive set of summary statistics and hypothesis tests for revisions between initial and final data releases.
get_revision_analysis(df, final_release, degree = 1, grouping_var = NULL)get_revision_analysis(df, final_release, degree = 1, grouping_var = NULL)
df |
A data frame containing the initial data releases. Must include columns:
|
final_release |
A data frame containing the final release data. Must include columns:
|
degree |
An integer between 1 and 5 specifying the level of detail for the output: 1: Default, includes information about revision size. 2: includes correlation statistics of revision. 3: includes news and noise tests. 4: includes sign switches, seasonality analysis and Theil's U. 5: Full set of all statistics and tests. |
grouping_var |
A character string specifying the grouping variable in
the data frame. Defaults to |
This function performs a variety of statistical analyses to understand the nature of revisions between the initial and final data releases. The function:
Checks the input data for consistency and transforms it as necessary.
Merges the initial and final release datasets by their time variable and
optional grouping variables (id or release).
Computes summary statistics such as the mean, standard deviation, and range of the revisions.
Performs hypothesis tests for bias, efficiency, and correlation using robust methods (e.g., Newey-West standard errors).
Includes tests for seasonality, noise, and news effects.
Key tests include:
Bias Tests: Tests for the presence of mean bias and regression bias.
Autocorrelation and Seasonality: Tests for serial correlation and seasonal patterns in revisions.
Theil's U Statistics: Measures predictive accuracy of the initial releases relative to the final values.
Noise vs. News: Differentiates between unpredictable errors (noise) and systematic adjustments (news).
The function supports grouped calculations based on the presence
of id or release columns in the input.
The following statistics and tests are calculated (See the vignette
vignette("revision-analysis") for more details):
N: The number of observations in the group.
Frequency: The inferred data frequency (e.g., 12 for monthly or 4 for quarterly data).
Bias (mean): The mean revision, testing whether revisions are systematically biased.
Bias (p-value): p-value from a t-test evaluating the significance of the mean revision.
Bias (robust p-value): Newey-West HAC robust p-value for the mean revision test.
Minimum: The minimum revision in the group.
Maximum: The maximum revision in the group.
10Q: The 10th percentile revision.
Median: The median revision.
90Q: The 90th percentile revision.
MAR: The mean absolute revision.
Std. Dev.: The standard deviation of revisions, indicating their variability.
Noise/Signal: The ratio of the standard deviation of revisions to the standard deviation of final values.
Correlation: The Pearson correlation between revisions and initial values, testing the relationship.
Correlation (p-value): p-value for the significance of the correlation.
Autocorrelation (1st): The first-order autocorrelation of revisions, measuring persistence.
Autocorrelation (1st p-value): p-value for the first-order autocorrelation test.
Autocorrelation up to 1yr (Ljung-Box p-value): p-value for the Ljung-Box test for higher-order autocorrelation.
Theil's U1: A normalized measure of forecast accuracy, comparing the root mean squared error (RMSE) of revisions to the RMSE of final and initial values.
Theil's U2: Compares forecast changes to actual changes.
Seasonality (Friedman p-value): p-value from the Friedman test for seasonality in revisions.
News joint test (p-value): p-value for the joint news test.
News test Intercept: The estimated intercept from the news test regression.
News test Intercept (std.err): The standard error of the intercept in the news test regression.
News test Intercept (p-value): p-value for the intercept in the news test regression.
News test Coefficient: The estimated coefficient for the
value in the news test regression.
News test Coefficient (std.err): The standard error of the coefficient in the news test regression.
News test Coefficient (p-value): p-value for the coefficient in the news test regression.
Noise joint test (p-value): p-value for the joint noise test.
Noise test Intercept: The estimated intercept from the noise test regression.
Noise test Intercept (std.err): The standard error of the intercept in the noise test regression.
Noise test Intercept (p-value): p-value for the intercept in the noise test regression.
Noise test Coefficient: The estimated coefficient for the
final_value in the noise test regression.
Noise test Coefficient (std.err): The standard error of the coefficient in the noise test regression.
Noise test Coefficient (p-value): p-value for the coefficient in the noise test regression.
Fraction of correct sign: The fraction of correct sign changes in revisions.
Fraction of correct growth rate change: The fraction of correct sign changes of growth rates in revisions.
A data frame with one row per grouping (if applicable) and columns
for summary statistics and test results. The resulting data frame is of
class revision_summary.
Other revision analysis:
diagnose(),
diagnose.revision_summary(),
get_first_efficient_release(),
print.lst_efficient(),
print.revision_summary(),
summary.lst_efficient(),
summary.revision_summary()
# Example usage: df_small <- dplyr::filter( reviser::gdp, id == "US", time >= as.Date("2018-01-01") ) df <- dplyr::select( get_nth_release(df_small, n = 0:2), -"pub_date" ) final_release <- dplyr::select( get_nth_release(df_small, n = "latest"), -"pub_date" ) results <- get_revision_analysis( df, final_release )# Example usage: df_small <- dplyr::filter( reviser::gdp, id == "US", time >= as.Date("2018-01-01") ) df <- dplyr::select( get_nth_release(df_small, n = 0:2), -"pub_date" ) final_release <- dplyr::select( get_nth_release(df_small, n = "latest"), -"pub_date" ) results <- get_revision_analysis( df, final_release )
Computes revisions in vintage data based on specified reference points: a fixed reference date, the nth release, or a specified interval. This function allows users to analyze differences between data vintages across time.
get_revisions(df, interval = NULL, nth_release = NULL, ref_date = NULL)get_revisions(df, interval = NULL, nth_release = NULL, ref_date = NULL)
df |
A data frame containing vintage data. The data frame must include at least the following columns:
|
interval |
A positive integer specifying the lag (in periods) between
vintages to compute revisions.
Defaults to |
nth_release |
A positive integer or |
ref_date |
A date specifying the fixed reference publication date to compare all vintages against. |
The function supports three mutually exclusive methods for calculating revisions:
Reference date (ref_date): Computes revisions relative to a
fixed publication date.
Interval (interval): Computes revisions relative to vintages
published interval periods earlier.
Nth release (nth_release): Computes revisions relative to the
nth vintage release for each reference period.
If no method is explicitly specified, interval = 1 is used by default.
Input validation ensures that only one of ref_date, nth_release, or
interval is specified.
A data frame (tibble) of class tbl_revision, with the
following columns:
pub_date: The publication date of the vintage.
time: The reference period (e.g., quarter or month).
value: The calculated revision, i.e., the difference between the
observed value and the reference value.
Other revision utilities:
get_days_to_release(),
get_first_release(),
get_fixed_release(),
get_latest_release(),
get_nth_release(),
get_releases_by_date()
# Example data df <- dplyr::filter(reviser::gdp, id == "US") # Calculate revisions using an interval of 1 revisions_interval <- get_revisions(df, interval = 1) # Calculate revisions using a fixed reference date revisions_date <- get_revisions(df, ref_date = as.Date("2023-02-01")) # Calculate revisions relative to the nth release (2nd release) revisions_nth <- get_revisions(df, nth_release = 1)# Example data df <- dplyr::filter(reviser::gdp, id == "US") # Calculate revisions using an interval of 1 revisions_interval <- get_revisions(df, interval = 1) # Calculate revisions using a fixed reference date revisions_date <- get_revisions(df, ref_date = as.Date("2023-02-01")) # Calculate revisions relative to the nth release (2nd release) revisions_nth <- get_revisions(df, nth_release = 1)
Estimate the Jacobs and Van Norden (2011) state-space model for real-time data revisions, allowing for news and noise components and optional spillovers.
jvn_nowcast( df, e, ar_order = 1, h = 0, include_news = TRUE, include_noise = TRUE, include_spillovers = FALSE, spillover_news = TRUE, spillover_noise = TRUE, method = "MLE", alpha = 0.05, standardize = FALSE, solver_options = list() )jvn_nowcast( df, e, ar_order = 1, h = 0, include_news = TRUE, include_noise = TRUE, include_spillovers = FALSE, spillover_news = TRUE, spillover_noise = TRUE, method = "MLE", alpha = 0.05, standardize = FALSE, solver_options = list() )
df |
A matrix, data frame, or single-ID vintages object. Wide data
should store one vintage per column. Long-format vintages data are also
accepted and are converted internally. If |
e |
A single integer giving the number of vintages used in estimation.
The function uses the first |
ar_order |
A single integer giving the autoregressive order of the
latent true-value process. Must be greater than |
h |
A single integer giving the forecast horizon. Must be greater than
or equal to |
include_news |
Logical; whether to include a news component. |
include_noise |
Logical; whether to include a noise component. |
include_spillovers |
Logical; whether to include spillover effects. |
spillover_news |
Logical; whether spillovers apply to the news component. |
spillover_noise |
Logical; whether spillovers apply to the noise component. |
method |
Estimation method. Currently only |
alpha |
Significance level used for confidence intervals. Must lie in
|
standardize |
Logical; whether to standardize the vintage matrix before
estimation using |
solver_options |
A named list of solver options. Valid names are
For backward compatibility, the legacy aliases |
An object of class "jvn_model" with components:
A tibble of filtered and smoothed state estimates. If
solver_options$return_states = FALSE, this is NULL.
A list containing the state-space matrices Z,
Tmat, R, H, and Q.
A data frame of parameter estimates and standard errors.
The raw optimizer output returned by the selected numerical optimizer.
The maximized log-likelihood.
Akaike information criterion.
Bayesian information criterion.
Optimizer convergence code.
The input data after preprocessing.
Scaling metadata returned by jvn_standardize() when
standardize = TRUE; otherwise NULL.
The standard-error method used.
Estimated covariance matrix of the parameter estimates, if
available; otherwise NULL.
Jacobs, Jan P. A. M. and Van Norden, Simon (2011). Modeling data revisions: Measurement error and dynamics of "true" values. Journal of Econometrics.
Other revision nowcasting:
kk_nowcast(),
plot.jvn_model(),
plot.kk_model(),
print.jvn_model(),
print.kk_model(),
summary.jvn_model(),
summary.kk_model()
gdp_growth <- dplyr::filter( tsbox::ts_pc(reviser::gdp), id == "EA", time >= min(pub_date), time <= as.Date("2020-01-01") ) gdp_growth <- tidyr::drop_na(gdp_growth) df <- get_nth_release(gdp_growth, n = 0:3) result <- jvn_nowcast( df = df, e = 4, ar_order = 2, h = 0, include_news = TRUE, include_noise = TRUE ) summary(result)gdp_growth <- dplyr::filter( tsbox::ts_pc(reviser::gdp), id == "EA", time >= min(pub_date), time <= as.Date("2020-01-01") ) gdp_growth <- tidyr::drop_na(gdp_growth) df <- get_nth_release(gdp_growth, n = 0:3) result <- jvn_nowcast( df = df, e = 4, ar_order = 2, h = 0, include_news = TRUE, include_noise = TRUE ) summary(result)
Implements a generalized Kishor-Koenig (KK) model for nowcasting and forecasting with state-space models, allowing for multiple vintages of data, efficient estimation, and Kalman filtering and smoothing.
kk_nowcast( df, e, h = 0, model = "Kishor-Koenig", method = "MLE", alpha = 0.05, solver_options = list() )kk_nowcast( df, e, h = 0, model = "Kishor-Koenig", method = "MLE", alpha = 0.05, solver_options = list() )
df |
A data frame or single-ID vintages object in either long or wide
format. Long-format vintages data are converted internally. After
preprocessing, the data must contain a |
e |
An integer indicating the number of data vintages to include in the model. Must be greater than 0. |
h |
An integer specifying the forecast horizon. Default is 0, which implies no forecasts. Must be greater than or equal to 0. |
model |
A string specifying the type of model to use. Options are:
|
method |
A string specifying the estimation method to use. Options are "MLE" (Maximum Likelihood, default), "SUR", and "OLS". |
alpha |
Significance level for confidence intervals (default = 0.05). |
solver_options |
A named list controlling the SUR and MLE routines.
Valid names are
For backward compatibility, the legacy aliases |
The function supports multiple models, including the full Kishor-Koenig
framework, Howrey's model, and a classical approach. It handles data
preprocessing, estimation of system equations using Seemingly Unrelated
Regressions (SUR), and application of the Kalman filter. This is
the first openly available implementation of the Kishor-Koenig model (See
the vignette vignette("nowcasting_revisions") for more details).
A list with the following components:
A tibble containing filtered and smoothed state estimates. If
solver_options$return_states = FALSE, this is NULL.
A list of KK model matrices, such as transition and observation matrices.
A list of state-space model matrices derived from the KK model.
The fitted KFAS::SSModel object. If
solver_options$return_states = FALSE, this is NULL.
Estimated model parameters with standard errors.
The raw fit object returned by the selected estimator.
Log-likelihood value for MLE fits; otherwise NULL.
Akaike information criterion for MLE fits; otherwise NULL.
Bayesian information criterion for MLE fits; otherwise NULL.
Convergence status.
The number of the efficient release (0-indexed).
The input data after preprocessing to wide format.
The standard-error method used by MLE; otherwise NULL.
Estimated covariance matrix of the parameter estimates, if
available; otherwise NULL.
Kishor, N. Kundan and Koenig, Evan F., "VAR Estimation and Forecasting When Data Are Subject to Revision", Journal of Business and Economic Statistics, 2012.
Other revision nowcasting:
jvn_nowcast(),
plot.jvn_model(),
plot.kk_model(),
print.jvn_model(),
print.kk_model(),
summary.jvn_model(),
summary.kk_model()
# Example usage: df <- get_nth_release( tsbox::ts_span( tsbox::ts_pc( dplyr::filter(reviser::gdp, id == "US") ), start = "1980-01-01" ), n = 0:1 ) df <- dplyr::select(df, -c("id", "pub_date")) df <- na.omit(df) e <- 1 # Number of efficient release h <- 2 # Forecast horizon result <- kk_nowcast(df, e, h = h, model = "Kishor-Koenig") result$params# Example usage: df <- get_nth_release( tsbox::ts_span( tsbox::ts_pc( dplyr::filter(reviser::gdp, id == "US") ), start = "1980-01-01" ), n = 0:1 ) df <- dplyr::select(df, -c("id", "pub_date")) df <- na.omit(df) e <- 1 # Number of efficient release h <- 2 # Forecast horizon result <- kk_nowcast(df, e, h = h, model = "Kishor-Koenig") result$params
A flexible function to visualize vintage data using various plot types such as line plots, point plots, bar plots, or boxplots. The function ensures that input data is validated and appropriately transformed before plotting.
plot_vintages( df, type = "line", dim_col = "pub_date", time_col = "time", title = "", subtitle = "", ylab = "" )plot_vintages( df, type = "line", dim_col = "pub_date", time_col = "time", title = "", subtitle = "", ylab = "" )
df |
A data frame containing the vintage data to be plotted. Must
include at least two columns:
one for time ( |
type |
A character string specifying the type of plot to create. Options are:
|
dim_col |
A character string specifying the column name in |
time_col |
A character string specifying the column name in |
title |
A character string specifying the title of the plot. Defaults to an empty string. |
subtitle |
A character string specifying the subtitle of the plot. Defaults to an empty string. |
ylab |
A character string specifying the label for the y-axis. Defaults to an empty string. |
The plot_vintages function is designed to handle data frames in both
wide and long formats. It ensures
that the provided data frame includes the necessary columns for plotting.
If the dim_col column contains
more than 30 unique values, only the most recent 30 are plotted.
Additionally, the function supports
custom themes and color scales using scale_color_reviser,
scale_fill_reviser, and theme_reviser.
The function raises an error if:
The type argument is not one of "line", "point", "bar",
or "boxplot".
The specified dim_col is not a column in df.
title, subtitle, or ylab are not character strings.
A ggplot2 plot object representing the specified vintage data visualization.
theme_reviser(), scale_color_reviser(), scale_fill_reviser()
Other revision graphs:
plot.tbl_pubdate(),
plot.tbl_release(),
theme_reviser()
# Example data df <- data.frame( time = rep(seq.Date(from = as.Date("2022-01-01"), by = "month", length.out = 12), 3), value = runif(36, 50, 100), pub_date = rep(c("2022-01-05", "2022-02-07", "2022-03-03"), each = 12) ) # Line plot plot_vintages( df, type = "line", dim_col = "pub_date", title = "Line plot", subtitle = "Randomly generated data" ) # Point plot plot_vintages( df, type = "point", dim_col = "pub_date", title = "Scatter plot", subtitle = "Randomly generated data" ) # Bar plot plot_vintages( df, type = "bar", dim_col = "pub_date", title = "Bar plot", subtitle = "Randomly generated data" ) # Boxplot plot_vintages( df, type = "boxplot", dim_col = "pub_date", title = "Boxplot", subtitle = "Randomly generated data" )# Example data df <- data.frame( time = rep(seq.Date(from = as.Date("2022-01-01"), by = "month", length.out = 12), 3), value = runif(36, 50, 100), pub_date = rep(c("2022-01-05", "2022-02-07", "2022-03-03"), each = 12) ) # Line plot plot_vintages( df, type = "line", dim_col = "pub_date", title = "Line plot", subtitle = "Randomly generated data" ) # Point plot plot_vintages( df, type = "point", dim_col = "pub_date", title = "Scatter plot", subtitle = "Randomly generated data" ) # Bar plot plot_vintages( df, type = "bar", dim_col = "pub_date", title = "Bar plot", subtitle = "Randomly generated data" ) # Boxplot plot_vintages( df, type = "boxplot", dim_col = "pub_date", title = "Boxplot", subtitle = "Randomly generated data" )
Plot filtered or smoothed estimates for a selected state from a fitted
jvn_model.
## S3 method for class 'jvn_model' plot(x, state = "true_lag_0", type = "filtered", ...)## S3 method for class 'jvn_model' plot(x, state = "true_lag_0", type = "filtered", ...)
x |
An object of class |
state |
Character scalar giving the state to visualize. Defaults to
|
type |
Character scalar indicating whether |
... |
Additional arguments passed to |
This method requires x$states to be available. If the model was
fitted with solver_options$return_states = FALSE, plotting is not
possible.
A ggplot2 object.
Other revision nowcasting:
jvn_nowcast(),
kk_nowcast(),
plot.kk_model(),
print.jvn_model(),
print.kk_model(),
summary.jvn_model(),
summary.kk_model()
gdp_growth <- dplyr::filter( tsbox::ts_pc(reviser::gdp), id == "EA", time >= min(pub_date), time <= as.Date("2020-01-01") ) gdp_growth <- tidyr::drop_na(gdp_growth) df <- get_nth_release(gdp_growth, n = 0:3) result <- jvn_nowcast( df = df, e = 4, ar_order = 2, h = 0, include_news = TRUE, include_noise = TRUE ) plot(result)gdp_growth <- dplyr::filter( tsbox::ts_pc(reviser::gdp), id == "EA", time >= min(pub_date), time <= as.Date("2020-01-01") ) gdp_growth <- tidyr::drop_na(gdp_growth) df <- get_nth_release(gdp_growth, n = 0:3) result <- jvn_nowcast( df = df, e = 4, ar_order = 2, h = 0, include_news = TRUE, include_noise = TRUE ) plot(result)
Plot filtered or smoothed estimates for a selected state from a fitted
kk_model.
## S3 method for class 'kk_model' plot(x, state = NULL, type = "filtered", ...)## S3 method for class 'kk_model' plot(x, state = NULL, type = "filtered", ...)
x |
An object of class |
state |
Character scalar giving the state to visualize. If |
type |
Character scalar indicating whether |
... |
Additional arguments passed to |
This method requires x$states to be available. If the model was
fitted with solver_options$return_states = FALSE, plotting is not
possible.
A ggplot2 object visualizing the specified state estimates.
Other revision nowcasting:
jvn_nowcast(),
kk_nowcast(),
plot.jvn_model(),
print.jvn_model(),
print.kk_model(),
summary.jvn_model(),
summary.kk_model()
df <- get_nth_release( tsbox::ts_span( tsbox::ts_pc( dplyr::filter(reviser::gdp, id == "US") ), start = "1980-01-01" ), n = 0:1 ) df <- dplyr::select(df, -c("id", "pub_date")) df <- na.omit(df) e <- 1 # Number of efficient release h <- 2 # Forecast horizon result <- kk_nowcast(df, e, h = h, model = "Kishor-Koenig") plot(result)df <- get_nth_release( tsbox::ts_span( tsbox::ts_pc( dplyr::filter(reviser::gdp, id == "US") ), start = "1980-01-01" ), n = 0:1 ) df <- dplyr::select(df, -c("id", "pub_date")) df <- na.omit(df) e <- 1 # Number of efficient release h <- 2 # Forecast horizon result <- kk_nowcast(df, e, h = h, model = "Kishor-Koenig") plot(result)
Plot Method for Publication Date Vintages
## S3 method for class 'tbl_pubdate' plot(x, ...)## S3 method for class 'tbl_pubdate' plot(x, ...)
x |
An object of class |
... |
Additional arguments passed to plot_vintages. |
A ggplot2 object.
Other revision graphs:
plot.tbl_release(),
plot_vintages(),
theme_reviser()
df <- dplyr::filter(reviser::gdp, id == "US") plot(df)df <- dplyr::filter(reviser::gdp, id == "US") plot(df)
Plot Method for Release Vintages
## S3 method for class 'tbl_release' plot(x, ...)## S3 method for class 'tbl_release' plot(x, ...)
x |
An object of class |
... |
Additional arguments passed to plot_vintages. |
A ggplot2 object.
Other revision graphs:
plot.tbl_pubdate(),
plot_vintages(),
theme_reviser()
df <- dplyr::filter(reviser::gdp, id == "US") df <- get_nth_release(df, n = 0:5) plot(df)df <- dplyr::filter(reviser::gdp, id == "US") df <- get_nth_release(df, n = 0:5) plot(df)
Default print method for jvn_model objects. This method dispatches to
summary.jvn_model() for a consistent console display.
## S3 method for class 'jvn_model' print(x, ...)## S3 method for class 'jvn_model' print(x, ...)
x |
An object of class |
... |
Additional arguments passed to |
The input object, invisibly.
Other revision nowcasting:
jvn_nowcast(),
kk_nowcast(),
plot.jvn_model(),
plot.kk_model(),
print.kk_model(),
summary.jvn_model(),
summary.kk_model()
gdp_growth <- dplyr::filter( tsbox::ts_pc(reviser::gdp), id == "EA", time >= min(pub_date), time <= as.Date("2020-01-01") ) gdp_growth <- tidyr::drop_na(gdp_growth) df <- get_nth_release(gdp_growth, n = 0:3) result <- jvn_nowcast( df = df, e = 4, ar_order = 2, h = 0, include_news = TRUE, include_noise = TRUE ) resultgdp_growth <- dplyr::filter( tsbox::ts_pc(reviser::gdp), id == "EA", time >= min(pub_date), time <= as.Date("2020-01-01") ) gdp_growth <- tidyr::drop_na(gdp_growth) df <- get_nth_release(gdp_growth, n = 0:3) result <- jvn_nowcast( df = df, e = 4, ar_order = 2, h = 0, include_news = TRUE, include_noise = TRUE ) result
Default print method for kk_model objects.
Wraps the summary method for a consistent output.
## S3 method for class 'kk_model' print(x, ...)## S3 method for class 'kk_model' print(x, ...)
x |
An object of class |
... |
Additional arguments passed to |
The function returns the input x invisibly.
Other revision nowcasting:
jvn_nowcast(),
kk_nowcast(),
plot.jvn_model(),
plot.kk_model(),
print.jvn_model(),
summary.jvn_model(),
summary.kk_model()
df <- get_nth_release( tsbox::ts_span( tsbox::ts_pc( dplyr::filter(reviser::gdp, id == "US") ), start = "1980-01-01" ), n = 0:1 ) df <- dplyr::select(df, -c("id", "pub_date")) df <- na.omit(df) e <- 1 h <- 2 result <- kk_nowcast(df, e, h = h, model = "Kishor-Koenig", method = "MLE") resultdf <- get_nth_release( tsbox::ts_span( tsbox::ts_pc( dplyr::filter(reviser::gdp, id == "US") ), start = "1980-01-01" ), n = 0:1 ) df <- dplyr::select(df, -c("id", "pub_date")) df <- na.omit(df) e <- 1 h <- 2 result <- kk_nowcast(df, e, h = h, model = "Kishor-Koenig", method = "MLE") result
Print Method for Efficient Release Results
## S3 method for class 'lst_efficient' print(x, ...)## S3 method for class 'lst_efficient' print(x, ...)
x |
An object of class |
... |
Additional arguments (not used). |
The function returns the input x invisibly.
Other revision analysis:
diagnose(),
diagnose.revision_summary(),
get_first_efficient_release(),
get_revision_analysis(),
print.revision_summary(),
summary.lst_efficient(),
summary.revision_summary()
df <- get_nth_release( tsbox::ts_pc(dplyr::filter(reviser::gdp, id == "US")), n = 0:3 ) final_release <- get_nth_release( tsbox::ts_pc(dplyr::filter(reviser::gdp, id == "US")), n = 10 ) result <- get_first_efficient_release(df, final_release, significance = 0.05) print(result)df <- get_nth_release( tsbox::ts_pc(dplyr::filter(reviser::gdp, id == "US")), n = 0:3 ) final_release <- get_nth_release( tsbox::ts_pc(dplyr::filter(reviser::gdp, id == "US")), n = 10 ) result <- get_first_efficient_release(df, final_release, significance = 0.05) print(result)
Print Method for Revision Summary
## S3 method for class 'revision_summary' print(x, interpretation = TRUE, digits = 3, ...)## S3 method for class 'revision_summary' print(x, interpretation = TRUE, digits = 3, ...)
x |
An object of class |
interpretation |
Logical. If TRUE, provides interpretation of key statistics. Default is TRUE. |
digits |
Integer. Number of digits to display. Default is 3. |
... |
Additional arguments (not used). |
The function returns the input x invisibly.
Other revision analysis:
diagnose(),
diagnose.revision_summary(),
get_first_efficient_release(),
get_revision_analysis(),
print.lst_efficient(),
summary.lst_efficient(),
summary.revision_summary()
df <- dplyr::select( get_nth_release( na.omit( tsbox::ts_pc( dplyr::filter(reviser::gdp, id == "US") ) ), n = 0:3 ), -"pub_date" ) final_release <- dplyr::select( get_nth_release( na.omit( tsbox::ts_pc( dplyr::filter(reviser::gdp, id == "US") ) ), n = "latest" ), -"pub_date" ) results <- get_revision_analysis(df, final_release, degree = 1) print(results) # Print without interpretation print(results, interpretation = FALSE)df <- dplyr::select( get_nth_release( na.omit( tsbox::ts_pc( dplyr::filter(reviser::gdp, id == "US") ) ), n = 0:3 ), -"pub_date" ) final_release <- dplyr::select( get_nth_release( na.omit( tsbox::ts_pc( dplyr::filter(reviser::gdp, id == "US") ) ), n = "latest" ), -"pub_date" ) results <- get_revision_analysis(df, final_release, degree = 1) print(results) # Print without interpretation print(results, interpretation = FALSE)
Print method for objects of class tbl_pubdate. This method delegates
to the tibble print method, which will automatically call
tbl_sum.tbl_pubdate
to generate the custom header.
## S3 method for class 'tbl_pubdate' print(x, ...)## S3 method for class 'tbl_pubdate' print(x, ...)
x |
An object of class |
... |
Additional arguments passed to the next print method. |
The input x is returned invisibly.
Other helpers:
print.tbl_release(),
summary.tbl_pubdate(),
summary.tbl_release(),
tbl_sum.tbl_pubdate(),
tbl_sum.tbl_release(),
vintages_long(),
vintages_wide()
df <- dplyr::filter(reviser::gdp, id == "US") wide_data <- vintages_wide(df) print(wide_data$US)df <- dplyr::filter(reviser::gdp, id == "US") wide_data <- vintages_wide(df) print(wide_data$US)
Print method for objects of class tbl_release.
## S3 method for class 'tbl_release' print(x, ...)## S3 method for class 'tbl_release' print(x, ...)
x |
An object of class |
... |
Additional arguments passed to the next print method. |
The input x is returned invisibly.
Other helpers:
print.tbl_pubdate(),
summary.tbl_pubdate(),
summary.tbl_release(),
tbl_sum.tbl_pubdate(),
tbl_sum.tbl_release(),
vintages_long(),
vintages_wide()
df <- dplyr::filter(reviser::gdp, id == "US") release_data <- get_nth_release(df, n = 0:3) print(release_data)df <- dplyr::filter(reviser::gdp, id == "US") release_data <- get_nth_release(df, n = 0:3) print(release_data)
Print a compact summary of a fitted jvn_model, including convergence
status, information criteria, and parameter estimates.
## S3 method for class 'jvn_model' summary(object, ...)## S3 method for class 'jvn_model' summary(object, ...)
object |
An object of class |
... |
Unused; included for method compatibility. |
The input object, invisibly.
Other revision nowcasting:
jvn_nowcast(),
kk_nowcast(),
plot.jvn_model(),
plot.kk_model(),
print.jvn_model(),
print.kk_model(),
summary.kk_model()
gdp_growth <- dplyr::filter( tsbox::ts_pc(reviser::gdp), id == "EA", time >= min(pub_date), time <= as.Date("2020-01-01") ) gdp_growth <- tidyr::drop_na(gdp_growth) df <- get_nth_release(gdp_growth, n = 0:3) result <- jvn_nowcast( df = df, e = 4, ar_order = 2, h = 0, include_news = TRUE, include_noise = TRUE ) summary(result)gdp_growth <- dplyr::filter( tsbox::ts_pc(reviser::gdp), id == "EA", time >= min(pub_date), time <= as.Date("2020-01-01") ) gdp_growth <- tidyr::drop_na(gdp_growth) df <- get_nth_release(gdp_growth, n = 0:3) result <- jvn_nowcast( df = df, e = 4, ar_order = 2, h = 0, include_news = TRUE, include_noise = TRUE ) summary(result)
Computes and displays a summary of the results from a Kishor-Koenig (KK) model fit, including convergence status, information criteria, and parameter estimates.
## S3 method for class 'kk_model' summary(object, ...)## S3 method for class 'kk_model' summary(object, ...)
object |
An object of class |
... |
Additional arguments passed to or from other methods. |
The function returns the input object invisibly.
Other revision nowcasting:
jvn_nowcast(),
kk_nowcast(),
plot.jvn_model(),
plot.kk_model(),
print.jvn_model(),
print.kk_model(),
summary.jvn_model()
df <- get_nth_release( tsbox::ts_span( tsbox::ts_pc( dplyr::filter(reviser::gdp, id == "US") ), start = "1980-01-01" ), n = 0:1 ) df <- dplyr::select(df, -c("id", "pub_date")) df <- na.omit(df) e <- 1 h <- 2 result <- kk_nowcast(df, e, h = h, model = "Kishor-Koenig", method = "MLE") summary(result)df <- get_nth_release( tsbox::ts_span( tsbox::ts_pc( dplyr::filter(reviser::gdp, id == "US") ), start = "1980-01-01" ), n = 0:1 ) df <- dplyr::select(df, -c("id", "pub_date")) df <- na.omit(df) e <- 1 h <- 2 result <- kk_nowcast(df, e, h = h, model = "Kishor-Koenig", method = "MLE") summary(result)
Provides a detailed summary of the regression model and hypothesis test for
the first efficient release identified by the
get_first_efficient_release() function.
## S3 method for class 'lst_efficient' summary(object, ...)## S3 method for class 'lst_efficient' summary(object, ...)
object |
An output object from the
|
... |
Additional arguments (not used). |
This function prints the following information:
The index of the first efficient release.
A summary of the regression model fitted for the efficient release, which includes coefficients, R-squared values, and other relevant statistics.
The hypothesis test results for the efficient release, showing the test statistic and p-value for the null hypothesis of unbiasedness and efficiency.
The function assumes the object includes:
e: The index of the first efficient release (0-based).
models: A list of linear regression models for each release.
tests: A list of hypothesis test results corresponding to each release.
Returns a tibble with the following columns:
id: The identifier of the time series (if present in input data).
e: The index of the first efficient release.
alpha: The intercept coefficient of the regression model.
beta: The coefficient of the slope.
p-value: The p-value for the joint hypothesis (alpha = 0 and beta = 1).
n_tested: The number of releases tested.
Other revision analysis:
diagnose(),
diagnose.revision_summary(),
get_first_efficient_release(),
get_revision_analysis(),
print.lst_efficient(),
print.revision_summary(),
summary.revision_summary()
# Example usage df <- get_nth_release( tsbox::ts_pc(dplyr::filter(reviser::gdp, id == "US")), n = 1:4 ) final_release <- get_nth_release( tsbox::ts_pc(dplyr::filter(reviser::gdp, id == "US")), n = 10 ) # Identify the first efficient release result <- get_first_efficient_release(df, final_release, significance = 0.05) summary(result)# Example usage df <- get_nth_release( tsbox::ts_pc(dplyr::filter(reviser::gdp, id == "US")), n = 1:4 ) final_release <- get_nth_release( tsbox::ts_pc(dplyr::filter(reviser::gdp, id == "US")), n = 10 ) # Identify the first efficient release result <- get_first_efficient_release(df, final_release, significance = 0.05) summary(result)
Summary Method for Revision Summary
## S3 method for class 'revision_summary' summary(object, interpretation = TRUE, ...)## S3 method for class 'revision_summary' summary(object, interpretation = TRUE, ...)
object |
An object of class |
interpretation |
Logical. If TRUE, provides interpretation of key statistics. Default is TRUE. |
... |
Additional arguments passed to print. |
The function returns the input object invisibly.
Other revision analysis:
diagnose(),
diagnose.revision_summary(),
get_first_efficient_release(),
get_revision_analysis(),
print.lst_efficient(),
print.revision_summary(),
summary.lst_efficient()
# Example usage with revision analysis results df <- dplyr::select( get_nth_release( na.omit( tsbox::ts_pc( dplyr::filter(reviser::gdp, id == "US") ) ), n = 0:3 ), -"pub_date" ) final_release <- dplyr::select( get_nth_release( na.omit( tsbox::ts_pc( dplyr::filter(reviser::gdp, id == "US") ) ), n = "latest" ), -"pub_date" ) # Get revision analysis results results <- get_revision_analysis(df, final_release, degree = 5) # Summarize revision quality summary(results)# Example usage with revision analysis results df <- dplyr::select( get_nth_release( na.omit( tsbox::ts_pc( dplyr::filter(reviser::gdp, id == "US") ) ), n = 0:3 ), -"pub_date" ) final_release <- dplyr::select( get_nth_release( na.omit( tsbox::ts_pc( dplyr::filter(reviser::gdp, id == "US") ) ), n = "latest" ), -"pub_date" ) # Get revision analysis results results <- get_revision_analysis(df, final_release, degree = 5) # Summarize revision quality summary(results)
Summary Method for Publication Date Vintages
## S3 method for class 'tbl_pubdate' summary(object, ...)## S3 method for class 'tbl_pubdate' summary(object, ...)
object |
An object of class |
... |
Additional arguments (not used). |
The function returns a summary tibble invisibly.
Other helpers:
print.tbl_pubdate(),
print.tbl_release(),
summary.tbl_release(),
tbl_sum.tbl_pubdate(),
tbl_sum.tbl_release(),
vintages_long(),
vintages_wide()
df <- dplyr::filter(reviser::gdp, id == "US") wide_data <- vintages_wide(df) summary(wide_data$US)df <- dplyr::filter(reviser::gdp, id == "US") wide_data <- vintages_wide(df) summary(wide_data$US)
Summary Method for Release Vintages
## S3 method for class 'tbl_release' summary(object, ...)## S3 method for class 'tbl_release' summary(object, ...)
object |
An object of class |
... |
Additional arguments (not used). |
The function returns a summary tibble invisibly.
Other helpers:
print.tbl_pubdate(),
print.tbl_release(),
summary.tbl_pubdate(),
tbl_sum.tbl_pubdate(),
tbl_sum.tbl_release(),
vintages_long(),
vintages_wide()
df <- dplyr::filter(reviser::gdp, id == "US") # Long format release_data <- get_nth_release(df, n = 0:3) summary(release_data) # Wide format wide_release <- vintages_wide(release_data, names_from = "release") summary(wide_release$US)df <- dplyr::filter(reviser::gdp, id == "US") # Long format release_data <- get_nth_release(df, n = 0:3) summary(release_data) # Wide format wide_release <- vintages_wide(release_data, names_from = "release") summary(wide_release$US)
Provides a custom header for objects of class tbl_pubdate when
printed.
This method is called automatically by pillar when printing tibbles.
## S3 method for class 'tbl_pubdate' tbl_sum(x, ...)## S3 method for class 'tbl_pubdate' tbl_sum(x, ...)
x |
An object of class |
... |
Additional arguments (unused). |
A named character vector where names are labels and values are the corresponding information. The vector is used by pillar to format the tibble header.
Other helpers:
print.tbl_pubdate(),
print.tbl_release(),
summary.tbl_pubdate(),
summary.tbl_release(),
tbl_sum.tbl_release(),
vintages_long(),
vintages_wide()
df <- dplyr::filter(reviser::gdp, id == "US") wide_data <- vintages_wide(df) pillar::tbl_sum(wide_data$US)df <- dplyr::filter(reviser::gdp, id == "US") wide_data <- vintages_wide(df) pillar::tbl_sum(wide_data$US)
Provides a custom header for objects of class tbl_release when
printed.
## S3 method for class 'tbl_release' tbl_sum(x, ...)## S3 method for class 'tbl_release' tbl_sum(x, ...)
x |
An object of class |
... |
Additional arguments (unused). |
A named character vector where names are labels and values are the corresponding information.
Other helpers:
print.tbl_pubdate(),
print.tbl_release(),
summary.tbl_pubdate(),
summary.tbl_release(),
tbl_sum.tbl_pubdate(),
vintages_long(),
vintages_wide()
df <- dplyr::filter(reviser::gdp, id == "US") release_data <- get_nth_release(df, n = 0:3) pillar::tbl_sum(release_data)df <- dplyr::filter(reviser::gdp, id == "US") release_data <- get_nth_release(df, n = 0:3) pillar::tbl_sum(release_data)
These functions provide a custom visualization theme and color scales for
use with ggplot2, inspired by the tsbox package.
theme_reviser( base_size = 12, legend.position = "bottom", legend.direction = "horizontal" ) colors_reviser() scale_color_reviser(...) scale_fill_reviser(...)theme_reviser( base_size = 12, legend.position = "bottom", legend.direction = "horizontal" ) colors_reviser() scale_color_reviser(...) scale_fill_reviser(...)
base_size |
Numeric. The base font size for the theme. Default is 12. |
legend.position |
Character. Position of the legend. Default is "bottom". |
legend.direction |
Character. Direction of the legend. Default is "horizontal". |
... |
Additional arguments passed to the ggplot2 scale functions. |
theme_reviser: Defines a minimal theme with custom adjustments for
axis titles, plot titles, subtitles, captions, and legend positioning.
colors_reviser: Provides a predefined set of colors, including a
soft black, a palette suitable for colorblind readers, and additional
colors for extended use.
scale_color_reviser: A ggplot2 color scale that uses the custom
colors_reviser palette.
scale_fill_reviser: A ggplot2 fill scale that uses the custom
colors_reviser palette.
A customized ggplot2 theme, color palette, or scale.
Other revision graphs:
plot.tbl_pubdate(),
plot.tbl_release(),
plot_vintages()
Other revision graphs:
plot.tbl_pubdate(),
plot.tbl_release(),
plot_vintages()
Other revision graphs:
plot.tbl_pubdate(),
plot.tbl_release(),
plot_vintages()
Other revision graphs:
plot.tbl_pubdate(),
plot.tbl_release(),
plot_vintages()
library(ggplot2) ggplot(mtcars, aes(x = wt, y = mpg, color = factor(cyl))) + geom_point(size = 3) + theme_reviser() + scale_color_reviser()library(ggplot2) ggplot(mtcars, aes(x = wt, y = mpg, color = factor(cyl))) + geom_point(size = 3) + theme_reviser() + scale_color_reviser()
Converts a vintages dataset from wide format to long format, optionally
adding id if the input is a list of data frames. The long format contains
one row per combination of time and names_to (e.g., pub_date or
release), with values stored in a single value column.
vintages_long(df, names_to = "pub_date", keep_na = FALSE)vintages_long(df, names_to = "pub_date", keep_na = FALSE)
df |
A data frame, tibble, or list of data frames containing vintages data in wide format. |
names_to |
The name of the column to create from the wide-format
column names. Must be either |
keep_na |
Logical. If |
A long-format data frame or tibble. If the input is a list of wide-format data frames, the output will be a single combined long-format data frame.
Other helpers:
print.tbl_pubdate(),
print.tbl_release(),
summary.tbl_pubdate(),
summary.tbl_release(),
tbl_sum.tbl_pubdate(),
tbl_sum.tbl_release(),
vintages_wide()
# Example wide-format data long_data <- dplyr::filter(reviser::gdp, id == "US") # Convert to wide format wide_data <- vintages_wide(long_data) # Example list of wide-format data frames wide_list <- list( A = wide_data$US, B = wide_data$US ) # Convert list to long format long_data <- vintages_long(wide_list, names_to = "pub_date")# Example wide-format data long_data <- dplyr::filter(reviser::gdp, id == "US") # Convert to wide format wide_data <- vintages_wide(long_data) # Example list of wide-format data frames wide_list <- list( A = wide_data$US, B = wide_data$US ) # Convert list to long format long_data <- vintages_long(wide_list, names_to = "pub_date")
Converts a vintages dataset from long format to wide format, optionally
grouping by id if present. The wide format uses one column per unique
value of the names_from parameter, with observation dates (time) as
rows and values (value) as cell contents.
vintages_wide(df, names_from = "pub_date")vintages_wide(df, names_from = "pub_date")
df |
A data frame or tibble containing vintages data in long format. |
names_from |
The name of the column whose unique values will be used
as column names in the wide format. Defaults to |
If an id column is present, the function returns a named list of
wide-format data frames, one for each unique id. Otherwise, it returns a
single wide-format data frame.
Other helpers:
print.tbl_pubdate(),
print.tbl_release(),
summary.tbl_pubdate(),
summary.tbl_release(),
tbl_sum.tbl_pubdate(),
tbl_sum.tbl_release(),
vintages_long()
# Example wide-format data long_data <- dplyr::filter(reviser::gdp, id == "US") # Convert to wide format wide_data <- vintages_wide(long_data) # Example list of wide-format data frames wide_list <- list( A = wide_data$US, B = wide_data$US ) # Convert list to long format long_data1 <- vintages_long(wide_data, names_to = "pub_date") long_data2 <- vintages_long(wide_list, names_to = "pub_date")# Example wide-format data long_data <- dplyr::filter(reviser::gdp, id == "US") # Convert to wide format wide_data <- vintages_wide(long_data) # Example list of wide-format data frames wide_list <- list( A = wide_data$US, B = wide_data$US ) # Convert list to long format long_data1 <- vintages_long(wide_data, names_to = "pub_date") long_data2 <- vintages_long(wide_list, names_to = "pub_date")