Exercise 1) A study examined whether the perception of the quality of service at a five-star hotel in Jamaica differed by the type of guest (domestic vs foreign). Hotel guests were randomly selected and asked to rate 10 service-related items. Each item was rated on a five-point scale (the higher the score, the higher the perceived quality of service). A score for each guest was obtained by adding the ratings s/he gave for all items. The scores for domestic and foreign guests are recorded in the vectors “domestic_scores” and “foreign_scores” (see next code chunks).

domestic_scores = c(49, 48, 48, 39, 42, 41, 44, 46, 45, 44, 46, 47, 43, 45, 46, 40, 48, 43, 44, 46, 45, 44, 49, 43, 42, 47, 39, 47, 48, 48, 49, 43, 47, 43, 45, 39, 45, 46, 44, 48, 46, 44, 44)
foreign_scores = c(42, 42, 49, 42, 44, 46, 43, 44, 44, 44, 41, 44, 42, 42, 48, 40, 45, 43, 44 ,45, 44, 46, 45, 44, 44, 45, 37, 44, 41, 42, 42, 40, 42, 43, 41, 41, 45, 44, 42, 44, 46)

Test whether the mean service rating given by domestic guests is higher than the mean service rating given by foreign guests using a 0.10 level of significance. Consider that the standard deviations of the variables domestic_rate and foreign_rate are equal. Conduct this test step by step answering the following questions:

  1. Identify the two random variables involved in this problem.

Answer:

Service scores given by domestic guests Service scores given by foreign guests

An alternative could be:

Domestic scores

Foreign scores

  1. Check whether the assumption needed for the test to be valid is satisfied.
length(domestic_scores)
## [1] 43
length(foreign_scores)
## [1] 41

Answer: Given that both sample sizes are more than 30, we can safely assume that the normal distribution is warranted. Thus, the validity assumption is satisfied.

  1. State the hypotheses (Ho and Ha)

Ho: Mean service scores given by domestic guests <= Mean service scores given by foreign guests Ha: Mean service scores given by domestic guests > Mean service scores given by foreign guests

An alternative way of stating the hypotheses in a more compact way is this:

Md: Mean service scores given by domestic guests Mf: Mean service scores given by foreign guests

Ho: Md <= Mf Ha: Md > Mf

  1. Conduct the relevant test in R to reach a decision.
# The order used to enter the vectors with the two samples MATTERS!
# The first vector is always the first population you stated in Ho and Ha.
t.test(domestic_scores,foreign_scores,alternative = c("greater"), var.equal=TRUE)
## 
##  Two Sample t-test
## 
## data:  domestic_scores and foreign_scores
## t = 2.8295, df = 82, p-value = 0.00293
## alternative hypothesis: true difference in means is greater than 0
## 95 percent confidence interval:
##  0.6359463       Inf
## sample estimates:
## mean of x mean of y 
##  44.86047  43.31707

Decision: The PV (0.0029) is less than the significance level that we established (alpha= 0.1); therefore, the data give us evidence to reject Ho and support Ha.

Therefore, the data is backing up the suspicion (claim) that domestic guests give higher average scores that foreign guests.

  1. What kind of error could you be making after you made the decision in part d)?

We could be making a type I error. Why? Because we rejected Ho. When one decides to reject Ho after conducting the test, IF Ho happens to be true (which in reality we do NOT know), we would be making an error (by rejecting Ho when Ho was true).

In this specific problem, a type I error can be described as follows: Concluding that domestic guests give higher average scores than foreign guests WHEN IN REALITY domestic guests give an average score equal (or lower) than the average score given by foreign guests.

Do we have any indication that the risk of making a type I error in this exercise is low? Thankfully yes!

The PV is the probability of making a type I error, and in this case, the PV is very low (0.0029). Thus, there is a small chance that we are making such an error in this problem.

  1. Estimate the effect size in this problem.

DO THIS PART LATER. FINISH EXERCISE 2 FIRST. DO IT AFTER WE HAVE COVERED the “Practical significance” slides from the presentation.

Exercise 2) A Starbucks manager suspects that the coffee at two of her stores (stores A and B) yield different caffeine content. To test whether this is true, she takes a random sample of large coffees from both stores and measures the amount of caffeine content in each coffee cup (in mg). The amount of mg of caffeine in a cup of coffee is a random variable that follows a Normal distribution. The results are stored in the vectors “coffeeA” and coffeeB”.

coffeeA = c(166, 166, 166, 162, 163, 163, 164, 165, 164, 164, 165, 165, 164, 164, 165, 162, 165, 164, 164, 165)

coffeeB = c(165, 164, 166, 164, 164, 165, 162, 165, 166, 166, 166, 164, 166, 164, 165, 163, 165, 165, 164, 166)

Conduct a hypothesis test to check if the manager’s concern is reasonable. Use a significance level of 0.05. Conduct the test following these steps:

Answer:

Caffeine content in a cup of coffee at store A

Caffeine content in a cup of coffee at store B

Ha: Mean caffeine content given in Store A is not equal to Mean caffeine content given in Store B

Ho: store A = Store B

Ha: store A != Store B

In contrast to exercise 1, here in exercise 2 I am not providing you with info about whether you can safely assume that the variances of both variables are the same or not. From now on, I do not have to tell you that information because I will teach you how to check for it by running a hypothesis test to compare the variances of two populations.

Test to check for the equality of the variances:

Ho: Variance of A = Variance of B

Ha: Variance of A != Variance of B

var.test(coffeeA,coffeeB,alternative = "two.sided")
## 
##  F test to compare two variances
## 
## data:  coffeeA and coffeeB
## F = 1.1032, num df = 19, denom df = 19, p-value = 0.8328
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
##  0.4366433 2.7870743
## sample estimates:
## ratio of variances 
##           1.103158
# remember that 'two.sided' means 'not equal to'

PV= 0.8328 is very large (way bigger than alpha=0.05), thus, we do not have evidence to reject Ho. Thus, we can conclude that the variances of both variables are the same.

t.test(coffeeA,coffeeB, alternative = "two.sided", var.equal = TRUE) #because we do not reject Ho and both variances are the same then var.equal is TRUE
## 
##  Two Sample t-test
## 
## data:  coffeeA and coffeeB
## t = -1.2412, df = 38, p-value = 0.2221
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -1.1839577  0.2839577
## sample estimates:
## mean of x mean of y 
##    164.30    164.75

p-value = 0.2221 > alpha =0.05, therefore, we do not have evidence to reject Ho in favor of Ha. The samples do not give us enough evidence to conclude that the average caffeine content is different in the two stores. The manager’s suspicion is not backed up by the data.

  1. What kind of error could you be making after you made the decision in a)?

We could be making a type II error. Why? Because we did NOT reject Ho. When one decides to not reject Ho after conducting the test, IF Ho happens to be false (which in reality we do NOT know), we would be making an error (by not rejecting Ho when Ho was actually false).

In this specific problem, a type II error can be described as follows: Concluding that the mean caffeine content in the coffee served at both stores is the same WHEN IN REALITY there is a difference in the mean caffeine content between the stores.

Do we have any indication that the risk of making a type I error in this exercise is low? No (although we could have it)