Assignment
Assignment
ID:- 2325385680
1. Do you think the average systolic blood pressure of the patient is 130 mm/hg? Use the
appropriate STATA command to answer it.
Answer: Command :
ttest bpsystol==130
One-sample t test
------------------------------------------------------------------------------
Variable | Obs Mean Std. err. Std. dev. [95% conf. interval]
---------+--------------------------------------------------------------------
bpsystol | 10,351 130.8817 .2293364 23.33265 130.4321 131.3312
------------------------------------------------------------------------------
mean = mean(bpsystol) t = 3.8444
H0: mean = 130 Degrees of freedom = 10350
Ha: mean < 130 Ha: mean != 130 Ha: mean > 130
Pr(T < t) = 0.9999 Pr(|T| > |t|) = 0.0001 Pr(T > t) = 0.0001
So, the mean or average of the systolic BP is 130 mm/hg which is 130.8817
2. Check your answer of the t-test output from the previous problem, calculate and check
manually using the formula where you obtain same result for the t-statistic.
Answer: Formula to calculate t-statistic is,
x ̅ −μ
t=
s
Here, x ̅ is the sample mean = 130.8817
√n ¿
¿
μ is the population mean = 130
s is the sample standard deviation =
23.33265
n is the sample size = 10351
130.8817−130
t=
23.33265/(√¿10351)
0.8817
t= 0.8817
23.33265 ≈ ≈ 3.8439
101.738 ¿ 0.2293364
¿
The difference between the manually calculated t-statistic and the one provided in the output is
minimal (around 0.0005), which could be due to rounding difference.
3. Compare whether the mean BMI varies by sex? You may use “ttest” command to answer
this. Consider both equal and unequal variance assumptions.
Answer: For unequal variance, Command:
ttest bmi,by( sex)unequal
Here, in all cases P-value is >0.05, we fail to reject the null hypothesis, suggesting that
there is no significant difference in BMI between males and females.
4. Check your answer of the two-sample t-test output from the previous problem, calculate
and check manually using the formula whether you obtain same result for the t-statistic!
Answer:
x 1−x 2
t=
√
2 2
s1 s 2
+
n1 n2
25.50999−25.56256
t=
√ (4.023758)2 (5.600241)2
4915
+
5436
−0.05257 −0.05257
t≈ ≈ ≈−0.5524
√ 0.0090644 0.0952
The manually calculated t-statistic closely matches the one obtained from the output. The
difference is likely due to rounding during calculation. Thus, the manually calculated t-
statistic confirms the result obtained from the Stata output.
5. Compare whether the mean height of the participants is similar irrespective of their race.
Answer: Command:
oneway height race
Analysis of variance
Source SS df MS F Prob > F
------------------------------------------------------------------------
Between groups 6882.21987 2 3441.10993 37.17 0.0000
Within groups 958117.822 10348 92.5896619
------------------------------------------------------------------------
Total 965000.042 10350 93.236719