Exercises

Exercise 6.1 A chemical process has produced, until the previous week, on average, \(800\) tons of a chemical product per day. The daily productions this week were \(785,\) \(805,\) \(790,\) \(793,\) and \(802\) tons. Is this data indicating that the average production has gone below the \(800\) tons? Answer by carrying out the adequate hypothesis test at significance level \(\alpha=0.05\) assuming that the daily productions follow a normal distribution.

Exercise 6.2 A study was conducted by the Florida Fish and Wildlife Conservation Commission for estimating the quantity of DDT found in the brain tissues of brown pelicans. Samples of \(n_1=10\) young pelicans and \(n_2=13\) baby pelicans gave the results indicated in the table below (measurements in parts per million). Normality is assumed in both populations, as well as equal variances.

Young pelicans Baby pelicans
\(n_1=10\) \(n_2=13\)
\(\bar{X}_1=0.041\) \(\bar{X}_2=0.026\)
\(S_1'=0.021\) \(S_2'=0.006\)
  1. Test the hypothesis of no difference in the average DDT quantities found in young and baby pelicans against the alternative that the young pelicans show a higher average, with \(\alpha=0.05.\)
  2. Is there evidence that the average quantity of DDT for young pelicans is larger than the one for baby pelicans in more than \(0.01\) parts per million?

