knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(REPS) data("data_constraxion")
The calculate_regression_diagnostics() function in REPS provides regression diagnostics by period. It is designed for panel or repeated cross-section data (e.g. property transactions over time) to evaluate the quality of period-specific log-linear regressions.
For each period, it:
log(price) ~ covariatesThese diagnostics help assess model quality over time, identifying periods with issues like non-normality, low fit, heteroscedasticity, or autocorrelation.
Your dataset should include:
# Example dataset (you should already have this loaded) head(data_constraxion) # We log transform the floor_area again (see vignette on calculating price index as why) dataset <- data_constraxion dataset$floor_area <- log(dataset$floor_area)
calculate_regression_diagnostics()Example:
diagnostics <- calculate_regression_diagnostics( dataset = dataset, period_variable = "period", dependent_variable = "price", numerical_variables = c("floor_area", "dist_trainstation"), categorical_variables = c("dummy_large_city", "neighbourhood_code") ) head(diagnostics)
For convenient visualization:
plot_regression_diagnostics(diagnostics)
This generates a 3x2 grid of plots:
Example:
knitr::include_graphics("diagnostics_plot.png")
The hedonic price index relies on a log-linear regression model, which assumes that certain statistical conditions hold. The diagnostics plot provides an overview of how well these assumptions are met across different periods.
Each subplot corresponds to a specific model assumption:
A p-value below 0.05 (dashed red line) indicates a potential violation of the normality assumption.
Adjusted R-squared (right plot)
Values outside the 1.75–2.25 range (dashed lines) suggest potential autocorrelation.
Durbin-Watson p-value (right plot)
The calculate_regression_diagnostics() and plot_regression_diagnostics() functions in REPS enable:
They support robust, high-quality hedonic price index modeling by systematically checking regression assumptions.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.