In: Statistics and Probability
R studio: Show detailed working, including appropriate mathematical notation for each question. For most questions this will involve showing your working from R, (e.g. cut-and-paste commands and output from an R session).
The probability of a student owning a cat is known to be 0.44; and the probability of a student owning a dog is known to be 0.54. If the probability of owning both is known to be 0.36, calculate:
(a) the probability of not owning a dog
(b) the probability of owning either a cat or a dog or both
(c) the probability of a student owning a dog, given that they own a cat
(d) Are owning a cat and dog independent? Justify (e) (harder) a group of 32 vetinary science students is interviewed. Of these 32, only 7 have no pet. State a sensible null hypothesis, test it, and interpret.
R Code
pc = 0.44 #probability of owning
cat
pd = 0.54 #probability of owning dog
pcd = 0.36 #probability of owning both dog and cat
#(a) probability of not owning dog
1-pd
#(b) probability of owning either a cat or a dog or both
pc + pd - pcd
#(c) probability of a student owning a dog, given that they own a
cat
pcd / pc
#(d)
pcd == pc * pd #pcd should be equal to pc * pd for
independent
Running the code, we get
(a) the probability of not owning a dog = 0.46
(b) the probability of owning either a cat or a dog or both = 0.62
(c) the probability of a student owning a dog, given that they own a cat = 0.8181818
(d) Are owning a cat and dog independent - No
(e)
probability of not owning any pet = 1 - 0.62 = 0.38
Null Hypothesis H0: p = 0.38
Using R code, we get
> prop.test(7,32,p = 0.38)
1-sample proportions test with continuity correction
data: 7 out of 32, null probability 0.38
X-squared = 2.8804, df = 1, p-value = 0.08967
alternative hypothesis: true p is not equal to 0.38
95 percent confidence interval:
0.09944097 0.40441815
sample estimates:
p
0.21875
Since p-value (0.08967) is greater than 0.05 significance level, we fail to reject null hypothesis H0 and conclude that there is no strong evidence to warrant the rejection of the claim that proportion of people not owning a pet is 0.38.