Exercise 6.3 The hourly salaries of a particular industry have a normal distribution with mean \(\mu=33000\) (in euros/year, before taxes). If in that industry there is a company of \(n=40\) employees that pays an average of \(30500\) euros/year and has a quasistandard deviation on the salaries of \(S'=6250,\) can this company be accused of systematically paying inferior salaries? Employ the significance level \(\alpha=0.01.\)

Exercise 6.4 After an increment of \(8.5\%\) due to inflation in 2023, the average pension in the “régimen general” in Spain in 2023 is \(18305.84\) euros/year. The maximum pension is \(42823.34\) euros/year. The minimum wage is \(15120\) euros/year. All figures are before taxes.

A study conducted by a union of young professionals obtained the following data about the gross yearly salary of professionals in the age range 20–29. The data is divided into two groups of professionals according to their career status:

  • Group A: 20708, 21630, 15670, 17764, 19308, 19053, 19196, 18341, 19002, 18459, 19577, 19603, 16950, 17254, 17439, 18507, 18421, 16148, 21317, 18076, 21774, 18920, 16742, 15120, 15120, 17610, 19122, 19956, 19876, 17588, 17309, 19843, 16826, 17088, 17740, 20648, 16064, 19990, 15924, 17079.
  • Group B: 35261, 37821, 32167, 41367, 42732, 49535, 38236, 49175, 46720, 34275, 39510, 37475, 42905, 46869, 43089, 30767, 44708, 39449, 40953, 42604, 41246, 39125, 48394, 37166, 44107, 41153, 42399, 45076, 38372, 37798, 36956, 44789, 34909, 44991, 35470.

Answer the following questions using significance level \(\alpha=0.05\):

  1. Are professionals in Group A better paid than the average pension? And worse paid than the maximum pension?
  2. Repeat the previous question for Group B.
  3. Pool the data together and answer the questions in a.

Exercise 6.5 A researcher is convinced that his measuring device has a variability equal to a standard deviation of \(2\) measurement units. Seventeen measurements gave as a result \(S'^2=6.1.\) Assuming normality, does the data agree or disagree with his belief? Determine the \(p\)-value of the test and the test decision at the significance level \(\alpha=0.05.\)

Exercise 6.6 The delivery times of two fast-food chains within a neighborhood are compared. The delivery times (in minutes) of \(n_1=13\) orders of chain A and \(n_2=18\) orders of chain B are given below. Assuming normality, is there evidence that the delivery times of chain A are more variable than those of chain B? Employ \(\alpha=0.05.\)

  • Chain A: 16.3, 16.6, 14.8, 14, 16.4, 10.9, 16.4, 14.4, 14.4, 12.9, 14.7, 19.1, 15.8.
  • Chain B: 16.9, 17.2, 14.7, 13.6, 16.9, 9.3, 17, 14.1, 14.1, 12.1, 14.6, 20.7, 16.2, 16.6, 12.6, 17.6, 12.2, 14.

Exercise 6.7 A psychological study was carried out in order to compare the response times (in seconds) of men and women with respect to a certain stimulus. Two independent srs’s of \(42\) men and \(45\) women were employed in the experiment. The results are shown in the table. Is the data showing enough evidence for suggesting a difference between the average response for men and women? Employ \(\alpha=0.05.\)

Men Women
\(n_1=42\) \(n_2=45\)
\(\bar{X}_1=3.6\) \(\bar{X}_2=3.8\)
\(S_1'^2=0.18\) \(S_2'^2=0.14\)

Exercise 6.8 Two surveys were conducted by the Centro de Investigaciones Sociológicas (CIS), in May 2023 and July 2023. In them, the percentage of Spaniards that self-identify as middle class (“Clase media-media”) are \(47.2\%\) and \(48.7\%,\) respectively. The sample sizes on each poll are \(4030\) and \(4164.\) Using a significance level of \(1\%,\) can we guarantee that this increment is significative?

Exercise 6.9 In the July 2023 survey of the CIS it was asked to which political party the respondent voted in the Spanish General Elections of 2019. There were \(3585\) respondents. The results for the five national parties are shown in the table below, as well with the percentage of votes actually received at the general elections.

Political party Declared 2023 Received 2019
PSOE \(31.20\%\) \(28.25\%\)
PP \(20.30\%\) \(20.99\%\)
VOX \(6.60\%\) \(15.21\%\)
PODEMOS-IU \(13.30\%\) \(12.97\%\)
Cs \(6.10\%\) \(6.86\%\)

We want to investigate the social bias in the answers of the respondents to the interviewers.

  1. For all political parties, test the equality of same proportion of votes as declared in 2023 and as received in 2019. What are the obtained \(p\)-values? What are your conclusions?
  2. Which voting preferences, if any, are significantly underreported? Which ones are overreported? Use a significance level of \(1\%.\)

Exercise 6.10 Two manufacturers, A and B, compete for the supply of batteries for a known company of electric cars, E. Company E has been told by manufacturer B that its batteries are more reliable than those from manufacturer A, the current supplier of batteries for E. To test this statement, company E is presented with historical data from the reliability of \(n_B=1736\) batteries produced by B for a smaller brand, with only \(7\) batteries requiring service before five years. Company E checks this reliability against the historical data of its production line using A’s batteries, where \(n_A=21239\) and \(191\) batteries have required service before five years. At significance level \(\alpha=0.01,\) should the company E change its supplier to have a higher reliability?

Exercise 6.11 The closing prices of two common stocks were recorded during a period of \(16\) days:

  • Stock 1: 38.83, 40.67, 41.68, 37.42, 40.86, 40.96, 39.62, 39.65, 39.63, 39.23, 39.74, 39.09, 39.37, 40.41, 41.52, 40.19.
  • Stock 2: 42.76, 43.93, 44.08, 41.71, 44.27, 43.73, 40.12, 41.6, 43.22, 44.83, 41.69, 44.16, 45.42, 44.7, 42.04, 44.21.

Is this data showing enough evidence indicating a difference in variability for the closing prices of the two stocks? Determine the \(p\)-value of the test. What would be concluded with \(\alpha=0.02\)? Assume normality (although stock prices are typically not normally distributed).

Exercise 6.12 A local brewery intends to buy a new bottling machine and considers two models, A and B, manufactured by different companies. The decisive factor for buying one model or the other is the variability in the filling of the bottles; the machine with the lower variance is the preferred one. To infer the machines’ filling variances, \(10\) bottles are filled in each one, obtaining the results of the table below. Perform the three types of tests (right one-sided, left one-sided, and two-sided) at the significance level \(\alpha=0.05\) for the null hypothesis of equality of variances of the two machines (assume normality). What are your conclusions?

A B
\(n_A=10\) \(n_B=10\)
\(\bar{X}_A=0.9\) \(\bar{X}_B=0.93\)
\(S_A'^2=0.04\) \(S_B'^2=0.03\)

Exercise 6.13 The Weibull distribution with parameters \(\lambda>0\) and \(k>0\) has pdf

\[\begin{align*} f(x;\lambda,k)=\frac{k}{\lambda}\left(\frac{x}{\lambda}\right)^{k-1}e^{-(x/\lambda)^k}, \quad x>0. \end{align*}\]

Estimate \(\lambda\) by maximum likelihood assuming \(k=2\) and estimate the Fisher information of \(\lambda.\) Then, obtain the \(p\)-values of the tests for

  1. \(H_0:\lambda=1\) vs. \(H_1:\lambda>1\) and
  2. \(H_0:\lambda=1\) vs. \(H_1:\lambda\neq 1\)

for the sample realization 1.66, 0.94, 1.54, 1.27, 1.78, 1.85, 2.34, 1.74, 1.32, 0.6, 0.88, 2.33, 1.49, 0.7, 0.73, 2.32, 1.92, 2.6, 2.51, 2.09, 3.09, 1.1, 1.76, 2.74, 2.1, 0.73, 1.47.

Exercise 6.14 Assume a srs from a negative binomial distribution \(\mathrm{NB}(r,p)\) (Exercise 5.24) is given and that \(r>0\) is known. Derive the critical region of an asymptotic test for \(H_0:p=p_0\) vs. \(H_1:p\neq p_0.\)

Exercise 6.15 The growth coefficient of certain bacteria follows a log-normal distribution \(\mathcal{LN}(\mu,\sigma^2)\) (see Exercise 5.19). The volume of bacteria in a Petri dish typically duplicates every hour, which means that their growth coefficient is \(2.\) Since the expectation of \(\mathcal{LN}(\mu,\sigma^2)\) is \(\exp(\mu+\sigma^2/2),\) this means that \(\mu+\sigma^2/2=\log(2).\)

A researcher suspects that exposing the bacteria to a chemical can slow down their growth. In \(30\) experiments, he exposes the bacteria to the chemical and annotates their growth coefficients: 1.46, 1.23, 2.34, 1.44, 1.79, 1.4, 2.18, 1.4, 1.79, 1.06, 1.38, 1.31, 1.78, 1.39, 1.41, 1.88, 1.51, 2.42, 2.13, 2.02, 2.32, 1.01, 1.28, 0.93, 1.6, 1.69, 3.37, 2.1, 2, 1.81.

Conduct a hypothesis test to check whether the growth coefficient of the bacteria is significantly lower from \(2\) at significance level \(\alpha=0.05\) and report the \(p\)-value. The parameter of interest for the hypothesis test is \(\theta:=\mu+\sigma^2/2.\) Hint: exploit result (4.7) on multiparameter inference for the vector \((\mu,\sigma^2)'\), then use a linear transformation to have an asymptotic result for \(\theta,\) and then construct a test using \(\hat{\boldsymbol{\mathcal{I}}}(\hat{\mu}_\mathrm{MLE},\hat{\sigma}_\mathrm{MLE}^2).\)

Exercise 6.16 Assume a srs \((X_1,\ldots,X_n)\) of a continuous rv \(X\) and an arbitrary test statistic \(T(X_1,\ldots,X_n)\stackrel{H_0}{\sim}F_T.\) Prove that the \(p\)-value of the test is a rv distributed as \(\mathcal{U}(0,1)\) under \(H_0.\) Do it for each of the following testing problems:

  1. \(H_0:\theta=\theta_0\) vs. \(H_1:\theta>\theta_0.\)
  2. \(H_0:\theta=\theta_0\) vs. \(H_1:\theta<\theta_0.\)
  3. \(H_0:\theta=\theta_0\) vs. \(H_1:\theta\neq\theta_0.\)

Exercise 6.17 Replicate Figure 6.2 in R. Once you have a working solution, explore the following parameters for arbitrary fixed values of the others:

  1. \(n=5,50,200.\)
  2. \(\sigma=0.1,2,10.\)
  3. \(\mu_0=-1,5,10.\)

In each case, describe the changes of the power curves and interpret the reason of these changes.

Exercise 6.18 Build the analogous example to Example 6.18 for:

  1. \(H_0:\sigma^2=\sigma_0^2\) vs. \(H_1:\sigma^2\neq\sigma_0^2.\)
  2. \(H_0:\sigma^2=\sigma_0^2\) vs. \(H_1:\sigma^2>\sigma_0^2.\)
  3. \(H_0:\sigma^2=\sigma_0^2\) vs. \(H_1:\sigma^2<\sigma_0^2.\)

Assume normal populations. The chi-square cdf is available as pchisq() in R. The resulting figure for the right one-sided test should be similar to Figure 6.1. Do you observe any strange behavior? Can you explain it?

Exercise 6.19 Approximate by Monte Carlo the power curves displayed in Figure 6.2 for the case where \(\sigma\) is unknown. To do so, approximate the rejection probability in \(\omega(\mu)\) by the relative rejection frequency of the corresponding test using \(M\) random samples, for each \(\mu\) in a sequence. You can use the following pseudocode as a guiding template:

For mu_i in mu
    For j in 1:M
        Draw sample of size n from N(mu_i, sigma^2)
        Test H0: mu = mu0 vs. H1
        Save test decision
    End
    rel_freq_i <- Relative rejection frequency
End
Draw (mu, rel_freq)

Use \(M=1000\) and the same settings of Figure 6.2. You may use the t.test() function in R to carry out one-sample tests for \(H_0:\mu=\mu_0.\)

Exercise 6.20 Assume that \(X_1\sim\mathcal{N}(\mu,\sigma_1^2)\) and \(X_2\sim\mathcal{N}(\mu,\sigma_2^2).\) Denote \(\theta=\sigma_1^2/\sigma_2^2.\) Let \((X_{11},\ldots,X_{1n_1})\) and \((X_{21},\ldots,X_{2n_2})\) be two srs’s of \(X_1\) and \(X_2,\) respectively. Using Monte Carlo, as explained in Exercise 6.19, obtain and draw the power curves for:

  1. \(H_0:\theta=1\) vs. \(H_1:\theta>1.\)
  2. \(H_0:\theta=1\) vs. \(H_1:\theta<1.\)
  3. \(H_0:\theta=1\) vs. \(H_1:\theta\neq1.\)

Consider \(n_1=25\) and \(n_2=50.\) Use \(M=1000\) and the sequence of \(\theta\) given by theta <- seq(0.1, 10, l = 25).

Exercise 6.21 Find the UMP test for \(H_0:\theta=\theta_0\) vs. \(H_1:\theta=\theta_1\) in a \(\mathrm{Exp}(\theta)\) distribution. Then, obtain the \(p\)-value of such a test for:

  1. \(\theta_0=1\) and \(\theta_1=0.5\) with the sample realization (0.8, 0.2, 1.8, 1.3, 3.8, 0.4, 1.6, 2, 0.4, 1.4, 0.1, 0.6, 2, 2.3, 0.6, 0.2, 0.7, 1.2, 0.3, 1.8, 0.2).
  2. \(\theta_0=2\) and \(\theta_1=1\) with the sample realization (1.6, 14, 0, 8.4, 4.9, 1.7, 0.2, 2.6, 0.9, 0.3, 1.6, 1.7, 2.3, 2.2, 5.6, 2.8, 2.6, 0, 2, 2.7, 4).

Exercise 6.22 The following sample from a \(\mathcal{N}(0,\sigma^2)\) distribution is given: 0, -1.6, 1.4, -0.1, -0.3, 0.5, 0.6, -1.1, 0.1, -1.4, -1.7, 2.8, 2.2, -1, 0.5, 1.1, 1.3, 0.5, 1.2, 0.4, 0.4, -2.2, -0.7, -1.5, -0.7, -1, -0.3, 2.8, 1, -0.9, -0.7, -1.5, 1.2, 0.8.

  1. Find the UMP test for \(H_0:\sigma=1\) vs. \(H_1:\sigma=2.\) Report the \(p\)-value of the above test when applied to the sample.
  2. Repeat part a for \(H_0:\sigma=1\) vs. \(H_1:\sigma=\sigma_1\) with \(\sigma_1=0.75,1.5.\)
  3. Plot the \(p\)-value curve of the test as a function of \(\sigma_1>0\) for \(H_0:\sigma=1\) vs. \(H_1:\sigma=\sigma_1.\)

Exercise 6.23 Validate the asymptotic distribution (6.7) of the likelihood ratio statistic in Theorem 6.2 by Monte Carlo. To do so, first derive and implement the likelihood ratio statistic \(\lambda_n\) for the following testing problems:

  1. \(H_0:\theta=0\) vs. \(H_1:\theta\neq0\) with \((X_1,\ldots,X_n)\sim\mathcal{N}(\theta,1).\)
  2. \(H_0:\theta=1\) vs. \(H_1:\theta\neq1\) with \((X_1,\ldots,X_n)\sim\mathrm{Exp}(\theta).\)
  3. Example 6.20 with \(\theta_1=\theta_2=0.5\) and \(n_1=n_2=n.\)

Then, show a histogram of \(-2\log\lambda_n\) by Monte Carlo and overlay the pdf of \(\chi^2_p.\) Use \(M=1000\) and \(n=10,50,100,500.\) Use the dchisq() function in R to plot the pdf of a chi-square rv.

Exercise 6.24 Let \((X_{11},\ldots,X_{1n_1})\) and \((X_{21},\ldots,X_{2n_2})\) be two srs’s from two independent normal populations \(\mathcal{N}(\mu_1,\sigma_1^2)\) and \(\mathcal{N}(\mu_2,\sigma_2^2),\) respectively. Let us test the equality of populations, that is,

\[\begin{align*} H_0:(\mu_1,\sigma_1^2)=(\mu_2,\sigma_2^2)\quad \text{vs.} \quad H_1:(\mu_1,\sigma_1^2)\neq(\mu_2,\sigma_2^2). \end{align*}\]

  1. Derive the LRT for this problem. Use that, under \(H_0,\) \(\hat{\mu}_\mathrm{MLE}=(n_1\bar{X}_1+n_2\bar{X}_2)/(n_1+n_2)\) and \(\hat{\sigma}^2_\mathrm{MLE}=(n_1S^2_1+n_2S^2_2)/(n_1+n_2).\)
  2. Implement in R a function to conduct this LRT, returning its \(p\)-value.
  3. Check with simulated data that the test works correctly under \(H_0\) (does not reject) and \(H_1\) (rejects).
  4. Apply the LRT to the variables iris$Sepal.Width[iris$Species == "versicolor"] and iris$Sepal.Width[iris$Species == "virginica"] from the iris dataset in R.

Exercise 6.25 Let \(\boldsymbol{X}\sim \mathcal{N}_2(\boldsymbol{\mu},\boldsymbol{\Sigma})\) be a bivariate random vector. Assume that the srs \(\boldsymbol{X}_1,\ldots,\boldsymbol{X}_n\) is iid from \(\boldsymbol{X}.\)

  1. Derive the LRT for \(H_0:\rho=0\) vs. \(H_1:\rho\neq 0.\) Use that \(\hat{\boldsymbol{\mu}}_\mathrm{MLE}=\bar{\boldsymbol{X}}\) and \(\hat{\boldsymbol{\Sigma}}_\mathrm{MLE}=\frac{1}{n}\sum_{i=1}^n (\boldsymbol{X}_i-\bar{\boldsymbol{X}})(\boldsymbol{X}_i-\bar{\boldsymbol{X}})'.\)
  2. Implement in R a function to conduct this LRT, returning its \(p\)-value.
  3. Check with simulated data that the test works correctly under \(H_0\) (does not reject) and \(H_1\) (rejects). Use mvtnorm::rmvnorm() to simulate from a bivariate normal distribution.
  4. Apply the LRT to the variables Sepal.Length and Sepal.Width from the iris dataset in R.