Created
April 14, 2015 01:19
-
-
Save chrismeserole/3817d693153c5c688fb9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install devtools & obsval | |
install.packages("devtools") | |
library("devtools") | |
devtools::install_github("chrismeserole/obsval") | |
library("obsval") | |
# install secondary packages | |
install.packages("mvtnorm") | |
install.packages("nnet") | |
library(mvtnorm) | |
library(nnet) | |
# specify parameters | |
data <- studentVote | |
specification <- 'warsup~female' | |
reg_model <- "mlogit" | |
n_draws <- 1000 | |
effect_var <- 'female' | |
effect_var_high <- 1 | |
effect_var_low <- 0 | |
verbose <- TRUE | |
baseline_category <- "strongly oppose" | |
# run the model and calculate predicted probabilities | |
mymodel <- obsval( data, specification, reg_model, n_draws, | |
effect_var, effect_var_high, effect_var_low, | |
verbose, baseline_category ) | |
# get results | |
mean(mymodel$pp_effect[,'strongly oppose']) | |
quantile(mymodel$pp_effect[,'strongly oppose'], c(0.025, 0.975)) | |
# visualize results | |
plot(mymodel$pp_effect[,'strongly oppose']) | |
boxplot(mymodel$pp_effect[,'strongly oppose']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment