adibender / coalitions

Coalition probabilities in multi-party democracies
https://adibender.github.io/coalitions/
Other
21 stars 4 forks source link

pool_surveys() not pooling properly #125

Closed hmeleiro closed 4 years ago

hmeleiro commented 4 years ago

Hello, I'm not sure if I'm doing everything correctly, but I'm having trouble pooling some surveys.

The thing is that the pooled percent is not a percent but a large number. Here is a minimal reproducible example.

df <- tibble(pollster = c("poll1", "poll2"),
             date = as.Date(c("2019-05-14", "2019-05-13")),
             respondents = c(1000, 5000),
             party = c("PSOE", "PSOE"),
             percent = c(27.1, 28.3),
             votes = c(7203000, 7405004))

surveys <- nest(df, survey = c(party, percent, votes))
surveys <- nest(surveys, surveys = c(date, respondents, survey))

x <- pool_surveys(surveys, pollsters = c("poll1", "poll2"), last_date = as.Date("2019-05-15"), period = 14, period_extended = 20)

x$percent

x$percent [1] 243466.7

Am I doing something wrong?

Thanks for the package.

adibender commented 4 years ago

thanks for reporting, we will have a look (@bauer-alex ). Number of votes doesn't seem reasonable though, especially given the number of respondents. Votes should be percent/100 * respondents

hmeleiro commented 4 years ago

Ok, that's it. I thought the variable votes should be number of votes over the total population. Doing it the way you explain gives the correct pool mean.

Thanks.

adibender commented 4 years ago

I'll reopen this because this should either be documented properly or checked during the function call