Ch.5
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
Data
====
1. nesYYYY_vote.data.R, where YYYY = 1952, 1956, ..., 1996, 2000
Data from the National Election Study
- N : number of observations
- vote : 1: George Bush, 0: Bill Clinton
- income: income percentile
1: 0-16th
2: 17-33rd
3: 34-67th
4: 68-95th
5: 96-100th
2. wells.data.R
Decisions of households in Bangladesh about wether to change their source of
drinking water.
- N : number of observations
- arsenic : the arsenic level of respondent's well in units of hundreds of
micrograms per liter
- assoc : 1 if any members of the household are active in community
organizations
- dist : the distance in meters to the closest known safe well
- educ : years of education of the head of household
- switched : 1 if household i switched to a new well
3. separation.data.R
An example of data for which a logistic regression model is nonidentifiable
- N : number of observations (60)
- x ~ N(mean = 1, sd = 2)
- y : 0 if x < 2, else 1
Models
======
Logistic regressions
1. One predictor
nes_logit.stan : glm(vote ~ income, family=binomial(link="logit"))
separation.stan : glm(y ~ x, family=binomial(link="logit"))
wells_dist.stan : glm(switched ~ dist, family=binomial(link="logit"))
wells_dist100.stan: glm(switched ~ dist/100, family=binomial(link="logit"))
2. Multiple predictors with no interaction
wells_d100ars.stan: glm(switched ~ dist/100 + arsenic, family=binomial(link="logit"))
wells_dae.stan : glm(switched ~ dist/100 + arsenic + educ/4,
family=binomial(link="logit"))
3. Multiple predictors with interction
wells_daae_c.stan : glm(switched ~ c_dist100 + c_arsenic + c_dist100:c_arsenic
+ assoc + educ4,
family=binomial(link="logit"))
where:
educ4 <- educ / 4
wells_dae_c.stan : glm(switched ~ c_dist100 + c_arsenic + c_dist100:c_arsenic
+ educ4,
family=binomial(link="logit"))
wells_dae_inter.stan : glm(switched ~ dist/100 + arsenic + educ/4
+ dist/100:arsenic,
family=binomial(link="logit"))
wells_dae_inter_c.stan : glm(switched ~ c_dist100 + c_arsenic + c_educ4
+ c_dist100:c_arsenic + c_dist100:c_educ4
+ c_arsenic:c_educ4,
family=binomial(link="logit"))
wells_interaction.stan : glm(switched ~ dist/100 + arsenic + dist/100:arsenic,
family=binomial(link="logit"))
wells_interaction_c.stan: glm(switched ~ c_dist100 + c_arsenic
+ c_dist100:c_arsenic,
family=binomial(link="logit"))
where:
c_dist100 <- (dist - mean(dist)) / 100
c_arsenic <- arsenic - mean(arsenic)
wells_predicted.stan : glm(switched ~ c_dist100 + c_arsenic + c_educ4
+ c_dist100:c_arsenic + c_dist100:c_educ4
+ c_arsenic:c_educ4,
family=binomial(link="logit"))
wells_predicted_log.stan: glm(switched ~ c_dist100 + c_log_arsenic + c_educ4
+ c_dist100:c_log_arsenic
+ c_dist100:c_educ4
+ c_log_arsenic:c_educ4,
family=binomial(link="logit"))
where:
c_log_arsenic <- log(arsenic) - mean(log(arsenic))