Practice exam 3
Block 1 - Diagnostic analytics and causality
2A manager says: "the standard deviation of 14.3 means our mean is uncertain by 14.3." What is wrong here?
3An analyst says that the probability that a customer waits exactly 7.000 days for a delivery (continuous variable) is 20%. What is wrong here?
4An arrow in a causal relationship scheme has a question mark. What does that mean?
Block 2 - Descriptive statistics, sampling and correlation
5A chain has 40 branches across the country. To save travel costs the researcher randomly chooses 6 branches and measures all employees there. Which method is this?
6A care institution wants to say something about all elderly people in the Netherlands, but draws the sample from the patient list of one GP practice. What role does that patient list have?
7A supplier measures n = 36 parcels (simulated data) with a known sigma of 12 grams. What is the half width of the 95% confidence interval?
8A researcher raises the confidence level from 95% to 99% with the same data. What happens to the interval?
Block 3 - Hypothesis testing
9In a one-sided (right) test the critical value is 1.65 and the computed t = 3.77. What do you do?
10A sample of n = 25 has mean 52 and standard deviation 10. H0: mu = 50. What is the t value of the one-sample t-test?
11The output shows mean difference = -53.51 for rateTrain minus rateAirplane. What does that mean?
> t.test(Fl$rateTrain, Fl$rateAirplane, paired = TRUE)
Paired t-test
data: Fl$rateTrain and Fl$rateAirplane
t = -32.543, df = 692, p-value < 2.2e-16
alternative hypothesis: true mean difference is not equal to 0
95 percent confidence interval:
-56.73617 -50.27970
sample estimates:
mean difference
-53.50794
> summary(Fl$rateTrain - Fl$rateAirplane)
Min. 1st Qu. Median Mean 3rd Qu. Max.
-100.00 -90.00 -60.00 -53.51 -30.00 100.00
12Of 693 respondents, 287 are women (41.4%). Is the share of women significantly different from 50% at alpha = 0.05?
> x <- sum(Fl$dGender == "vrouw")
> n <- nrow(Fl)
> c(x = x, n = n, p = x/n)
x n p
287.0000000 693.0000000 0.4141414
> prop.test(x, n, p = 0.5)
1-sample proportions test with continuity correction
data: x out of n, null probability 0.5
X-squared = 20.092, df = 1, p-value = 7.379e-06
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
0.3773312 0.4519168
sample estimates:
p
0.4141414
13You want to know whether the brand customers choose (A, B, C) is related to their gender. Which test fits?
14Which statement about Cronbach's alpha is correct?
Block 4 - Data cleaning and management
15PreferTrain has 28 NAs and you impute them with the mean. What does the output show?
> x <- Fl$PreferTrain > xi <- ifelse(is.na(x), mean(x, na.rm = TRUE), x) > c(n_voor = sum(!is.na(x)), n_na = length(xi)) n_voor n_na 665 693 > round(c(mean_voor = mean(x, na.rm = TRUE), mean_na = mean(xi)), 3) mean_voor mean_na 42.511 42.511 > round(c(sd_voor = sd(x, na.rm = TRUE), sd_na = sd(xi)), 3) sd_voor sd_na 27.698 27.132
16The example on slide 17: trans has 6 transactions (T001 to T006) from customers C01, C02, C01, C03, C01 and C05; cust has 4 customers (C01 to C04). How many rows does merge(trans, cust, by = "customer_id", all.x = TRUE) return?
Block 5 - Linear regression
17An estate agent models the value per m2 (valuem2, in dollars) of 90 houses on Long Island using annual property tax (taxes, in dollars) and a region dummy (Suffolk = 1, Nassau = 0). Which interpretation of the coefficient of f.regionSuffolk (−157.98) is correct?
> rA <- lm(valuem2 ~ taxes + f.region, data = Hu)
> summary(rA)
Call:
lm(formula = valuem2 ~ taxes + f.region, data = Hu)
Residuals:
Min 1Q Median 3Q Max
-151.313 -59.439 -4.703 42.863 202.336
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 208.10687 32.08430 6.486 5.16e-09 ***
taxes 0.02906 0.01014 2.867 0.00519 **
f.regionSuffolk -157.97627 20.37294 -7.754 1.56e-11 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 75.33 on 87 degrees of freedom
Multiple R-squared: 0.427, Adjusted R-squared: 0.4139
F-statistic: 32.42 on 2 and 87 DF, p-value: 3.013e-11
18An estate agent models the value per m2 (valuem2, in dollars) of 90 houses on Long Island using annual property tax (taxes, in dollars) and a region dummy (Suffolk = 1, Nassau = 0). By how many dollars per m2 does the predicted value differ between two houses in the same region whose annual tax differs by 1000 dollars?
> rA <- lm(valuem2 ~ taxes + f.region, data = Hu)
> summary(rA)
Call:
lm(formula = valuem2 ~ taxes + f.region, data = Hu)
Residuals:
Min 1Q Median 3Q Max
-151.313 -59.439 -4.703 42.863 202.336
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 208.10687 32.08430 6.486 5.16e-09 ***
taxes 0.02906 0.01014 2.867 0.00519 **
f.regionSuffolk -157.97627 20.37294 -7.754 1.56e-11 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 75.33 on 87 degrees of freedom
Multiple R-squared: 0.427, Adjusted R-squared: 0.4139
F-statistic: 32.42 on 2 and 87 DF, p-value: 3.013e-11
19An estate agent models the value per m2 (valuem2, in dollars) of 90 houses on Long Island using annual property tax (taxes, in dollars) and a region dummy (Suffolk = 1, Nassau = 0). At the bottom it says "F-statistic: 32.42 on 2 and 87 DF, p-value: 3.013e-11". Which H0 belongs to this test and what is the conclusion?
> rA <- lm(valuem2 ~ taxes + f.region, data = Hu)
> summary(rA)
Call:
lm(formula = valuem2 ~ taxes + f.region, data = Hu)
Residuals:
Min 1Q Median 3Q Max
-151.313 -59.439 -4.703 42.863 202.336
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 208.10687 32.08430 6.486 5.16e-09 ***
taxes 0.02906 0.01014 2.867 0.00519 **
f.regionSuffolk -157.97627 20.37294 -7.754 1.56e-11 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 75.33 on 87 degrees of freedom
Multiple R-squared: 0.427, Adjusted R-squared: 0.4139
F-statistic: 32.42 on 2 and 87 DF, p-value: 3.013e-11
20An estate agent models the value per m2 (valuem2, in dollars) of 90 houses on Long Island using annual property tax (taxes, in dollars) and a region dummy (Suffolk = 1, Nassau = 0). What is the predicted value per m2 (in dollars) of a house in Suffolk with an annual tax of 3000 dollars?
> rA <- lm(valuem2 ~ taxes + f.region, data = Hu)
> summary(rA)
Call:
lm(formula = valuem2 ~ taxes + f.region, data = Hu)
Residuals:
Min 1Q Median 3Q Max
-151.313 -59.439 -4.703 42.863 202.336
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 208.10687 32.08430 6.486 5.16e-09 ***
taxes 0.02906 0.01014 2.867 0.00519 **
f.regionSuffolk -157.97627 20.37294 -7.754 1.56e-11 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 75.33 on 87 degrees of freedom
Multiple R-squared: 0.427, Adjusted R-squared: 0.4139
F-statistic: 32.42 on 2 and 87 DF, p-value: 3.013e-11
21In the model Nassau is the reference and the dummy coefficient for Suffolk is −157.98. The analyst recodes so that Suffolk becomes the reference. What changes?
22The model was estimated on houses with an annual tax between roughly 1000 and 6000 dollars. A colleague uses it for a villa with 40,000 dollars in tax. What is the main objection?
23An estate agent models the value per m2 (valuem2, in dollars) of 90 houses on Long Island using annual property tax (taxes, in dollars) and a region dummy (Suffolk = 1, Nassau = 0). What does "Residual standard error: 75.33 on 87 degrees of freedom" mean?
> rA <- lm(valuem2 ~ taxes + f.region, data = Hu)
> summary(rA)
Call:
lm(formula = valuem2 ~ taxes + f.region, data = Hu)
Residuals:
Min 1Q Median 3Q Max
-151.313 -59.439 -4.703 42.863 202.336
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 208.10687 32.08430 6.486 5.16e-09 ***
taxes 0.02906 0.01014 2.867 0.00519 **
f.regionSuffolk -157.97627 20.37294 -7.754 1.56e-11 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 75.33 on 87 degrees of freedom
Multiple R-squared: 0.427, Adjusted R-squared: 0.4139
F-statistic: 32.42 on 2 and 87 DF, p-value: 3.013e-11
Block 6 - Logistic regression, overfitting and validation
24A provider models whether a household accepts an offer (Accepteert = 1). Koophuis is 1 for an owner-occupied home and 0 for a rented home. What does the coefficient 1.010191 of Koophuis mean in business language?
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -3.059258 0.636016 -4.810 1.51e-06 ***
Inkomen 0.043241 0.009569 4.519 6.22e-06 ***
Koophuis 1.010191 0.231169 4.370 1.24e-05 ***
Leeftijd -0.014108 0.007500 -1.881 0.06 .
25What is overfitting?
26The acceptance model is estimated on 350 training observations and tested on 150 test observations (threshold 0.5). Does this output point to overfitting?
cutoff accuracy sensitivity specificity precision train 0.5 0.7286 0.1146 0.9606 0.5238 test 0.5 0.7933 0.1944 0.9825 0.7778
27Which two measures are on the axes of a ROC curve?
28A logit model contains the factor Regio (Noord, Oost, West; Noord is the reference category) and the output shows RegioOost and RegioWest. What does the coefficient of RegioOost mean?
29A linear probability model (lm) and the logit model give 0.1723 and 1.0102 respectively for Koophuis. How do you read that?
logit ols (Intercept) -3.0593 -0.0533 Inkomen 0.0432 0.0074 Koophuis 1.0102 0.1723 Leeftijd -0.0141 -0.0025
30How are the coefficients of a logistic regression estimated?
Block 7 - Open questions on R output
7.1Tasks (together at most 200 words): 1. Interpret the coefficients of Schuldquote and Inkomen 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 risk team's reasoning that the model is bad because the accuracy lies below the baseline (3 points).
A bank predicts default (Wanbetaling = 1) for 1200 loans (simulated data; 26 defaulters). Predictors are Schuldquote (debt as a percentage of income), Inkomen (in €1,000) and Vastcontract (Ja = permanent employment, reference category Nee). Because default is rare, the bank calls a loan 'risky' at a predicted probability of at least 0.05 (threshold) instead of 0.5. The risk team says: the accuracy of 0.875 is lower than 0.978, so the model is bad.
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -7.19931 1.26771 -5.679 1.35e-08 ***
Schuldquote 0.07259 0.01759 4.126 3.69e-05 ***
Inkomen 0.01774 0.02273 0.781 0.435
VastcontractJa -0.40619 0.41387 -0.981 0.326
Null deviance: 250.70 on 1199 degrees of freedom
Residual deviance: 225.95 on 1196 degrees of freedom
AIC: 233.95
Waargenomen
Voorspeld 0 1
0 1040 16
1 134 10
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?
An HR department models the annual salary (in euros) of 240 alumni using years of education, years of experience and a dummy vrouw (1 = woman). The dependent variable is log(salaris). The data come from a voluntary alumni survey (simulated data). Write a short reflection (at most 250 words in total) on the output.
> rK <- lm(log(salaris) ~ opleiding + ervaring + vrouw, data = sal)
> summary(rK)
Call:
lm(formula = log(salaris) ~ opleiding + ervaring + vrouw, data = sal)
Residuals:
Min 1Q Median 3Q Max
-0.60643 -0.18152 0.00117 0.17144 0.75468
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 9.449195 0.086327 109.458 < 2e-16 ***
opleiding 0.070291 0.005293 13.280 < 2e-16 ***
ervaring 0.012553 0.001840 6.824 7.41e-11 ***
vrouw -0.056155 0.032043 -1.752 0.081 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.2461 on 236 degrees of freedom
Multiple R-squared: 0.5145, Adjusted R-squared: 0.5084
F-statistic: 83.38 on 3 and 236 DF, p-value: < 2.2e-16
> rL <- lm(salaris ~ opleiding + ervaring + vrouw, data = sal)
> round(coef(summary(rL)), 3)
Estimate Std. Error t value Pr(>|t|)
(Intercept) -8870.064 4102.149 -2.162 0.032
opleiding 3172.988 251.520 12.615 0.000
ervaring 542.843 87.415 6.210 0.000
vrouw -2767.541 1522.656 -1.818 0.070
> round(summary(rL)$r.squared, 4)
[1] 0.4851
Answer builder
7.3Assignments (together at most 150 words): 1. Name the role of app use and of income in the causal relationship scheme (2 points). 2. Formulate one testable hypothesis about the effect of push messages on the amount saved, and give the corresponding null hypothesis (3 points). 3. Explain why the statement "push messages cause saving" is not justified on the basis of the current data (2 points).
A bank sends push messages that encourage customers to save and wants to know whether this raises the amount saved. The marketer thinks the message makes customers open the app more often (app use), and that customers who open the app more often save more. He expects the effect to be stronger for customers with a higher income. In the current data, customers with a lot of app use have also saved a lot.