Last active
September 29, 2019 20:33
-
-
Save diamonaj/a53ca24522a71d94eb1acdde882cf472 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| storagedf_16 <- matrix(NA, nrow = 100, ncol = 78) # for ages 18:95, thus 78 | |
| for(age in c(18:95)) { | |
| for(i in 1:100) | |
| { | |
| beta <- sum(simulations@coef[i,]*(c(1, mean_white, age, 16, mean_income, age^2*0.01, ))) | |
| storagedf_16[i, age - 17] <- exp(beta)/(1 + exp(beta)) # for a given age, we iterate thru | |
| # the simulated coefficients. The | |
| # first column represents all the | |
| # expected values for age = 18 years old. | |
| # The second column, all expected values | |
| # for age = 19 years old, etc. | |
| } | |
| } | |
| # Let's apply the quantile function to each column. Remember, quantile() calculates the conf interval. | |
| conf.intervals <- apply(storagedf_16, 2, quantile, probs = c(0.005, 0.995)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment