# R/exams questions

## Knowledge quiz (single-choice)

What is the seat of the federal authorities in Switzerland (i.e., the de facto capital)?

Zurich St. Gallen Lausanne Geneva Bern

There is no de jure capital but the de facto capital and seat of the federal authorities is Bern.

- False
- False
- False
- False
- True

## Knowledge quiz (multiple-choice)

Which of the following cities are the capital of the corresponding country?

Riyadh (Saudi Arabia)Astana (Kazakhstan)New Delhi (India)Auckland (New Zealand)Toronto (Canada)

- True. Riyadh is the capital of Saudi Arabia.
- True. Astana is the capital of Kazakhstan.
- True. New Delhi is the capital of India.
- False. The capital of New Zealand is Wellington.
- False. The capital of Canada is Ottawa.

## Arithmetic (numeric)

What is the derivative of \(f(x) = x^{2} e^{3.4x}\), evaluated at \(x = 0.73\)?

Using the product rule for \(f(x) = g(x) \cdot h(x)\), where \(g(x) := x^{2}\) and \(h(x) := e^{3.4x}\), we obtain \[\begin{aligned} f'(x) & = & [g(x) \cdot h(x)]' = g'(x) \cdot h(x) + g(x) \cdot h'(x) \\ & = & 2 x^{2 - 1} \cdot e^{3.4x} + x^{2} \cdot e^{3.4x} \cdot 3.4 \\ & = & e^{3.4x} \cdot(2 x^1 + 3.4 x^{2}) \\ & = & e^{3.4x} \cdot x^1 \cdot (2 + 3.4x). \end{aligned}\] Evaluated at \(x = 0.73\), the answer is \[e^{3.4\cdot 0.73} \cdot 0.73^1 \cdot (2 + 3.4\cdot 0.73) = 39.148364.\] Thus, rounded to two digits we have \(f'(0.73) = 39.15\).

## Arithmetic (single-choice)

What is the derivative of \(f(x) = x^{7} e^{2.9x}\), evaluated at \(x = 0.72\)?

\(12.08\)\(8.68\)\(10.22\)\(7.87\)\(12.76\)

Using the product rule for \(f(x) = g(x) \cdot h(x)\), where \(g(x) := x^{7}\) and \(h(x) := e^{2.9x}\), we obtain \[\begin{aligned} f'(x) & = & [g(x) \cdot h(x)]' = g'(x) \cdot h(x) + g(x) \cdot h'(x) \\ & = & 7 x^{7 - 1} \cdot e^{2.9x} + x^{7} \cdot e^{2.9x} \cdot 2.9 \\ & = & e^{2.9x} \cdot(7 x^6 + 2.9 x^{7}) \\ & = & e^{2.9x} \cdot x^6 \cdot (7 + 2.9x). \end{aligned}\] Evaluated at \(x = 0.72\), the answer is \[e^{2.9\cdot 0.72} \cdot 0.72^6 \cdot (7 + 2.9\cdot 0.72) = 10.215748.\] Thus, rounded to two digits we have \(f'(0.72) = 10.22\).

- False
- False
- True
- False
- False

## Multiple-choice with graphic

In the following figure the distributions of a variable given by two samples (A and B) are represented by parallel boxplots. Which of the following statements are correct? (Comment: The statements are either about correct or clearly wrong.)

The location of both distributions is about the same. Both distributions contain no outliers. The spread in sample A is clearly bigger than in B. The skewness of both samples is similar. Distribution A is left-skewed.

- False. Distribution A has on average higher values than distribution B.
- True. Both distributions have no observations which deviate more than 1.5 times the interquartile range from the box.
- False. The interquartile range in sample A is not clearly bigger than in B.
- True. The skewness of both distributions is similar, both are about symmetric.
- False. Distribution A is about symmetric.

## Multiple-choice with R output

The waiting time (in minutes) at the cashier of two supermarket chains with different cashier systems is compared. The following statistical test was performed:

        Two Sample t-test

    data:  Waiting by Supermarket
    t = -4.3616, df = 114, p-value = 2.847e-05
    alternative hypothesis: true difference in means between group Sparag and group Consumo is not equal to 0
    95 percent confidence interval:
     -4.551177 -1.708214
    sample estimates:
     mean in group Sparag mean in group Consumo
                 4.400115              7.529811

Which of the following statements are correct? (Significance level 5%)

The absolute value of the test statistic is larger than 1.96. A one-sided alternative was tested. The p-value is larger than 0.05. The test shows that the waiting time is longer at Sparag than at Consumo. The test shows that the waiting time is shorter at Sparag than at Consumo.

- True. The absolute value of the test statistic is equal to 4.362.
- False. The test aims at showing that the difference of means is unequal to 0.
- False. The p-value is equal to 2.85e-05.
- False.
- True. The test result is significant (\(p < 0.05\)) and hence the alternative is shown, that the difference of means are unequal to 0.

## String question

What is the name of the R function for extracting the estimated coefficients from a fitted (generalized) linear model object?

`coef` is the R function for extracting the estimated coefficients from a fitted (generalized) linear model object. See `?coef` for the corresponding manual page.

## Cloze question combining all types

Theory: Consider a linear regression of `y` on `x`. It is usually estimated with which estimation technique (three-letter abbreviation)?

This estimator yields the best linear unbiased estimator (BLUE) under the assumptions of the Gauss-Markov theorem. Which of the following properties are required for the errors of the linear regression model under these assumptions?

independent zero expectation normally distributed identically distributed homoscedastic

Application: Using the data provided in `linreg.csv` estimate a linear regression of `y` on `x`. What are the estimated parameters?

Intercept:

Slope:

In terms of significance at 5% level:

Theory: Linear regression models are typically estimated by ordinary least squares (OLS). The Gauss-Markov theorem establishes certain optimality properties: Namely, if the errors have expectation zero, constant variance (homoscedastic), no autocorrelation and the regressors are exogenous and not linearly dependent, the OLS estimator is the best linear unbiased estimator (BLUE).

Application: The estimated coefficients along with their significances are reported in the summary of the fitted regression model, showing that `y` decreases significantly with `x` (at 5% level).

    Call:
    lm(formula = y ~ x, data = d)

    Residuals:
        Min      1Q  Median      3Q     Max
    -0.6164 -0.1483  0.0026  0.1459  0.6090

    Coefficients:
                Estimate Std. Error t value Pr(>|t|)
    (Intercept)  0.04130    0.02353   1.755   0.0823 .
    x           -0.80200    0.04261 -18.824   <2e-16 ***
    ---
    Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

    Residual standard error: 0.2353 on 98 degrees of freedom
    Multiple R-squared:  0.7833,    Adjusted R-squared:  0.7811
    F-statistic: 354.3 on 1 and 98 DF,  p-value: < 2.2e-16

Code: The analysis can be replicated in R using the following code.

    ## data
    d <- read.csv("linreg.csv")
    ## regression
    m <- lm(y ~ x, data = d)
    summary(m)
    ## visualization
    plot(y ~ x, data = d)
    abline(m)

## Cloze question with table layout

An industry-leading company seeks a qualified candidate for a management position. A management consultancy carries out an assessment center which concludes in making a positive or negative recommendation for each candidate: From previous assessments they know that of those candidates that are actually eligible for the position (event \(E\)) \(60\%\) get a positive recommendation (event \(R\)). However, out of those candidates that are not eligible \(62\%\) get a negative recommendation. Overall, they know that only \(6\%\) of all job applicants are actually eligible.

What is the corresponding fourfold table of the joint probabilities? (Specify all entries in percent.)

| \(R\) | \(\overline{R}\) | sum
--- | --- | --- | ---
\(E\) | % | % | %
\(\overline{E}\) | % | % | %
sum | % | % | %

Using the information from the text, we can directly calculate the following joint probabilities: \[ \begin{aligned} P(E \cap R) & = P(R | E) \cdot P(E) = 0.6 \cdot 0.06 = 0.036 = 3.6\%\\ P(\overline{E} \cap \overline{R}) & = P(\overline{R} | \overline{E}) \cdot P(\overline{E}) = 0.62 \cdot 0.94 = 0.5828 = 58.28\%. \end{aligned} \] The remaining probabilities can then be found by calculating sums and differences in the fourfold table:

| \(R\) | \(\overline{R}\) | sum
--- | --- | --- | ---
\(E\) | 3.60 | 2.40 | 6.00
\(\overline{E}\) | 35.72 | 58.28 | 94.00
sum | 39.32 | 60.68 | 100.00

- \(P(E \cap R) = 3.60\%\)
- \(P(\overline{E} \cap R) = 35.72\%\)
- \(P(E \cap \overline{R}) = 2.40\%\)
- \(P(\overline{E} \cap \overline{R}) = 58.28\%\)
- \(P(R) = 39.32\%\)
- \(P(\overline{R}) = 60.68\%\)
- \(P(E) = 6.00\%\)
- \(P(\overline{E}) = 94.00\%\)
- \(P(\Omega) = 100.00\%\)