adibender / coalitions

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

`pool_surveys()` problem with two Forsa polls published on one day #58

Closed bauer-alex closed 6 years ago

bauer-alex commented 6 years ago

Pooled shares don't sum to 100%:

> dat <- get_surveys()
There were 14 warnings (use warnings() to see them)
> dat
# A tibble: 7 x 2
    pollster            surveys
       <chr>             <list>
1 allensbach  <tibble [39 x 5]>
2      emnid <tibble [213 x 5]>
3      forsa <tibble [219 x 5]>
4        fgw  <tibble [79 x 5]>
5        gms  <tibble [94 x 5]>
6  infratest <tibble [102 x 5]>
7       insa <tibble [291 x 5]>
> pool_surveys(dat, last_date = as.Date("2017-11-21"))
# A tibble: 7 x 8
  pollster       date      start        end respondents  party   percent     votes
     <chr>     <date>     <date>     <date>       <dbl>  <chr>     <dbl>     <dbl>
1   pooled 2017-11-21 2017-11-17 2017-11-21    2942.704    afd 20.602092  606.2587
2   pooled 2017-11-21 2017-11-17 2017-11-21    2942.704    cdu 51.859722 1526.0784
3   pooled 2017-11-21 2017-11-17 2017-11-21    2942.704    fdp 17.359794  510.8474
4   pooled 2017-11-21 2017-11-17 2017-11-21    2942.704 greens 18.002364  529.7564
5   pooled 2017-11-21 2017-11-17 2017-11-21    2942.704   left 15.652744  460.6140
6   pooled 2017-11-21 2017-11-17 2017-11-21    2942.704 others  7.038114  207.1109
7   pooled 2017-11-21 2017-11-17 2017-11-21    2942.704    spd 34.422840 1012.9624
bauer-alex commented 6 years ago

Error is located in coalitions:::get_eligible(). You probably just have to add a filter(row_number() == 1) at the end of the function, s.t. the second Forsa poll is dropped