STA3030F TUTORIAL 3
Instructions
Only Question 4 should be done in R, all the other questions must be done by hand.
Question 1
A second-hand car dealership has recorded the number of sales made in a random sample
of its branches located in four provinces. It wishes to know whether there are significant
differences in the mean sales levels in the four provinces. The data and selected summary
statistics are presented in the table below as follows:
ni
P 2
Group Salsolinol Excretion Levels Yi. Yij − Yi.
j=1
Western Cape 30 35 32 33 41 34.20 70.80
KZN 31 36 37 31 39 45 36.50 139.50
Northern Cape 43 42 42 44 42.75 2.75
Limpopo 45 32 47 48 42 40 42.33 173.33
Suppose a bootstrapping approach has been applied based on 5000 replications. For each
SST /(k − 1)
replication, the SSE, SST and the ratio were calculated. A summary of
SSE/(N − k)
quantiles of the bootstrapped ratios are shown below:
Quantile: 0.02% 1% 2.5% 5% 10% 20%
F-ratio: 0.002 0.038 0.068 0.111 0.186 0.329
Quantile: 80% 90% 95% 97.5% 99% 100%
F-ratio: 1.728 2.518 3.303 4.015 5.129 13.821
Use these bootstrap results to compute a p-value for the hypothesis test that there are no
differences in mean sales levels between the four provinces. What would you conclude?
Question 2
A group of 5 athletes had their calorie intakes measured for four days before a major race.
The main focus of the research is to assess whether there is a difference in the average
intake over the four days. The data is presented in the table below as follows:
Athlete
ni
X 2
Group 1 2 3 4 5 Yi. Yij − Yi.
j=1
Day 1 2000 1600 3000 3700 2400 2540 2 752 000
Day 2 1800 1800 3500 3300 1800 2440 3 092 000
Day 3 2200 2000 3000 3700 5000 3180 5 968 000
Day 4 4000 2200 3700 4100 4200 3640 2 732 000
Year: 2025 1
STA3030F TUTORIAL 3
A bootstrap simulation was performed in which 2000 bootstrap samples were generated.
For each replication, the SSE, SST and the ratio SST/SSE were calculated. Note: The
ratio has not been adjusted for degrees of freedom. The SST/SSE ratios were sorted from
smallest to largest, and the following are a selection of the observed values:
Position: 1 20 50 100 500 1000
SST/SSE: 0.001 0.007 0.013 0.021 0.078 0.155
Position: 1500 1900 1950 1980 1990 2000
SST/SSE: 0.278 0.631 0.809 1.052 1.238 3.906
After adjusting the ratios for the degrees of freedom, use the results to test the hypothesis
that there are no differences between mean calorie intake over the four days. What would
you conclude?
Question 3
During the 2010 FIFA World Cup, attendance figures (in thousands of people) of people
watching games at four of the World Cup venues were recorded for some of the games at
each stadium, shown as follows:
ni
P 2 2
Stadium Attendance Yij − Yi. ni Yi. − Y..
i=1
Green Point 8.9 7.2 3.1 7.1 6.7 18.16 0.06
Soccer City 6.6 6.9 8.2 8.3 2.30 4.05
Ellis Park 5.6 7.3 7.2 6.3 1.94 0.04
Nelson Mandela 4.2 6.9 4.1 5.8 5.45 6.19
(a) Briefly outline how you could use bootstrapping to investigate the sampling distri-
bution of SST, the treatment sum of squares.
(b) Such a bootstrapping approach was applied, based on 2000 bootstrap replications.
For each replication, the SSE (Error Sum of Squares), SST (Treatment Sum of
Squares) and the F -ratios
SST
k−1
SSE
N −k
were calculated. The F -ratios were sorted from smallest to largest, and the following
are a selection of the observed values:
Sample No: 50 100 500 1000 1500 1900 1950 2000
F -ratio 0.06 0.11 0.42 0.87 1.52 3.38 4.16 11.37
What conclusion should be drawn about any differences in the mean attendance
between the stadiums?
Year: 2025 2
STA3030F TUTORIAL 3
Question 4
(a) Write a function in R that calculates the SSE and SST, name the function [Link] sst.
The function should take one parameter, [Link] - a list of observations from
each group. The function should return the following:
• Fr_o : observed F_ratio = (SST/(k-1))/(SSE/(N-k))
• Y.. : overall sample mean
• Yi. : sample mean for each group i
• N : total number of observations.
Use the following as a guide:
fun.sse_sst = function([Link])
{
# [Link]: a list of observations from each group
# Your code here !!!
return(list(Fr_o = ___ , Y.. = ___ , Yi. = ___ , N = ___ ))
}
# replace ___ with appropriate variables
The output of the function when applied to the data in Question 2 is shown below:
# Load the data
d1 = c(2000, 1600, 3000, 3700, 2400)
d2 = c(1800 ,1800, 3500, 3300, 1800)
d3 = c(2200, 2000, 3000, 3700, 5000)
d4 = c(4000, 2200, 3700, 4100, 4200)
days = list(d1,d2,d3,d4)
output = fun.sse_sst(days)
output
## $Fr_o
## [1] 1.755042
##
## $Y..
## [1] 2950
##
## $Yi.
## [1] 2540 2440 3180 3640
##
## $N
## [1] 20
(b) In Question 2, the ratio SST/SSE was computed. What changes should be made to
your code in a) so that your function returns either the adjusted ratio for degrees of
freedom (F-ratio) or SST/SSE. The function must NOT return both ratios.
Year: 2025 3