Description Usage Arguments Value Author(s) References Examples
This function provides cantonal estimates of public support based on the MrP procedure. Specifically: this function caries out the third (prediction) and forth step (post-stratification) of MrP.
1 2 |
response.model |
The output object of |
augment.data |
In case one uses survey data for the generation of |
augment.row |
Integer, between 1 and 26. Indicates the row or rows where the |
uncertainty |
Logical. If |
Number.sim |
Integer. Number of simulations to be run for uncertainty measure. Default is set to 1000. |
region |
Vector. The regional grouping is based on the large regions in Switzerland (see Leemann and Wasserfallen, 2013). But for certain questions and models alternative groupings could be beneficial. The user can supply a vector (length 26) with integers from 1 to the maximal number of distict regions whereas the first element indicates the regional group of ZH, the second element implies the regional group of BE, ... etc. (it is the standard order of cantons used by the Federal Statistics Office.) |
Creates an object of class swissMrP
. A list where the first element is a vector of length 26 (an estimate for each of the 26 cantons).
Lucas Leemann lleemann@gmail.com
Gelman, Andrew and Thomas C. Little. 1997. Poststratification Into Many Categories Using Hierarchical Logistic Regression. Survey Research 23:127-135.
Jeffrey Lax and Justin Phillips. 2009. How Should We Estimate Public Opinion in The States? American Journal of Political Science 53 (1), 107-121.
Leemann, Lucas and Fabio Wasserfallen. 2016. The Democratic Effect of Direct Democracy. American Political Science Review 110(4): 750-762.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | library(lme4)
### Fake data
err.ind <- rnorm(1000,sd=4)
woman <- sample(c(0,1),replace=TRUE,size=1000)
age <- sample(c(1:4),replace=TRUE,size=1000)
education <- sample(c(1:6),replace=TRUE,size=1000)
cantonnr <- sample(c(1:26),replace=TRUE,size=1000)
region <- sample(c(1:7),replace=TRUE,size=1000)
x <- cbind(rnorm(26),rnorm(26)); err.con <- rnorm(26,sd=4); X <- matrix(NA,1000,2)
for (q in 1:1000){ X[q,] <- c(x[cantonnr[q]],err.con[cantonnr[q]])}
y.fake <- X[,1] +X[,2] + woman+age+education+cantonnr+region + err.ind
y <- rep(0,length(y.fake))
y[y.fake>mean(y.fake)]<-1
model1 <- glmer(y ~ X[,1] +X[,2] + (1|woman) + (1|education) + (1|age) + (1|cantonnr)
+ (1|region), family=binomial(probit))
# use the MrP function
mrp1 <- swissMrP(model1)
## Here is an example if two cantons (10,22; FR & VD) are missing
mrp2 <- swissMrP(model1,
augment.data=matrix(c(c(1,2,-1),c(1,1,-5)),2,3, byrow=TRUE),
augment.row=c(10,22))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.