Description Usage Arguments Examples
Title
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | margingaussianmodelprop(
poll_data,
stateloc,
marginloc,
nloc,
proploc = NULL,
npolls = NULL,
dateloc = NULL,
normalize = F,
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 |
|
marginloc |
|
npolls |
the number of polls to include, default is all polls |
dateloc |
the location of the date used to determine the last npolls |
normalize |
whether or not to normalize poll date before margin is calculated |
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)]), ]
stateloc = which(colnames(polls) == "State")
polls2016$margin = polls2016$Trump - polls2016$Clinton
marginloc = which(colnames(polls2016) == "margin")
margingaussianmodelprop(polls2016, stateloc = stateloc, marginloc = marginloc, election_data = electdata)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.