Skip to content

Use worst case method for MKI / KI#19

Merged
Damonamajor merged 12 commits intomasterfrom
Use-worst-case-method-for-MKI-/-KI
Sep 16, 2025
Merged

Use worst case method for MKI / KI#19
Damonamajor merged 12 commits intomasterfrom
Use-worst-case-method-for-MKI-/-KI

Conversation

@Damonamajor
Copy link
Copy Markdown
Contributor

@Damonamajor Damonamajor commented Sep 3, 2025

This uses the worst case method for MKI / KI to ensure stability across different runs. This ordered by ascending sale price followed by decreasing assessed value.

Connects ccao-data/assesspy#33.

@Damonamajor Damonamajor self-assigned this Sep 3, 2025
@Damonamajor Damonamajor marked this pull request as ready for review September 3, 2025 20:08
@Damonamajor Damonamajor requested a review from a team as a code owner September 3, 2025 20:08
Copy link
Copy Markdown
Member

@jeancochrane jeancochrane left a comment

Choose a reason for hiding this comment

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

Excellent 👍🏻

Comment thread R/formulas.R
calc_gini <- function(assessed, sale_price) {
df <- data.frame(av = assessed, sp = sale_price)
df <- df[order(df$sp), ]
df <- df[order(df$sp, -df$av), ]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[Suggestion, optional] I think we should add the same comment here as assesspy, to make sure it's clear in both places:

Suggested change
df <- df[order(df$sp, -df$av), ]
# This Gini coefficient algorithm is sensitive to the order of the input
# observations: If multiple observations share the same sale price but have
# different estimates, the output coefficients will be different depending
# on which of the sales with identical prices gets ordered first in the
# input dataframe. To ensure a stable sort order, Quintos recommends
# sorting by ascending sale price and then by descending estimate to break
# any ties. This produces "worst case" MKI/KI statistics, but ensures those
# statistics are deterministic. See this issue for more discussion:
# https://github.com/ccao-data/assesspy/issues/33#issuecomment-3180632954
df <- df[order(df$sp, -df$av), ]

@Damonamajor Damonamajor merged commit ba04058 into master Sep 16, 2025
9 checks passed
@Damonamajor Damonamajor deleted the Use-worst-case-method-for-MKI-/-KI branch September 16, 2025 14:26
Damonamajor added a commit that referenced this pull request Sep 16, 2025
@Damonamajor Damonamajor restored the Use-worst-case-method-for-MKI-/-KI branch September 16, 2025 14:28
@Damonamajor Damonamajor deleted the Use-worst-case-method-for-MKI-/-KI branch September 16, 2025 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants