Practice exam 2
Block 1 - Diagnostic analytics and causality
2A call centre has very skewed call durations. An analyst draws a sample of n = 80 calls. What does the central limit theorem say about the sample mean?
3A company publishes the average salary of 200 employees. A few directors earn an extreme amount. Which measure fits a "typical" employee best?
4A municipality sees that in months with more ice cream sales more people drown. An analyst concludes that ice cream causes drowning. What is the best criticism?
Block 2 - Descriptive statistics, sampling and correlation
5A bank has three customer segments of very different size (retail, SME, corporate) and wants enough observations in each segment. Which sampling method fits?
6A study among first-year students of one programme in Rotterdam finds that students study 22 hours a week on average. The authors conclude this for "all Dutch students". What is the main problem here?
7A sample of n = 81 delivery times (simulated data) gives a standard deviation s = 18 minutes. What is the standard error of the sample mean?
8A report states: "95% confidence interval for the mean delivery time: 4.6 to 5.7 days." Which interpretation is correct?
Block 3 - Hypothesis testing
9A researcher finds p = 0.20 and concludes: "H0 is proven." What is wrong?
10A test has a probability of a Type II error (beta) of 0.20. What is the power of the test?
11Is mean rateTrain significantly different between men and women at alpha = 0.05?
> t.test(rateTrain ~ dGender, data = Fl)
Welch Two Sample t-test
data: rateTrain by dGender
t = -1.7013, df = 628.47, p-value = 0.08939
alternative hypothesis: true difference in means between group man and group vrouw is not equal to 0
95 percent confidence interval:
-7.3788543 0.5284398
sample estimates:
mean in group man mean in group vrouw
26.20197 29.62718
> tapply(Fl$rateTrain, Fl$dGender, mean, na.rm = TRUE)
man vrouw
26.20197 29.62718
12What do you conclude from this chi-square test at alpha = 0.05?
> tab <- table(Fl$ManipDest, Fl$ManipInfo)
> tab
1 2
1 118 114
2 115 120
3 115 111
> res <- chisq.test(tab)
> res
Pearson's Chi-squared test
data: tab
X-squared = 0.23316, df = 2, p-value = 0.89
> round(res$expected, 2)
1 2
1 116.50 115.50
2 118.01 116.99
3 113.49 112.51
13You compare four groups with all 6 pairwise t-tests, each at alpha = 0.05 and treated as independent. What is the probability of at least one Type I error?
14Cronbach's alpha for 8 items is -0.0984. What is the most likely cause and fix?
> Ent <- na.omit(Ent)
> nrow(Ent)
[1] 637
> a <- psych::alpha(Ent, warnings = FALSE)
> round(a$total$raw_alpha, 4)
[1] -0.0984
> round(a$alpha.drop["raw_alpha"], 4)
raw_alpha
Risk01 -0.2592
Risk02 0.1177
Risk03 -0.3108
Risk05 0.2117
Risk06 -0.3052
Risk07 -0.3082
Risk08 0.1189
Risk09 -0.2699
> round(cor(Ent, use = "complete.obs")[, 1], 3)
Risk01 Risk02 Risk03 Risk05 Risk06 Risk07 Risk08 Risk09
1.000 -0.274 0.328 -0.314 0.229 0.211 -0.223 0.332
Block 4 - Data cleaning and management
15You get the table of operating systems. How many rows does Ph %>% filter(os %in% c("Android", "iOS")) keep?
> table(Ph$os)
Android EMUI KAIOS OxygenOS WindowsPhone
197 915 2 1 3 3
iOS
103
16In a list of ages 21, 25, 35, 30, 32, 328 there is a value of 328. What is the best first step?
Block 5 - Linear regression
17An analyst wants to include the variable regio (north, east, south, west) in a regression. How should he do it?
18A gym chain models the number of new members per month of 80 branches (nieuwe_leden) using marketing (in €1000), the number of nearby competitors and a dummy centrum (1 = branch in the city centre). Simulated data. Which interpretation of the coefficient of centrum is correct?
> rJ <- lm(nieuwe_leden ~ marketing + concurrenten + centrum, data = gym)
> summary(rJ)
Call:
lm(formula = nieuwe_leden ~ marketing + concurrenten + centrum,
data = gym)
Residuals:
Min 1Q Median 3Q Max
-33.631 -6.195 0.456 9.079 25.517
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 22.1055 4.0949 5.398 7.39e-07 ***
marketing 0.8202 0.2718 3.018 0.003461 **
concurrenten -2.8205 0.7073 -3.988 0.000152 ***
centrum 16.2737 2.7382 5.943 7.93e-08 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 11.98 on 76 degrees of freedom
Multiple R-squared: 0.4613, Adjusted R-squared: 0.44
F-statistic: 21.69 on 3 and 76 DF, p-value: 2.994e-10
19A gym chain models the number of new members per month of 80 branches (nieuwe_leden) using marketing (in €1000), the number of nearby competitors and a dummy centrum (1 = branch in the city centre). Simulated data. Which statement about the number of competitors matches the output?
> rJ <- lm(nieuwe_leden ~ marketing + concurrenten + centrum, data = gym)
> summary(rJ)
Call:
lm(formula = nieuwe_leden ~ marketing + concurrenten + centrum,
data = gym)
Residuals:
Min 1Q Median 3Q Max
-33.631 -6.195 0.456 9.079 25.517
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 22.1055 4.0949 5.398 7.39e-07 ***
marketing 0.8202 0.2718 3.018 0.003461 **
concurrenten -2.8205 0.7073 -3.988 0.000152 ***
centrum 16.2737 2.7382 5.943 7.93e-08 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 11.98 on 76 degrees of freedom
Multiple R-squared: 0.4613, Adjusted R-squared: 0.44
F-statistic: 21.69 on 3 and 76 DF, p-value: 2.994e-10
20A gym chain models the number of new members per month of 80 branches (nieuwe_leden) using marketing (in €1000), the number of nearby competitors and a dummy centrum (1 = branch in the city centre). Simulated data. The R² is 0.4613 and the adjusted R² is 0.4400. Why is the second measure lower, and what do you use it for?
> rJ <- lm(nieuwe_leden ~ marketing + concurrenten + centrum, data = gym)
> summary(rJ)
Call:
lm(formula = nieuwe_leden ~ marketing + concurrenten + centrum,
data = gym)
Residuals:
Min 1Q Median 3Q Max
-33.631 -6.195 0.456 9.079 25.517
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 22.1055 4.0949 5.398 7.39e-07 ***
marketing 0.8202 0.2718 3.018 0.003461 **
concurrenten -2.8205 0.7073 -3.988 0.000152 ***
centrum 16.2737 2.7382 5.943 7.93e-08 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 11.98 on 76 degrees of freedom
Multiple R-squared: 0.4613, Adjusted R-squared: 0.44
F-statistic: 21.69 on 3 and 76 DF, p-value: 2.994e-10
21A model with n = 80 and k = 3 predictors has R² = 0.4613. What is the adjusted R²?
> rJ <- lm(nieuwe_leden ~ marketing + concurrenten + centrum, data = gym)
> summary(rJ)
Call:
lm(formula = nieuwe_leden ~ marketing + concurrenten + centrum,
data = gym)
Residuals:
Min 1Q Median 3Q Max
-33.631 -6.195 0.456 9.079 25.517
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 22.1055 4.0949 5.398 7.39e-07 ***
marketing 0.8202 0.2718 3.018 0.003461 **
concurrenten -2.8205 0.7073 -3.988 0.000152 ***
centrum 16.2737 2.7382 5.943 7.93e-08 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 11.98 on 76 degrees of freedom
Multiple R-squared: 0.4613, Adjusted R-squared: 0.44
F-statistic: 21.69 on 3 and 76 DF, p-value: 2.994e-10
22Two predictors in a regression have a mutual correlation of 0.92. What is the most likely consequence?
23A gym chain models the number of new members per month of 80 branches (nieuwe_leden) using marketing (in €1000), the number of nearby competitors and a dummy centrum (1 = branch in the city centre). Simulated data. What is the expected number of new members per month for a branch in the centre with marketing = 10 (€1000) and 3 competitors?
> rJ <- lm(nieuwe_leden ~ marketing + concurrenten + centrum, data = gym)
> summary(rJ)
Call:
lm(formula = nieuwe_leden ~ marketing + concurrenten + centrum,
data = gym)
Residuals:
Min 1Q Median 3Q Max
-33.631 -6.195 0.456 9.079 25.517
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 22.1055 4.0949 5.398 7.39e-07 ***
marketing 0.8202 0.2718 3.018 0.003461 **
concurrenten -2.8205 0.7073 -3.988 0.000152 ***
centrum 16.2737 2.7382 5.943 7.93e-08 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 11.98 on 76 degrees of freedom
Multiple R-squared: 0.4613, Adjusted R-squared: 0.44
F-statistic: 21.69 on 3 and 76 DF, p-value: 2.994e-10
Block 6 - Logistic regression, overfitting and validation
24The logit model gives a customer log-odds of -1.5. What is the predicted probability that this customer accepts the offer?
25According to the model a customer has a probability of 0.20 of cancelling. What are the odds of cancelling?
26Below is the confusion matrix of 500 households at threshold 0.5 (simulated data). 1 comes first (TP top left), as on the exam. What is the sensitivity?
Werkelijk
Voorspeld 1 0
1 17 12
0 115 356
27An analyst estimates a classification model on all 500 households and reports the accuracy on those same households. What is the problem and what is the solution?
28Below are the odds ratios with 95% confidence interval. Which conclusion at α = 0.05 is right?
2.5 % 97.5 % (Intercept) 0.0135 0.1632 Inkomen 1.0248 1.0640 Koophuis 1.7456 4.3201 Leeftijd 0.9716 1.0006
29A model flags 70 transactions as fraud; 21 of them are really fraud. What is the precision?
30The base model has 4 estimated parameters (k = 4) and a residual deviance of 527.77 (that is -2 ln L). What is the AIC according to AIC = 2k - 2 ln(L)?
Block 7 - Open questions on R output
7.1Tasks (together at most 200 words): 1. Interpret the coefficients of Nieuwsbrief and Leeftijd in business language, including significance at α = 0.05 (4 points). 2. Calculate the sensitivity and the precision of the model (2 points). 3. Assess the analyst's statement that the model is bad because the accuracy is 0.61 (3 points).
A web shop sends discount vouchers and wants to predict who uses the voucher (Gebruikt = 1). For 800 customers (simulated data), Nieuwsbrief (Ja = receives the newsletter, reference category Nee), Bestellingen (number of orders last year) and Leeftijd (in years) were recorded. The shop estimates a logistic regression and predicts 'uses the voucher' at a predicted probability of at least 0.25 (threshold). A voucher costs little; a missed buying customer costs a lot of revenue. An analyst thinks the accuracy of 0.61 is bad.
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.667261 0.305206 -5.463 4.69e-08 ***
NieuwsbriefJa 0.934697 0.171813 5.440 5.32e-08 ***
Bestellingen 0.187138 0.047610 3.931 8.47e-05 ***
Leeftijd -0.011765 0.005571 -2.112 0.0347 *
Null deviance: 897.53 on 799 degrees of freedom
Residual deviance: 848.99 on 796 degrees of freedom
AIC: 856.99
Waargenomen
Voorspeld 0 1
0 362 73
1 239 126
Answer builder
7.2Write a short reflection on the output. Address the following points (250 words maximum in total): 1. Interpret the main regression coefficients from the output. 2. Interpret the p-values and what they say about statistical significance. 3. Assess the model fit and the predictive power of the model. 4. What concerns are there about the sample (bias, representativeness) and how do internal and external validity affect your conclusions?
A gym chain models the number of new members per month of 80 branches (nieuwe_leden) using marketing (in thousand euros), the number of nearby competitors and a dummy centrum (1 = branch in the city centre). Simulated data: all 80 branches are from one region of one chain. Write a short reflection (at most 250 words in total) on the output.
> rJ <- lm(nieuwe_leden ~ marketing + concurrenten + centrum, data = gym)
> summary(rJ)
Call:
lm(formula = nieuwe_leden ~ marketing + concurrenten + centrum,
data = gym)
Residuals:
Min 1Q Median 3Q Max
-33.631 -6.195 0.456 9.079 25.517
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 22.1055 4.0949 5.398 7.39e-07 ***
marketing 0.8202 0.2718 3.018 0.003461 **
concurrenten -2.8205 0.7073 -3.988 0.000152 ***
centrum 16.2737 2.7382 5.943 7.93e-08 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 11.98 on 76 degrees of freedom
Multiple R-squared: 0.4613, Adjusted R-squared: 0.44
F-statistic: 21.69 on 3 and 76 DF, p-value: 2.994e-10
Answer builder
7.3Assignments (together at most 150 words): 1. Name the role of number of items and of customer type (new or returning) in the causal relationship scheme (2 points). 2. Formulate one testable hypothesis about the effect of free shipping on the order value, and give the corresponding null hypothesis (3 points). 3. Which research design allows a causal conclusion, and why (2 points)?
A web shop considers free shipping from 40 euros to raise the average order value. The team thinks customers will therefore put more items in their basket (number of items), and that more items lead to a higher order value. The effect is expected to differ for new and returning customers. The web shop can randomly show customers the offer or not.