Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions vignettes/example-ratio-study.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,30 @@ library(dplyr)
library(jsonlite)
library(stringr)

# Load 100k rows of 2020 residential (major class 2) assessment data
# Load 100k rows of 2022 residential (major class 2) assessment data
assessments <- read_json(
paste0(
"https://datacatalog.cookcountyil.gov/resource/uzyt-m557.json?",
"$where=starts_with(class,'2')&tax_year=2020&$limit=100000"
"$where=starts_with(class,'2')&tax_year=2022&$limit=100000"
),
simplifyVector = TRUE
)
) %>%
# read_json removes leading zeroes, add them back
mutate(pin = str_pad(pin, 14, "left", "0"))

# Load 100k rows of 2020 sales data
# Load 100k rows of 2022 sales data
sales <- read_json(
paste0(
URLencode(paste0(
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I had to use URLencode() here since sending a > sign really pisses off the socrata API.

"https://datacatalog.cookcountyil.gov/resource/wvhk-k5uv.json?",
"year=2020&$limit=100000"
),
"year=2022 and sale_price>=10000&$limit=100000"
)),
simplifyVector = TRUE
) %>%
# read_json removes leading zeroes, add them back
mutate(pin = str_pad(pin, 14, "left", "0"))
mutate(
pin = str_pad(pin, 14, "left", "0"),
year = as.character(as.integer(year))
)
```

### CSV or Excel
Expand Down Expand Up @@ -252,7 +257,7 @@ ggplot(graph_data) +
scale_y_continuous(labels = function(x) paste0(x * 100, "%")) +
labs(
title = "Median Sale Ratios: Open Data Sample",
subtitle = "By decile of sale price in 2020",
subtitle = "By decile of sale price in 2022",
x = "Price Decile Range",
y = "Sale Ratio"
) +
Expand Down Expand Up @@ -357,7 +362,7 @@ MKI <- round(gini_assessed / gini_sale, 4)
KI <- round(gini_assessed - gini_sale, 4)
```

The output for the Modified Kakwani Index is `r MKI`, and the Kakwani Index is `r KI`. According to the following table, this means that the assessments are slightly regressive.
The output for the Modified Kakwani Index is `r MKI`, and the Kakwani Index is `r KI`. According to the following table, this means that the assessments are slightly regressive.

| KI Range | MKI Range | Interpretation |
|:-------------------|:-------------------|:-------------------|
Expand Down