clear all set obs 1000 forvalues i=1/4 { generate x`i' = runiform(-3,3) // x's independent and balanced } summarize x* pwcorr x*, sig // no substantial correlation egen ylo = rowtotal(x*) //histogram ylo // normal distribution generate ypr = invlogit(ylo) //histogram ypr // beta distribution generate y = runiform() < ypr tabulate y // should be roughly "fair" quietly logit y x* predict rp, residuals // Pearson residuals predict rd, deviance // deviance residuals predict pxb, xb // linear predictor scatter rd rp scatter rp pxb scatter rd pxb clear input x1 x2 -1 -1 0 0 1 1 end fillin x1 x2 expand 20 generate ypr = invlogit(x1 + x2) generate y = runiform() < ypr graph bar y, over(x1) over(x2) logit y x*, nolog predict rp, residuals // Pearson residuals predict rd, deviance // deviance residuals predict pxb, xb // linear predictor capture graph drop _all scatter rd rp, name(PtoD) scatter rp pxb, name(Pearson) scatter rd pxb, name(deviance) graph combine Pearson deviance PtoD