In: Statistics and Probability
STAT | ||||||||||||
PatientID | Age | Sex | County | CardioRisk | Height | Weight | BloodGroup | Stroke | RegularEx | Group | Cholesterol1 | Cholesterol2 |
225 | 58 | Male | Offaly | Low | 179.2 | 103.5 | AB | N | N | Placebo | 6.1 | 4.6 |
226 | 61 | Male | Carlow | Medium | 174.9 | 63 | AB | Y | N | Control | 2.2 | 5.7 |
227 | 57 | Female | Donegal | Medium | 161.9 | 76.1 | B | N | Y | Control | 5.8 | 5 |
228 | 43 | Male | Offaly | High | 176 | 83.7 | AB | Y | N | Control | 3.6 | 2.4 |
229 | 37 | Female | Longford | Low | 157.8 | 68 | B | N | Y | Control | 4.9 | 6 |
230 | 29 | Male | Leitrim | Medium | 166.1 | 79.1 | A | Y | Y | Placebo | 3.5 | 5.3 |
231 | 52 | Male | Cavan | Low | 167.6 | 60.4 | A | Y | Y | Placebo | 2.9 | 4 |
232 | 47 | Female | Westmeath | Low | 167.8 | 63.6 | B | N | Y | Control | 4 | 3.2 |
233 | 28 | Male | Wicklow | Low | 170.5 | 67.2 | O | Y | N | Control | 4.2 | 4 |
the commands for these questions using rstudio
Q1
a. Is there a difference in the risk of cardiovascular disease between males and females?
b. Is there a difference in weight between the Control and Placebo groups?
c. Do the data suggest that the new drug reduces cholesterol level compared to the placebo?
Q.a
We perform chi-square test of independence to check this claim.
> d=read.table('data1.csv',header=T,sep=',')
> head(d)
PatientID Age Sex County CardioRisk Height Weight BloodGroup
Stroke
1 225 58 Male Offaly Low 178.2 103.5 AB N
2 226 61 Male Carlow Medium 173.9 63.0 AB Y
3 227 57 Female Donegal Medium 160.9 76.1 B N
4 228 43 Male Offaly High 175.0 83.7 AB Y
5 229 37 Female Longford Low 156.8 68.0 B N
6 230 29 Male Leitrim Medium 165.1 79.1 A Y
RegularEx Group Cholesterol1 Cholesterol2
1 N Placebo 6.1 4.6
2 N Control 2.2 5.7
3 Y Control 5.8 5.0
4 N Control 3.6 2.4
5 Y Control 4.9 6.0
6 Y Placebo 3.5 5.3
> attach(d)
The following objects are masked from d (pos = 3):
Age, BloodGroup, CardioRisk, Cholesterol1, Cholesterol2,
County,
Group, Height, PatientID, RegularEx, Sex, Stroke, Weight
> t=table(Sex,CardioRisk);t
CardioRisk
Sex High Low Medium
Female 0 2 1
Male 1 3 2
> chisq.test(t)
Pearson's Chi-squared test
data: t
X-squared = 0.6, df = 2, p-value = 0.7408
Warning message:
In chisq.test(t) : Chi-squared approximation may be
incorrect
Hypothesis:
H0 : Cardio risk does not depend upon sex
H1 : Cardio risk does depend upon sex.
Since p-value is greater than 0.05, we accept null hypothesis and conclude that there is no difference in the risk of cardiovascular disease between males and females.
Que.b
> t.test(Weight[which(Group=='Placebo')],Weight[which(Group=='Control')])
Welch Two Sample t-test
data: Weight[which(Group == "Placebo")] and Weight[which(Group
== "Control")]
t = 0.83162, df = 2.2847, p-value = 0.4835
alternative hypothesis: true difference in means is not equal to
0
95 percent confidence interval:
-38.66752 60.13418
sample estimates:
mean of x mean of y
81.00000 70.26667
Since p-value is greater than 0.05, there is no difference in weight between the Control and Placebo groups.
Que.c
> chol1=Cholesterol2[which(Group=='Control')] -
Cholesterol1[which(Group=='Control')]
> chol2=Cholesterol2[which(Group=='Placebo')] -
Cholesterol1[which(Group=='Placebo')]
> t.test(chol1,chol2,alternative='less')
Welch Two Sample t-test
data: chol1 and chol2
t = -0.16147, df = 4.1791, p-value = 0.4396
alternative hypothesis: true difference in means is less than
0
95 percent confidence interval:
-Inf 2.408399
sample estimates:
mean of x mean of y
0.2666667 0.4666667
Since p-value is greater than 0.05, we conclude that the new drug does not reduces cholesterol level compared to the placebo.