Stata Commands for Generating a Confidence Interval and ...
Stata Commands for Generating a Confidence Interval and Prediction Interval for Xh
Y = college student’s height, X1 = mom’s height, X2 = dad’s height, X3 = 1 if male, 0 if female
There were n = 165 usable cases in the dataset.
We would like to find a confidence interval for the mean height of all college females whose mothers are 65 inches tall and fathers are 70 inches tall, and a prediction interval for a female whose parents have those heights. Therefore, Xh' = [1 65 70 0].
First we need to increase the number of observations by one, and since we already had 165, we need 166. Then we need to insert the appropriate new values for the 3 X variables into row 166. Note that the names for the 3 X variables are momheight, dadheight and male:
. set obs 166
obs was 165, now 166
. replace momheight = 65 in 166
. replace dadheight = 70 in 166
. replace male = 0 in 166
Generate the point estimate, [pic] by getting fitted values for all rows. We’ll call them “newht”. Remember that the “predict” command with no option generates fitted (predicted) values:
. predict newht
Generate the t-multiplier for a 95% interval and df = 161 (the df associated with MSE, thus with s):
. generate tmult=invttail(161,.025)
Generate the standard errors, which we call s{[pic]} and s{pred}. Here I have named them “CIstderror” and “PIstderror”:
. predict CIstderror, stdp
. predict PIstderror, stdf
Generate the lower and upper end points for each interval, then list the results for Row 166:
. generate lowerCI = newht - tmult*CIstderror
. generate upperCI = newht + tmult*CIstderror
. generate lowerPI = newht - tmult*PIstderror
. generate upperPI = newht + tmult*PIstderror
. list newht lowerCI upperCI lowerPI upperPI in 166
+------------------------------------------------------+
| newht lowerCI upperCI lowerPI upperPI|
|------------------------------------------------------|
166. | 65.29191 64.75152 65.82503 60.68798 69.89584 |
+------------------------------------------------------+
Let’s list the standard errors as well, so we can see how much larger s{pred} is than s{[pic]}
. list CIstderror in 166 [This is s{[pic]}]
+----------+
| CIstde~r |
|----------|
166. | .2699615 |
+----------+
. list PIstderror in 166 [This is s{pred}]
+----------+
| PIstde~r |
|----------|
166. | 2.331329 |
+----------+
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- introduction to the practice of statistics
- ac 150 5370 10h standard specifications for construction
- written respiratory protection program template
- chapter 1000 guidelines for municipal shoreland
- chapter 6 normal probability distributions
- chapter 1 linear regression with one predictor variable
- chapter 6 foundation design hud
- stata commands for generating a confidence interval and
- physics loudoun county public schools
Related searches
- confidence interval calculator for population mean
- upper and lower confidence interval calculator
- confidence interval calculator for p
- confidence interval calculator for mean
- confidence interval calculator for sample
- confidence interval for t
- confidence interval calculator for two means
- confidence interval calculator for two groups
- confidence interval confidence level calculator
- confidence interval and statistical significance
- confidence interval calculator for two
- confidence interval for proportion in excel