Skip to content

Commit

Permalink
Drop strata report sections
Browse files Browse the repository at this point in the history
  • Loading branch information
dfsnow committed Feb 5, 2025
1 parent 4171940 commit e099f00
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 214 deletions.
5 changes: 2 additions & 3 deletions pipeline/02-assess.R
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ assessment_data_merged %>%
select(
meta_year, meta_pin, meta_class, meta_card_num, meta_lline_num,
meta_modeling_group, ends_with("_num_sale"), pred_card_initial_fmv,
all_of(params$model$predictor$all),
flag_strata_is_imputed, township_code
all_of(params$model$predictor$all), township_code
) %>%
mutate(
ccao_n_years_exe_homeowner = as.integer(ccao_n_years_exe_homeowner)
Expand Down Expand Up @@ -273,7 +272,7 @@ assessment_data_pin <- assessment_data_merged %>%
meta_nbhd_code, meta_tax_code, meta_class, meta_tieback_key_pin,
meta_tieback_proration_rate, meta_cdu, meta_modeling_group,
meta_pin_num_landlines, meta_strata_1, meta_strata_2,
flag_strata_is_imputed, char_yrblt,
char_yrblt,

# Keep overall building square footage
char_total_bldg_sf = char_building_sf,
Expand Down
211 changes: 0 additions & 211 deletions reports/performance/_outcomes.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -388,214 +388,3 @@ stats_median_yoy_delta %>%
c("Comparison of YOY Change in AV for Sold and Unsold Houses" = 7)
)
```

## Strata

::: panel-tabset

```{r _outcomes_imputed_cleaning}
outcomes_strata <- assessment_pin %>%
filter(!flag_nonlivable_space) %>%
select(
meta_pin,
meta_strata_1,
pred_pin_final_fmv,
sale_recent_1_price,
township = meta_township_code,
imputed = flag_strata_is_imputed,
flag_nonlivable_space
) %>%
mutate(
meta_strata_1 = as.numeric(meta_strata_1),
township = ccao::town_convert(township)
)
```

### Estimated Final FMV (PIN)

```{r _outcomes_estimated_fmv_imputed, warning=FALSE}
outcomes_strata %>%
ggplot(aes(
x = factor(meta_strata_1),
y = pred_pin_final_fmv,
fill = imputed
)) +
geom_boxplot() +
scale_y_continuous(
limits = c(0, 2000000),
labels = scales::dollar_format(scale = 1 / 1000, suffix = "K")
) +
labs(
x = "Strata",
y = "Estimated Final FMV (PIN)",
fill = "Imputation Status"
) +
theme_minimal() +
theme(legend.position = "bottom")
```

### Sale Prices

```{r _outcomes_sale_prices, warning=FALSE}
outcomes_strata %>%
ggplot(
aes(x = factor(meta_strata_1), y = sale_recent_1_price, fill = imputed)
) +
geom_boxplot() +
scale_y_continuous(limits = c(0, 2000000), labels = scales::dollar_format()) +
labs(
x = "Strata",
y = "FMV",
fill = "Imputation Status"
) +
theme_minimal() +
theme(legend.position = "top")
```

### Descriptive Stats

```{r _outcomes_descriptive_stats}
outcomes_strata_descriptive <- outcomes_strata %>%
group_by(meta_strata_1) %>%
summarize(
`Est. Min.` = min(pred_pin_final_fmv, na.rm = TRUE),
`Est. Mean` = mean(pred_pin_final_fmv, na.rm = TRUE),
`Est. Med.` = median(pred_pin_final_fmv, na.rm = TRUE),
`Est. Max.` = max(pred_pin_final_fmv, na.rm = TRUE),
`Sale Min.` = min(sale_recent_1_price, na.rm = TRUE),
`Sale Mean` = mean(sale_recent_1_price, na.rm = TRUE),
`Sale Med.` = median(sale_recent_1_price, na.rm = TRUE),
`Sale Max.` = max(sale_recent_1_price, na.rm = TRUE)
) %>%
rename(`Strata 1` = meta_strata_1) %>%
mutate(across(`Est. Min.`:`Sale Max.`, ~ dollar(round(.x, 2))))
datatable(
outcomes_strata_descriptive,
options = list(pageLength = 20, autoWidth = TRUE, scrollX = TRUE)
)
```

### Descriptive Stats by Imputation Status

```{r _outcomes_descriptive_stats_imputed}
outcomes_strata_descriptive_imp <- outcomes_strata %>%
group_by(meta_strata_1, imputed) %>%
summarize(
`Est. Min.` = min(pred_pin_final_fmv, na.rm = TRUE),
`Est. Mean` = mean(pred_pin_final_fmv, na.rm = TRUE),
`Est. Med.` = median(pred_pin_final_fmv, na.rm = TRUE),
`Est. Max.` = max(pred_pin_final_fmv, na.rm = TRUE),
`Sale Min.` = min(sale_recent_1_price, na.rm = TRUE),
`Sale Mean` = mean(sale_recent_1_price, na.rm = TRUE),
`Sale Med.` = median(sale_recent_1_price, na.rm = TRUE),
`Sale Max.` = max(sale_recent_1_price, na.rm = TRUE)
) %>%
rename(`Strata 1` = meta_strata_1, Imputed = imputed) %>%
mutate(across(`Est. Min.`:`Sale Max.`, ~ dollar(round(.x, 2))))
datatable(
outcomes_strata_descriptive_imp,
options = list(pageLength = 20, autoWidth = TRUE, scrollX = TRUE)
)
```

:::

## Strata Sale Prices vs Mailed Values

::: panel-tabset

```{r _outcomes_strata_plots}
outcomes_strata_groups <- outcomes_strata %>%
filter(!is.na(sale_recent_1_price)) %>%
split(.$meta_strata_1)
outcomes_strata_plots <- map(outcomes_strata_groups, ~ {
p <- ggplot(.x, aes(
x = pred_pin_final_fmv, y = sale_recent_1_price,
color = township,
text = paste(
"PIN:", meta_pin,
"<br>Sale Price:", dollar(sale_recent_1_price),
"<br>Assessed Value:", dollar(pred_pin_final_fmv),
"<br>Township:", township,
"<br>Imputed:", imputed
)
)) +
geom_point(aes(shape = imputed)) +
labs(
x = "FMV",
y = "Sale Price",
title = paste("Strata", unique(.x$meta_strata_1)),
color = "Township"
) +
scale_x_continuous(limits = c(0, 2000000), labels = dollar) +
scale_y_continuous(limits = c(0, 2000000), labels = dollar) +
theme_minimal()
ggplotly(p, tooltip = "text")
})
```

### Strata 1

```{r results='asis'}
outcomes_strata_plots$`1`
```

### Strata 2

```{r results='asis'}
outcomes_strata_plots$`2`
```

### Strata 3

```{r results='asis'}
outcomes_strata_plots$`3`
```

### Strata 4

```{r results='asis'}
outcomes_strata_plots$`4`
```

### Strata 5

```{r results='asis'}
outcomes_strata_plots$`5`
```

### Strata 6

```{r results='asis'}
outcomes_strata_plots$`6`
```

### Strata 7

```{r results='asis'}
outcomes_strata_plots$`7`
```

### Strata 8

```{r results='asis'}
outcomes_strata_plots$`8`
```

### Strata 9

```{r results='asis'}
outcomes_strata_plots$`9`
```

### Strata 10

```{r results='asis'}
outcomes_strata_plots$`10`
```

:::

0 comments on commit e099f00

Please sign in to comment.