Confounding bias and caus al inference in exposure–response modeling 233
is a confounding factor and it controls the exposure di via a logistic model.
The ER model is fitted by simple LS, IP W with exac t and estimated weights,
respectively.
> nsimu=10000
> male=rep(0:1,nsimu/2)
> pi=1/(1+exp(male))
> di=rbinom(nsimu,1,pi)
> yi=di+male+rnorm(nsimu)
> pdi=predict(glm(di~male))
> pwei=ifelse(di==1,pdi,1-pdi)
> wei=ifelse(di==1,pi,1-pi)
> lm(yi~di)
Coefficients:
(Intercept) di
0.5716 0.7959
> lm(yi~di,weight=1/wei)
Coefficients:
(Intercept) di
0.4816 1.0383
> lm(yi~di,weight=1/pwei)
Coefficients:
(Intercept) di
0.4827 1.0360
The following table shows the mean and SD of the three estimates (IPW1 and
IPW2 are estimates with e xact and e stimated propensity, respectively) ...