Skip to contents

Makes a bivariate graph to visualize the data and relationship between the outcome and the variable of interest, after having partialLed out controls.

Usage

idid_viz_bivar(reg, var_interest)

Arguments

reg

A regression object.

var_interest

A string. The name of the main variable of interest.

Value

A ggplot2 scatter plot and regression line of the relationship between the outcome and the variable of interest, after partialling out controls.

Examples

reg_few_ctrl <- ggplot2::txhousing |>
  lm(formula = log(sales) ~ median)

idid_viz_bivar(reg_few_ctrl, "median")
#> Warning: Removed 617 rows containing non-finite outside the scale range
#> (`stat_smooth()`).
#> Warning: Removed 617 rows containing missing values or values outside the scale range
#> (`geom_point()`).


reg_more_ctrl <- ggplot2::txhousing |>
  lm(formula = log(sales) ~ median + listings + city + as.factor(date))

idid_viz_bivar(reg_more_ctrl, "median")
#> Warning: Removed 1434 rows containing non-finite outside the scale range
#> (`stat_smooth()`).
#> Warning: Removed 1434 rows containing missing values or values outside the scale range
#> (`geom_point()`).