Practice exam 5
Block 1 - Diagnostic analytics and causality
2When do you use a t-value instead of 1.96 for a 95% confidence interval?
3H1: "Higher advertising spend has a positive influence on revenue." Which null hypothesis (H0) belongs to this?
4Which design gives the strongest evidence that a new price approach increases revenue?
Block 2 - Descriptive statistics, sampling and correlation
5A satisfaction survey invites 1500 customers; mostly angry customers respond. Which bias fits?
6A colleague says: "My sample has n = 500, so my data are normally distributed." What is wrong with that?
7A report says "the average customer spends 36.9 euro" and also "between 34.1 and 39.7 euro". Which statements are a point estimate and an interval estimate, respectively?
8In a box plot of lead times (simulated data) Q1 = 22 and Q3 = 34 hours. From which value is an observation an outlier at the top?
Block 3 - Hypothesis testing
9Suppose (fictional case), with 11.9 million observations p < 0.001 for a difference of 0.2 seconds. Which conclusion is correct?
10Which measure raises the power of a test?
11In the two-way ANOVA on Attractiveness: which effects are significant at alpha = 0.05?
> summary(aov(Attractiveness ~ ManipDest * ManipInfo, data = Fl))
Df Sum Sq Mean Sq F value Pr(>F)
ManipDest 2 36533 18266 40.640 <2e-16 ***
ManipInfo 1 2 2 0.005 0.9455
ManipDest:ManipInfo 2 3016 1508 3.356 0.0355 *
Residuals 687 308784 449
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
> summary(aov(Attractiveness ~ ManipDest + ManipInfo, data = Fl))
Df Sum Sq Mean Sq F value Pr(>F)
ManipDest 2 36533 18266 40.364 <2e-16 ***
ManipInfo 1 2 2 0.005 0.946
Residuals 689 311800 453
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
12When do you use a z-test instead of a t-test for a mean?
13Share of men (18.0%) and women (20.9%) rating the train above 50: p = 0.3868. What do you conclude?
> trein <- Fl$rateTrain > 50
> tab <- table(Fl$dGender, trein)
> tab
trein
FALSE TRUE
man 333 73
vrouw 227 60
> prop.test(x = tab[, "TRUE"], n = rowSums(tab))
2-sample test for equality of proportions with continuity correction
data: tab[, "TRUE"] out of rowSums(tab)
X-squared = 0.74892, df = 1, p-value = 0.3868
alternative hypothesis: two.sided
95 percent confidence interval:
-0.09230152 0.03378897
sample estimates:
prop 1 prop 2
0.1798030 0.2090592
14A scale has three items (1 to 5). A respondent gives 4, 2 and 5. Item 2 is negatively worded. What is the composite score (mean after reverse coding)?
Block 4 - Data cleaning and management
15In the monthly means TEMP in July is -2.43 and PRCP -23.95, while August has 23.06. What is the most likely cause?
> am <- aggregate(cbind(TEMP, PRCP) ~ MO, data = Wr, FUN = mean) > am$TEMP <- round(am$TEMP, 2) > am$PRCP <- round(am$PRCP, 3) > am MO TEMP PRCP 1 1 -2.42 0.280 2 2 -0.70 0.238 3 3 3.23 0.956 4 4 7.57 0.751 5 5 12.81 0.428 6 6 19.66 0.746 7 7 -2.43 -23.950 8 8 23.06 0.096 9 9 20.23 0.142 10 10 14.26 0.157 11 11 7.00 0.716 12 12 2.01 0.429 > round(aggregate(TEMP ~ YEAR, data = Wr, FUN = mean), 2) YEAR TEMP 1 2021 14.94 2 2022 9.86 3 2023 10.69 4 2024 3.26 5 2025 6.25
16A variable has mean 60 and standard deviation 5. What is the z-score (standardization) of x = 70?
Block 5 - Linear regression
17In R you write lm(minuten ~ afstand * regen). Which terms does R estimate?
18A meal delivery service models the delivery time in minutes (minuten) of 150 orders using the distance in km (afstand) and a dummy regen (1 = it is raining). Simulated data. What does the coefficient of regen (4.50) mean in the model with interaction?
> rN <- lm(minuten ~ afstand * regen, data = bz)
> summary(rN)
Call:
lm(formula = minuten ~ afstand * regen, data = bz)
Residuals:
Min 1Q Median 3Q Max
-9.0382 -2.3187 0.1102 1.9844 11.3492
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 7.25079 0.69816 10.386 < 2e-16 ***
afstand 2.46874 0.09686 25.487 < 2e-16 ***
regen 4.50226 1.50449 2.993 0.00325 **
afstand:regen 0.77388 0.20548 3.766 0.00024 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 3.452 on 146 degrees of freedom
Multiple R-squared: 0.8917, Adjusted R-squared: 0.8894
F-statistic: 400.6 on 3 and 146 DF, p-value: < 2.2e-16
19A meal delivery service models the delivery time in minutes (minuten) of 150 orders using the distance in km (afstand) and a dummy regen (1 = it is raining). Simulated data. By how many minutes does the expected delivery time increase per extra kilometre when it is raining?
> rN <- lm(minuten ~ afstand * regen, data = bz)
> summary(rN)
Call:
lm(formula = minuten ~ afstand * regen, data = bz)
Residuals:
Min 1Q Median 3Q Max
-9.0382 -2.3187 0.1102 1.9844 11.3492
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 7.25079 0.69816 10.386 < 2e-16 ***
afstand 2.46874 0.09686 25.487 < 2e-16 ***
regen 4.50226 1.50449 2.993 0.00325 **
afstand:regen 0.77388 0.20548 3.766 0.00024 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 3.452 on 146 degrees of freedom
Multiple R-squared: 0.8917, Adjusted R-squared: 0.8894
F-statistic: 400.6 on 3 and 146 DF, p-value: < 2.2e-16
20A meal delivery service models the delivery time in minutes (minuten) of 150 orders using the distance in km (afstand) and a dummy regen (1 = it is raining). Simulated data. What does the F-test on the interaction (F = 14.18; p = 0.00024) show?
> rM <- lm(minuten ~ afstand + regen, data = bz) > rN <- lm(minuten ~ afstand * regen, data = bz) > anova(rM, rN) Analysis of Variance Table Model 1: minuten ~ afstand + regen Model 2: minuten ~ afstand * regen Res.Df RSS Df Sum of Sq F Pr(>F) 1 147 1909.3 2 146 1740.2 1 169.06 14.184 0.0002398 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
21A meal delivery service models the delivery time in minutes (minuten) of 150 orders using the distance in km (afstand) and a dummy regen (1 = it is raining). Simulated data. What is the predicted delivery time (in minutes) of a 5 km order when it is raining, according to the model with interaction?
> rN <- lm(minuten ~ afstand * regen, data = bz)
> summary(rN)
Call:
lm(formula = minuten ~ afstand * regen, data = bz)
Residuals:
Min 1Q Median 3Q Max
-9.0382 -2.3187 0.1102 1.9844 11.3492
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 7.25079 0.69816 10.386 < 2e-16 ***
afstand 2.46874 0.09686 25.487 < 2e-16 ***
regen 4.50226 1.50449 2.993 0.00325 **
afstand:regen 0.77388 0.20548 3.766 0.00024 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 3.452 on 146 degrees of freedom
Multiple R-squared: 0.8917, Adjusted R-squared: 0.8894
F-statistic: 400.6 on 3 and 146 DF, p-value: < 2.2e-16
22A web shop models weekly revenue (omzet, in €1000) over 100 weeks using the number of visitors (bezoekers) and the number of ad impressions (advertenties). Simulated data. Only bezoekers is strongly significant (t = 7.52). With advertenties added, neither is significant (p = 0.0625 and 0.1204), while the F-test gives p = 7.56e-11. What is the best explanation?
> round(cor(ws), 3)
bezoekers advertenties omzet
bezoekers 1.000 0.900 0.605
advertenties 0.900 1.000 0.599
omzet 0.605 0.599 1.000
> summary(lm(omzet ~ bezoekers, data = ws))
Call:
lm(formula = omzet ~ bezoekers, data = ws)
Residuals:
Min 1Q Median 3Q Max
-26.5924 -9.5294 0.1865 8.5457 29.3180
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 34.04556 7.07787 4.81 5.46e-06 ***
bezoekers 0.01053 0.00140 7.52 2.64e-11 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 12.17 on 98 degrees of freedom
Multiple R-squared: 0.3659, Adjusted R-squared: 0.3594
F-statistic: 56.55 on 1 and 98 DF, p-value: 2.644e-11
> summary(lm(omzet ~ bezoekers + advertenties, data = ws))
Call:
lm(formula = omzet ~ bezoekers + advertenties, data = ws)
Residuals:
Min 1Q Median 3Q Max
-30.3058 -8.6001 -0.3742 8.9788 30.5371
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 36.171059 7.155703 5.055 2.03e-06 ***
bezoekers 0.006020 0.003194 1.884 0.0625 .
advertenties 0.011717 0.007479 1.567 0.1204
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 12.08 on 97 degrees of freedom
Multiple R-squared: 0.3815, Adjusted R-squared: 0.3688
F-statistic: 29.92 on 2 and 97 DF, p-value: 7.56e-11
> vifb <- 1/(1 - summary(lm(bezoekers ~ advertenties, data = ws))$r.squared)
> round(vifb, 2)
[1] 5.29
23The residual plot of a regression fans out: at higher fitted values the residuals get larger. Which assumption is violated and what is the consequence?
Block 6 - Logistic regression, overfitting and validation
24A model flags 40 of the 1,000 transactions as possible fraud (positive = fraud). In 10 of those 40 it is really fraud. What does the number 10/40 = 0.25 mean?
25The output shows the measures of the same model at different cutoffs. What happens to sensitivity and specificity when the cutoff falls from 0.5 to 0.3?
cutoff accuracy sensitivity specificity precision [1,] 0.3 0.678 0.5758 0.7147 0.4199 [2,] 0.4 0.722 0.3333 0.8614 0.4632 [3,] 0.5 0.746 0.1288 0.9674 0.5862 [4,] 0.6 0.740 0.0379 0.9918 0.6250 [5,] 0.7 0.736 0.0000 1.0000 NA
26A model for default (3% of customers do not pay) has an accuracy of 97%. What do you say about that?
27What happens in 5-fold cross-validation?
28A model predicts for 500 households at threshold 0.5: 356 TN, 115 FN, 12 FP and 17 TP (R order: 0 first). What is the specificity?
29You compare the base model with a model to which Stedelijk has been added. What do you conclude?
Model 1: Accepteert ~ Inkomen + Koophuis + Leeftijd Model 2: Accepteert ~ Inkomen + Koophuis + Leeftijd + Stedelijk Resid. Df Resid. Dev Df Deviance Pr(>Chi) 1 496 527.77 2 495 527.44 1 0.32917 0.5661
30In the cross table 34% of the owners and 16% of the renters accept. What is the odds ratio of owners relative to renters?
0 1
0 0.84 0.16
1 0.66 0.34
Block 7 - Open questions on R output
7.1Tasks (together at most 200 words): 1. Interpret the coefficients of Herinnering and Leeftijd in business language, including significance at α = 0.05 (4 points). 2. Calculate the accuracy and the precision of the model (2 points). 3. Explain why the planner's statement is misleading (3 points).
A hospital wants to predict which patients fail to show up (NoShow = 1). For 900 appointments (simulated data; 120 no-shows), Wachtdagen (days between request and appointment), Herinnering (Ja = patient received an SMS reminder, reference category Nee) and Leeftijd (in years) were recorded. The hospital estimates a logistic regression. With a threshold of 0.2 the confusion matrix below results. A planner says: the accuracy is 0.79, so the model is good.
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -2.365772 0.362638 -6.524 6.86e-11 ***
Wachtdagen 0.032786 0.009022 3.634 0.000279 ***
HerinneringJa -0.739586 0.199685 -3.704 0.000212 ***
Leeftijd 0.003489 0.005111 0.683 0.494855
Null deviance: 706.81 on 899 degrees of freedom
Residual deviance: 679.16 on 896 degrees of freedom
AIC: 687.16
Waargenomen
Voorspeld 0 1
0 676 82
1 104 38
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 meal delivery service models the delivery time in minutes (minuten) of 150 orders using the distance in km (afstand), a dummy regen (1 = it is raining) and the interaction between them. Simulated data: all orders come from one city. Write a short reflection (at most 250 words in total) on the output.
> rN <- lm(minuten ~ afstand * regen, data = bz)
> summary(rN)
Call:
lm(formula = minuten ~ afstand * regen, data = bz)
Residuals:
Min 1Q Median 3Q Max
-9.0382 -2.3187 0.1102 1.9844 11.3492
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 7.25079 0.69816 10.386 < 2e-16 ***
afstand 2.46874 0.09686 25.487 < 2e-16 ***
regen 4.50226 1.50449 2.993 0.00325 **
afstand:regen 0.77388 0.20548 3.766 0.00024 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 3.452 on 146 degrees of freedom
Multiple R-squared: 0.8917, Adjusted R-squared: 0.8894
F-statistic: 400.6 on 3 and 146 DF, p-value: < 2.2e-16
Answer builder
7.3Assignments (together at most 150 words): 1. Name the role of visit frequency and of season in the causal relationship scheme (2 points). 2. Formulate one testable hypothesis about the effect of the loyalty card on revenue per customer, and give the corresponding null hypothesis (3 points). 3. Explain the risk of the analyst's plan to devise hypotheses afterwards (2 points).
A supermarket chain sees that customers with a loyalty card have a higher annual revenue per customer. The manager wants to investigate this for a new discount structure. He thinks the card makes customers come back more often (visit frequency), which raises revenue. The effect is expected to be stronger in the winter months. An analyst proposes to search the available data for the most interesting relationships and to devise hypotheses for them afterwards.