Hello,
I am running a linear regression and wanted to obtain confidence intervals for linear predictions. I predicted the linear predictions and their standard errors using predict, and then compared these with confidence intervals from predictnl.
Although the confidence intervals are similar in this exampe they are not exactly the same and I wondered which ones are the correct ones.
I use Stata 17
Thank you for your help
André
I am running a linear regression and wanted to obtain confidence intervals for linear predictions. I predicted the linear predictions and their standard errors using predict, and then compared these with confidence intervals from predictnl.
Although the confidence intervals are similar in this exampe they are not exactly the same and I wondered which ones are the correct ones.
I use Stata 17
Thank you for your help
André
Code:
use "https://www.stata-press.com/data/r17/mheart0", clear regress bmi female age predict xb_bmi, xb predict std_bmi, stdp generate inf = xb_bmi - 1.96*std_bmi generate sup = xb_bmi + 1.96*std_bmi predictnl xb_bmi2 = predict(xb), ci(cil_mi ciu_mi) list xb_bmi xb_bmi2 if xb_bmi != xb_bmi2 list inf cil_mi if inf != cil_mi list sup ciu_mi if sup != ciu_mi generate mean1 = (inf + sup)/2 - xb_bmi generate mean2 = (cil_mi + ciu_mi)/2 - xb_bmi2 tab mean1 tab mean2 clear
Comment