Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace point pred with bootstrap mean #102

Merged
Merged
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions src/elexmodel/models/BootstrapElectionModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,6 @@ def compute_bootstrap_errors(
z_test_pred = (ols_z.predict(x_test) + (aggregate_indicator_test @ epsilon_z_hat)).clip(
min=z_partial_reporting_lower, max=z_partial_reporting_upper
)
yz_test_pred = y_test_pred * z_test_pred

# we now need to generate our bootstrapped "true" quantities (in order to subtract the
# bootstrapped estimates from these quantities to get an estimate for our error)
Expand Down Expand Up @@ -1017,10 +1016,11 @@ def compute_bootstrap_errors(
min=z_partial_reporting_lower, max=z_partial_reporting_upper
) * weights_test

# the point prediction is the bootstrap sample mean
# this is for the unit point prediction. turn into unnormalized margin
self.weighted_yz_test_pred = yz_test_pred * weights_test
self.weighted_yz_test_pred = yz_test_pred_B.mean(axis=1).reshape(-1, 1) * weights_test
# and turn into turnout estimate
self.weighted_z_test_pred = z_test_pred * weights_test
self.weighted_z_test_pred = z_test_pred_B.mean(axis=1).reshape(-1, 1) * weights_test
self.ran_bootstrap = True

def get_unit_predictions(
Expand Down
Loading