Block 4: Prediction over time: a moving average

Week 7 · Prediction I · Imai §4.1.3 · about 4 min

NoteHow this works

Run each cell with Run Code, look at the output, then answer the question at the end of the block. Every cell is editable; Start Over resets it. Errors are information: read them.

pollsUS08: national polls. For each of the last 90 days, we average the polls conducted in the preceding 7 days (a moving average). The data are loaded in the background.

The moving average

Read the loop: what does week.data contain in iteration i = 1? In iteration i = 90?

Conclusion: What is the shape of the Obama and McCain lines as Election Day approaches?
Obama's poll average climbs from about 44.5 to 51, close to his actual 52.9%; McCain rises slowly from 41 to 44, near his actual 45.7%. Polls converge toward the result as the election approaches.