Description Usage Arguments Examples
Rolling Average Iterative Gaussian Bayesian Model
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | gaussianrollingaverageiterative(
poll_data,
stateloc,
proploc,
candidateloc,
npolls = 10,
varloc = NULL,
nloc,
invgamma = F,
v0 = NULL,
a0 = NULL,
b0 = NULL,
election_data,
cutoffs = c(-0.2, -0.1, -0.025, 0.025, 0.1, 0.2),
groupnames = c("Strong Red", "Red", "Lean Red", "Competitive", "Lean Blue", "Blue",
"Strong Blue")
)
|
poll_data |
|
stateloc |
|
proploc |
|
candidateloc |
|
npolls |
|
varloc |
|
nloc |
|
invgamma |
|
v0 |
|
a0 |
|
b0 |
|
election_data |
|
cutoffs |
|
groupnames |
1 2 3 4 5 6 7 8 9 10 11 12 | require(politicaldata)
elect2008 = subset(pres_results , year == 2008)
elect2008$margin = elect2008$dem - elect2008$rep
elect2012 = subset(pres_results , year == 2012)
elect2012$margin = elect2012$dem - elect2012$rep
electdata = data.frame("state" = elect2008$state, "2008" = elect2008$margin, "2012" = elect2012$margin)
data(polls2016)
polls = polls2016[ complete.cases(polls2016[, c(2, 3, 12)]), ]
head(polls)
nloc = which(colnames(polls2016) == "observations")
stateloc = which(colnames(polls) == "State")
gaussianrollingaverage(polls, stateloc = stateloc, proploc = c(2,3), 3, nloc = nloc, election_data = electdata)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.