In: Statistics and Probability
Test of equal or given proportions: Use the “bacteria” data set to answer the question, “did the drug treatment have a significant effect of the presence of the bacteria compared with the placebo?”
Please use R to answer this question.
It should be use In R studio. dataset is also in the R. it's large to put here.
Just open R studio, view(bacteria).
we have to test for equal proportions, that is, both the placebo and the drug should have same effect, so, the number of 'yes's should be equal to the number of 'no's
So, our hypothesis is:
where p= proportion of children who have bacteria H. influenzae present.
This is a test for single proportions.
Code in R:
library(MASS)
data(bacteria)
prop=bacteria[[1]]
table(prop)
x=0
n=length(prop)
for(i in 1:n)
{ if(prop[i]=="y")
x=x+1 #to calculate number of cases with presence of bacteria
}
#single sample proportion test
prop.test(x=x,n=n,p=0.5,alternative='greater')
result:
interpretation:
p-value is very very small, so we can conclude on the basis of our data that the drug treatment have a significant effect of the presence of the bacteria compared with the placebo.