Statistics · FCByF · UNR · Units 4 to 9

Statistical inference

Pick a symbol in the bar, or tap it in any formula, to highlight it throughout the notes.

4

Sampling distributions

Statistics are random variables: they have an expectation, a variance and a distribution.

Concepts
Concept

Random sample, statistic and sampling distribution

Random sample: a set of \(n\) independent random variables \(X_1,\dots,X_n\), each with the same distribution \(f(x)\) as the variable under study.

Statistic: a random variable defined as a function of the random sample (mean, variance, relative frequency…). Its value changes from sample to sample.

Sampling distribution: the probability distribution of a statistic. Knowing its expectation, variance and shape is what makes it possible to estimate and to test hypotheses.

Parameter = fixed, unknown number of the population (\(\pmu,\ \psig^2,\ \pp\)). Statistic = number computed from the sample (\(\bar x,\ s^2,\ h\)).

Statistics and their distributions
Statistic

Sample mean \(\bar X\)

It varies around the population mean, and its spread shrinks as \(n\) grows.

$$E(\bar X)=\pmu_X \qquad V(\bar X)=\frac{\psig^2_X}{n}\qquad \sigma_{\bar X}=\frac{\psig_X}{\sqrt n}$$

If the original variable is normal, \(X\sim N(\pmu_X;\psig_X)\), the mean is normal too for any \(n\). Subtracting its expectation and dividing by its standard deviation gives \(Z\), the standardized mean, which follows a standard normal (mean 0, standard deviation 1):

$$\bar X\sim N\!\left(\pmu_X;\ \frac{\psig_X}{\sqrt n}\right)\quad\Longrightarrow\quad Z=\frac{\bar X-\pmu_X}{\psig_X/\sqrt n}\sim N(0;1)$$
Proof of E and V
  1. $$E(\bar X)=E\Big(\tfrac1n\sum X_i\Big)=\tfrac1n\big[E(X_1)+\dots+E(X_n)\big]=\tfrac1n\,n\pmu_X=\pmu_X$$Linearity of expectation; each \(X_i\) has the distribution of \(X\).
  2. $$V(\bar X)=\tfrac1{n^2}V\Big(\sum X_i\Big)=\tfrac1{n^2}\big[V(X_1)+\dots+V(X_n)\big]=\tfrac{1}{n^2}\,n\psig^2_X=\frac{\psig^2_X}{n}$$The constant comes out squared; the \(X_i\) are independent, so the variance of the sum is the sum of the variances.
Concept · theorem

Central Limit Theorem

If \(X\) has any distribution with mean \(\pmu_X\) and standard deviation \(\psig_X\), for large enough \(n\):

$$\bar X\ \xrightarrow[n\to+\infty]{}\ N\!\left(\pmu_X;\ \frac{\psig_X}{\sqrt n}\right)$$

Rule of thumb: the approximation is valid for \(n\gt 30\). The more skewed \(X\) is, the larger the \(n\) needed. If \(X\) is already normal, \(\bar X\) is normal for any \(n\).

Statistic

Relative frequency \(h(A)\)

Let \(A\) be the event of interest, \(\pp=P(A)\) its probability and \(\pq=1-\pp\). Define \(X=1\) if \(A\) occurs and \(X=0\) otherwise (a Bernoulli variable). If \(f(A)\) is the absolute frequency (number of times \(A\) occurs in the \(n\) trials), then \(h(A)=\frac{f(A)}{n}=\frac{\sum X_i}{n}=\bar X\): the relative frequency is a sample mean.

$$E(h)=\pp\qquad V(h)=\frac{\pp\pq}{n}\qquad h\ \xrightarrow[n\to+\infty]{}\ N\!\left(\pp;\ \sqrt{\frac{\pp\pq}{n}}\right),\quad \pq=1-\pp$$
Proof
  1. $$E(X)=0\cdot \pq+1\cdot \pp=\pp$$Definition of the expectation of a discrete variable.
  2. $$V(X)=(0-\pp)^2\pq+(1-\pp)^2\pp=\pp^2\pq+\pq^2\pp=\pp\pq(\pp+\pq)=\pp\pq$$Definition of variance and \(\pp+\pq=1\).
  3. $$E(h)=E(\bar X)=\pp,\qquad V(h)=V(\bar X)=\frac{V(X)}{n}=\frac{\pp\pq}{n}$$Results for the mean applied to a Bernoulli \(X\); normality follows from the CLT (in practice \(n\gt30\)).
Statistic

Sample variance \(S^2\)

The sample variance is \(S^2=\frac{1}{n-1}\sum_{i=1}^n(X_i-\bar X)^2\). Define \(U\), the standardized sample variance: \(S^2\) multiplied by its degrees of freedom \(n-1\) and divided by the population variance \(\psig_X^2\). If \(X\sim N(\pmu_X;\psig_X)\), \(U\) follows a chi-square distribution with \(n-1\) degrees of freedom (\(\chi^2_{n-1}\)):

$$U=\frac{(n-1)S^2}{\psig_X^2}\sim\chi^2_{n-1}\qquad E(S^2)=\psig_X^2\qquad V(S^2)=\frac{2\psig_X^4}{n-1}$$
Proof of E and V
  1. $$S^2=\frac{U\,\psig^2_X}{n-1},\qquad E(U)=n-1,\quad V(U)=2(n-1)$$Solving for \(S^2\); the expectation and variance of a chi-square are \(gl\) and \(2\,gl\).
  2. $$E(S^2)=\frac{\psig^2_X}{n-1}E(U)=\frac{\psig^2_X}{n-1}(n-1)=\psig^2_X$$The constant comes out of the expectation.
  3. $$V(S^2)=\Big(\frac{\psig^2_X}{n-1}\Big)^2V(U)=\frac{\psig^4_X}{(n-1)^2}\,2(n-1)=\frac{2\psig^4_X}{n-1}$$The constant comes out of the variance squared.
Statistic

Student's T statistic

When, in the standardized mean \(Z\), the (unknown) population standard deviation \(\psig_X\) is replaced by the sample one \(S\), the resulting variable \(T\) is no longer normal: it follows a Student's t with \(n-1\) degrees of freedom (\(t_{n-1}\)):

$$T=\frac{\bar X-\pmu_X}{S/\sqrt n}\sim t_{n-1}\qquad(\text{requiere }X\text{ normal})$$
Proof
  1. $$Z=\frac{\bar X-\pmu_X}{\psig_X/\sqrt n}\sim N(0;1),\qquad U=\frac{(n-1)S^2}{\psig_X^2}\sim\chi^2_{n-1}$$Previous results; for normal \(X\), \(Z\) and \(U\) are independent.
  2. $$T=\frac{Z}{\sqrt{U/(n-1)}}\sim t_{n-1}$$Definition of Student's T variable.
  3. $$T=\frac{\dfrac{\bar X-\pmu_X}{\psig_X/\sqrt n}}{\sqrt{\dfrac{S^2}{\psig^2_X}}}=\frac{\dfrac{\bar X-\pmu_X}{\psig_X/\sqrt n}}{S/\psig_X}=\frac{\bar X-\pmu_X}{S/\sqrt n}$$Substitution and simplification: \(\psig_X\) cancels out.
Statistic

Ratio of variances: Snedecor's F

Take two independent normal populations, \(X_1\sim N(\pmu_1;\psig_1)\) and \(X_2\sim N(\pmu_2;\psig_2)\), and from each a sample of size \(n_1\) and \(n_2\), with sample variances \(S_1^2\) and \(S_2^2\). The ratio of their standardized variances follows a Snedecor's F with \(n_1-1\) and \(n_2-1\) degrees of freedom:

$$\frac{S_1^2/\psig_1^2}{S_2^2/\psig_2^2}\sim F_{n_1-1;\,n_2-1}\qquad\text{y si }\psig_1^2=\psig_2^2:\quad F=\frac{S_1^2}{S_2^2}\sim F_{n_1-1;\,n_2-1}$$
Proof
  1. $$U_1=\frac{(n_1-1)S_1^2}{\psig_1^2}\sim\chi^2_{n_1-1},\qquad U_2=\frac{(n_2-1)S_2^2}{\psig_2^2}\sim\chi^2_{n_2-1}$$Distribution of the sample variance in each population.
  2. $$F=\frac{U_1/(n_1-1)}{U_2/(n_2-1)}=\frac{S_1^2/\psig_1^2}{S_2^2/\psig_2^2}$$Definition of F: ratio of independent chi-squares divided by their degrees of freedom.
  3. If \(\psig_1^2=\psig_2^2\) the population variances cancel out, leaving \(S_1^2/S_2^2\).
Statistical quality control
Concept

Causes of variation and statistical control

  • Assignable causes: identifiable and removable (untrained operator, new batch of reagent, lack of calibration). They produce large variations.
  • Random causes: many small, unavoidable and independent causes (small environmental or electrical fluctuations).
  • In statistical control: the assignable causes have been removed and only the random ones remain.
  • Control sample: reference material with a certified analyte level (\(\pmu\) known). With the process in control, \(X\sim N(\pmu;\psig)\): \(\pmu\) and \(\psig\) are the quality specifications.
Formula

Shewhart chart for the mean

\(X\) is the measurement on the control sample and \(\pmu\), \(\psig\) are the quality specifications. With one measurement per control, \(X\) is plotted; with \(n\) measurements, their mean \(\bar X\) is plotted. The limits are placed \(k\) standard deviations from the center line \(\pmu\) (\(LI\): lower limit; \(LS\): upper):

$$\text{Individual: }\ \pmu\pm k\,\psig\qquad\qquad \text{Media de }n:\ \pmu\pm k\,\frac{\psig}{\sqrt n}$$
  • \(k=1\): contains 68 % (useful to detect patterns).
  • \(k=2\) (exactly 1.96): warning limits, 95 %.
  • \(k=3\) (exactly 2.576 for 99 %): action limits, 99.73 %.
Proof of the lower warning limit
  1. $$P(X\lt LI_{Alerta})=0.025$$We look for the 2.5 and 97.5 percentiles of \(X\).
  2. $$P\Big(Z\lt \frac{LI_{Alerta}-\pmu}{\psig}\Big)=0.025\ \Longrightarrow\ \frac{LI_{Alerta}-\pmu}{\psig}=z_{0.025}=-1.96$$Standardization and standard normal percentile.
  3. $$LI_{Alerta}=\pmu-1.96\,\psig$$Solving. With means of \(n\), \(\psig\) is replaced by \(\psig/\sqrt n\). The action limits follow the same way with \(z_{0.005}=-2.576\).
Formula

Control chart for precision (variance)

The sample variance \(S^2\) of the \(n\) measurements of each control is plotted; \(\psig^2\) is the specified process variance and \(\chi^2_{n-1;\,q}\) the \(q\) percentile of the chi-square with \(n-1\) degrees of freedom. There are only upper limits (\(L_{Alerta}\) and \(L_{Acción}\)):

$$L_{Alerta}=\frac{\psig^2\,\chi^2_{n-1;\,0.95}}{n-1}\qquad L_{Acción}=\frac{\psig^2\,\chi^2_{n-1;\,0.99}}{n-1}$$
Proof
  1. $$P(S^2\lt L_{Alerta})=0.95\Longrightarrow P\Big(\frac{(n-1)S^2}{\psig^2}\lt\frac{(n-1)L_{Alerta}}{\psig^2}\Big)=0.95$$Same transformation on both sides.
  2. $$\frac{(n-1)L_{Alerta}}{\psig^2}=\chi^2_{n-1;\,0.95}\Longrightarrow L_{Alerta}=\frac{\psig^2\chi^2_{n-1;0.95}}{n-1}$$The ratio is a \(\chi^2_{n-1}\); solve.
Concept

Rules for detecting loss of control

  • One point outside the action limits (probability 0.0027 if the process is still in control).
  • Two out of three consecutive points between the warning and action limits.
  • Four out of five consecutive points outside the \(k=1\) limits.
  • Non-random patterns: cyclic (rotation of analysts or equipment), shift in the mean (many points on the same side, e.g. a new batch of reagent), increasing or decreasing trend (a reagent deteriorating), stratified (almost everything within \(k=1\): the actual \(\psig\) is smaller than the one used).
  • On the variance chart: a point beyond the action limit or an increasing trend.
Interactive lab
Interactive chart

Distribution calculator: Z, t, χ² and F

Replaces the tables. Pick the distribution and its degrees of freedom, and ask for a percentile or a probability: the shaded area is the computed probability. It starts with \(\chi^2_{13;\,0.975}\), the percentile used in exercise 5.2.

Interactive chart · simulation

Population, 1000 samples and the distribution of the statistic

1000 samples of size \(n\) are drawn from the chosen population and \(\bar X\) or \(S^2\) is computed in each one. Raise \(n\): the histogram narrows (\(\psig/\sqrt n\)) and, by the CLT, the mean becomes normal even if the population is skewed or bimodal. With \(S^2\), the curve \(\chi^2\) only fits if the population is normal.

Histogram of the 1000 samplesTheoretical distributionParameter value
Worked exercises
Exercise 4.1 Course notes · U4, HDL cholesterol examplethe probability questions were added

Why average? HDL cholesterol

HDL cholesterol concentration in a population is \(X\sim N(50;\,3)\) mg/dL. Compute the probability of getting a value between 49 and 51 mg/dL (a) with a single measurement; (b) with the mean of \(n=10\); (c) with the mean of \(n=40\).

Step-by-step solution
  1. One measurement: $$P(49\lt X\lt 51)=P\Big(\tfrac{49-50}{3}\lt Z\lt\tfrac{51-50}{3}\Big)=P(-0.33\lt Z\lt 0.33)=0.261$$
  2. Mean of 10: \(\sigma_{\bar X}=3/\sqrt{10}=0.949\). $$P(49\lt \bar X\lt 51)=P(-1.05\lt Z\lt 1.05)=0.708$$
  3. Mean of 40: \(\sigma_{\bar X}=3/\sqrt{40}=0.474\). $$P(-2.11\lt Z\lt 2.11)=0.965$$
Conclusion. The probability of landing within 1 mg/dL of the true mean goes from 26 % to 71 % and to 96.5 %: the standard deviation of the mean is divided by \(\sqrt n\).
Exercise 4.2 Workbook · ch. 4, ex. 1part (c) was added

Germination of sunflower seeds

61 % of a population of seeds germinate within a week. A sample of 200 seeds is taken and 130 germinate. (a) Is 0.61 a parameter or a statistic? (b) Compute \(h\) and its distribution. (c) How likely is it to observe \(h\ge 0.65\)?

Step-by-step solution
  1. \(\pp=0.61\) is a parameter (it describes the population). \(h=130/200=0.65\) is a statistic: another sample of 200 would give another value.
  2. With \(n=200\gt30\): $$h\sim N\Big(0.61;\ \sqrt{\tfrac{0.61\cdot0.39}{200}}\Big)=N(0.61;\ 0.0345)$$
  3. $$P(h\ge0.65)=P\Big(Z\ge\tfrac{0.65-0.61}{0.0345}\Big)=P(Z\ge1.16)=0.123$$
Conclusion. In 12 % of samples of 200 seeds a germination of 65 % or more would be observed; the result is consistent with \(\pp=0.61\).
Exercise 4.3 Course notes · U4, examples 2 and 3 (glucose)the values in part (b) are illustrative

Glucose control charts with three daily aliquots

Glucose control sample with \(\pmu=80\) and \(\psig=1.5\) mg/100mL; \(n=3\) aliquots are run each day. (a) Build the charts for the mean and for the variance. (b) Illustrative values: two consecutive days with means 81.9 and 82.1, and one day with \(s^2=11.2\). What can be concluded?

Step-by-step solution
  1. \(\psig/\sqrt3=0.866\). Limits \(80\pm k\cdot0.866\):
    LimitkLowerUpper
    68 %179.1380.87
    Warning278.2781.73
    Action377.4082.60
  2. Variance chart, \(gl=2\), \(\chi^2_{2;0.95}=5.99\), \(\chi^2_{2;0.99}=9.21\): $$L_{Alerta}=\frac{1.5^2\cdot5.99}{2}=6.74\qquad L_{Acción}=\frac{1.5^2\cdot9.21}{2}=10.36\ (\text{mg/100mL})^2$$
  3. 81.9 and 82.1 lie between warning (81.73) and action (82.60): the rule “two out of three consecutive points between warning and action” is met. Also \(s^2=11.2\gt10.36\).
Conclusion. Both charts signal an assignable cause: patient results are not reported until the process has been checked.
Integrative exercises
Exercise 4.4 Workbook · ch. 4, ex. 9Integrative

Out-of-spec tablets: normal or binomial?

8 % of a population of tablets does not meet the Pharmacopoeia specifications. (a) Compute the probability that, in a sample of 150 tablets, the percentage out of spec is at most 10 %. (b) Compute the same probability for a sample of 10. (c) Was the same procedure used in (a) and (b)? Explain.

Step-by-step solution
  1. Let \(A\) = “the tablet is out of spec”, with \(\pp=0.08\) and \(\pq=0.92\). The statistic is the relative frequency \(h=f(A)/n\), with \(E(h)=\pp\) and \(V(h)=\pp\pq/n\).
  2. (a) n = 150. Since \(n\gt30\), by the CLT \(h\) is approximately normal: $$h\sim N\Big(0.08;\ \sqrt{\tfrac{0.08\cdot0.92}{150}}\Big)=N(0.08;\ 0.0222)$$ $$P(h\le0.10)=P\Big(Z\le\frac{0.10-0.08}{0.0222}\Big)=P(Z\le0.90)=0.8159$$
  3. (b) n = 10. With \(n\le30\) the CLT does not apply. Use the exact distribution of the absolute frequency: \(f(A)\sim\text{Binomial}(10;\ 0.08)\). Since \(h\le0.10\iff f(A)\le1\): $$P(f(A)\le1)=0.92^{10}+10\cdot0.08\cdot0.92^{9}=0.4344+0.3777=0.8121$$
  4. (c) No: in (a) the distribution of \(h\) was approximated by a normal; in (b) the exact binomial was used. Had the normal been used in (b), \(\sigma_h=\sqrt{0.08\cdot0.92/10}=0.0858\) would give \(P(Z\le0.23)=0.592\), far from the correct value 0.8121.
Conclusion. The probability is 0.816 with n = 150 and 0.812 with n = 10. The normal approximation for \(h\) requires large samples; with small samples you have to work with the binomial.
Exercise 4.5 Workbook · ch. 4, ex. 11Integrative

Serum cholesterol: charts for the mean and the variance over 20 days

An enzymatic method for serum cholesterol was brought into control. A control mix with \(\pmu=210\) mg/dL and \(\psig=3\) mg/dL is used, with three measurements per day. (a) Build the control charts. (b) With the means and variances of the next 20 days, can it be concluded that the process stayed in control?

Day12345678910
x̄209.7211.3206.7211.0210.0211.7209.0207.7210.0210.0
s²6.339.332.3312.0316.006.3312.004.334.0012.00
Day11121314151617181920
x̄211.3211.3210.0207.7209.7208.7212.0209.7211.3209.3
s²2.3312.337.002.335.336.333.002.336.3341.33
Step-by-step solution
  1. Mean chart (mean of \(n=3\)): \(\psig/\sqrt n=3/\sqrt3=1.732\) and limits \(210\pm k\cdot1.732\).
    LimitkLowerUpper
    68 %1208.27211.73
    Warning2206.54213.46
    Action3204.80215.20
  2. Variance chart, with \(gl=n-1=2\): $$L_{Alerta}=\frac{3^2\cdot\chi^2_{2;0.95}}{2}=\frac{9\cdot5.99}{2}=26.96\qquad L_{Acción}=\frac{9\cdot9.21}{2}=41.45\ (\text{mg/dL})^2$$
  3. Means. None falls outside the warning limits. Only days 3 (206.7), 8 (207.7), 14 (207.7) and 17 (212.0) fall outside \(k=1\), in isolation: never 4 out of 5 in a row. There are 9 means below 210, 7 above and 4 equal, with no runs or trends.
  4. Variances. The first 19 are below 26.96. On day 20, \(s^2=41.33\) lies between the warning and the action limit, very close to the latter.
Conclusion. Over the 20 days the process stayed in statistical control: no point exceeded an action limit and no patterns appeared. But the precision on day 20 is borderline: the following days should be watched, because another point between warning and action would signal loss of control.
5

Parameter estimation

Point estimation and confidence intervals; sample size.

Concepts
Concept

Estimator and estimate

Estimator of \(\theta\): a random variable that is a function of the sample, \(\hat\theta=g(X_1,\dots,X_n)\). Estimate: the observed value of the estimator once the sample has been obtained.

Example from the notes: with 40 individuals, \(\bar x=50.3\) mg/dL was obtained; 50.3 is an estimate of the mean HDL cholesterol.

Concept

Properties of a good estimator

  • Unbiased: \(E(\hat\theta)=\theta\).
  • Consistent (among unbiased ones): \(V(\hat\theta)\to0\) as \(n\to+\infty\).
ParameterEstimatorExpectationVariance
\(\pmu_X\)\(\bar X\)\(\pmu_X\)\(\psig^2_X/n\)
\(\psig^2_X\)\(S^2_X\)\(\psig^2_X\)\(2\psig^4_X/(n-1)\)
\(\pp=P(A)\)\(h(A)\)\(\pp\)\(\pp\pq/n\)
Why divide by \(n-1\) and not by \(n\)
  1. $$S'^2=\frac1n\sum(x_i-\bar x)^2=\frac{n-1}{n}S^2$$Relationship between both versions.
  2. $$E(S'^2)=\frac{n-1}{n}E(S^2)=\frac{n-1}{n}\psig^2_X\ \lt\ \psig^2_X$$\(S'^2\) is biased: it underestimates the population variance. \(S^2\) is unbiased.
Concept

Confidence interval: steps and interpretation

  1. Define the parameter \(\theta\).
  2. Choose a good estimator \(\hat\theta\).
  3. Set the confidence \(1-\alpha\) (usually 0.90, 0.95, 0.99).
  4. Define a variable \(Y\) that contains \(\theta\) and \(\hat\theta\), with a known distribution (with other parameters known).
  5. Set up \(P(y_{\alpha/2}\le Y\le y_{1-\alpha/2})=1-\alpha\) and solve for \(\theta\).
  6. Take the sample and compute \((a;\,b)\).
  7. Conclude with confidence \(1-\alpha\) that \((a;\,b)\) covers \(\theta\).

If sampling were repeated many times, \((1-\alpha)\cdot100\)% of the intervals would cover the true \(\theta\). It is not “the probability that \(\theta\) lies in this interval”: \(\theta\) is fixed; what is random is the interval.

The half-width \(d\) (margin of error) measures precision: the higher the confidence, the wider the interval; the larger \(n\), the narrower.

Formulas
Formula · CI

CI for \(\pmu\), normal population with known \(\psig\)

$$\bar x\pm z_{1-\alpha/2}\,\frac{\psig_X}{\sqrt n}$$

By the CLT it holds for any \(X\) with known \(\psig\) if \(n\) is large.

Proof
  1. $$P\Big(z_{\alpha/2}\le\frac{\bar X-\pmu_X}{\psig_X/\sqrt n}\le z_{1-\alpha/2}\Big)=1-\alpha$$\(Z\sim N(0;1)\) contains the parameter and the estimator.
  2. $$P\Big(z_{\alpha/2}\tfrac{\psig_X}{\sqrt n}\le\bar X-\pmu_X\le z_{1-\alpha/2}\tfrac{\psig_X}{\sqrt n}\Big)=1-\alpha$$Multiply by \(\psig_X/\sqrt n\gt0\).
  3. $$P\Big(\bar X-z_{\alpha/2}\tfrac{\psig_X}{\sqrt n}\ge\pmu_X\ge\bar X-z_{1-\alpha/2}\tfrac{\psig_X}{\sqrt n}\Big)=1-\alpha$$Subtract \(\bar X\) and multiply by \(-1\) (the inequalities flip).
  4. $$P\Big(\bar X-z_{1-\alpha/2}\tfrac{\psig_X}{\sqrt n}\le\pmu_X\le\bar X+z_{1-\alpha/2}\tfrac{\psig_X}{\sqrt n}\Big)=1-\alpha$$Symmetry of the normal: \(z_{\alpha/2}=-z_{1-\alpha/2}\).
Formula · sample size

Sample size to estimate \(\pmu\)

$$d=z_{1-\alpha/2}\frac{\psig_X}{\sqrt n}\quad\Longrightarrow\quad n=\Big(\frac{z_{1-\alpha/2}\,\psig_X}{d}\Big)^2$$

Higher confidence, higher precision (smaller \(d\)) or a more heterogeneous population (larger \(\psig\)) require a larger \(n\). Round up. If \(\psig\) is unknown, use a value from previous studies or from a pilot sample.

Formula · CI

CI for \(\pmu\), normal population with unknown \(\psig\)

$$\bar x\pm t_{n-1;\,1-\alpha/2}\,\frac{s_X}{\sqrt n}$$
Proof
  1. $$P\Big(t_{n-1;\alpha/2}\le\frac{\bar X-\pmu_X}{S_X/\sqrt n}\le t_{n-1;1-\alpha/2}\Big)=1-\alpha$$\(T\sim t_{n-1}\) replaces \(Z\) because \(\psig_X\) is estimated by \(S_X\).
  2. Solving as with \(Z\) and using the symmetry \(t_{n-1;\alpha/2}=-t_{n-1;1-\alpha/2}\) gives \(\bar X\pm t_{n-1;1-\alpha/2}S_X/\sqrt n\).
Formula · CI

CI for \(\psig^2\) of a normal population

$$\left(\frac{(n-1)s^2_X}{\chi^2_{n-1;\,1-\alpha/2}}\ ;\ \frac{(n-1)s^2_X}{\chi^2_{n-1;\,\alpha/2}}\right)$$

It is not symmetric around \(s^2\): the chi-square is skewed. The larger percentile goes in the denominator of the lower limit.

Proof
  1. $$P\Big(\chi^2_{n-1;\alpha/2}\le\frac{(n-1)S^2_X}{\psig^2_X}\le\chi^2_{n-1;1-\alpha/2}\Big)=1-\alpha$$\(U\sim\chi^2_{n-1}\).
  2. $$P\Big(\frac{\chi^2_{n-1;\alpha/2}}{(n-1)S^2_X}\le\frac1{\psig^2_X}\le\frac{\chi^2_{n-1;1-\alpha/2}}{(n-1)S^2_X}\Big)=1-\alpha$$Divide by \((n-1)S^2_X\gt0\).
  3. $$P\Big(\frac{(n-1)S^2_X}{\chi^2_{n-1;1-\alpha/2}}\le\psig^2_X\le\frac{(n-1)S^2_X}{\chi^2_{n-1;\alpha/2}}\Big)=1-\alpha$$Take reciprocals (the inequalities flip) and reorder.
Formula · CI and size

CI for a proportion \(\pp\) (large samples)

$$h\pm z_{1-\alpha/2}\sqrt{\frac{h(1-h)}{n}}\qquad\qquad n=\frac{z^2_{1-\alpha/2}\,\pp'\pq'}{d^2}$$

\(\pp'\) comes from previous studies or a pilot sample. Conservative option: \(\pp'=0.5\), which maximizes \(\pp'\pq'\) and gives the largest \(n\).

Proof
  1. $$Z=\frac{h-\pp}{\sqrt{h(1-h)/n}}\sim N(0;1)$$CLT; the variance \(\pp\pq/n\) depends on the parameter, so \(\pp\) and \(\pq\) are replaced by \(h\) and \(1-h\).
  2. $$P\Big(h-z_{1-\alpha/2}\sqrt{\tfrac{h(1-h)}{n}}\le\pp\le h+z_{1-\alpha/2}\sqrt{\tfrac{h(1-h)}{n}}\Big)=1-\alpha$$Same solving as for the mean, with \(z_{\alpha/2}=-z_{1-\alpha/2}\).
Interactive lab
Interactive chart · simulation

What does “90 % confidence” mean?

Fifty samples of a sodium solution with \(\pmu=2\) mg/L and \(\psig=0.2\) mg/L, as in exercise 4 of the workbook. Each bar is an interval; the ones that miss \(\pmu\) are in red. Generate several times: the cumulative percentage approaches the chosen confidence. Change the confidence or \(n\) to see how the width changes.

Covers μMisses μμ = 2 mg/L
Worked exercises
Exercise 5.1 Workbook · ch. 5, ex. 3

Yield of a new maize variety

Yields (qq/ha) in 12 plots in southern Santa Fe; a normal distribution is assumed. Estimate the mean yield with a point estimate and with a 95 % CI.

888574699370876589799384
Step-by-step solution
  1. Point estimate: \(\hat{\pmu}=\bar x=81.33\) qq/ha; \(s=9.70\).
  2. \(\psig\) unknown and \(n=12\): use \(t_{11;\,0.975}=2.201\). $$81.33\pm2.201\cdot\frac{9.70}{\sqrt{12}}=81.33\pm6.16$$
  3. CI: \((75.17;\ 87.50)\) qq/ha.
Conclusion. With 95 % confidence, the interval (75.2; 87.5) qq/ha covers the mean yield of the variety in the area.
Exercise 5.2 Workbook · ch. 5, ex. 6

Antioxidant capacity (FRAP) of wild raspberries

FRAP values (µg Fe/g dry weight) in 14 raspberries; normal variable. (a) Point estimates of the mean and the variance. (b) 99 % CI for the mean. (c) 95 % CI for the variance. (d) What \(n\) halves the width of (b)?

16.420.017.111.717.911.212.5
15.216.019.313.213.714.418.6
Step-by-step solution
  1. \(\bar x=15.51\), \(s^2=8.11\), \(s=2.848\).
  2. \(t_{13;0.995}=3.012\): $$15.51\pm3.012\cdot\frac{2.848}{\sqrt{14}}=15.51\pm2.29$$ CI: \((13.22;\ 17.81)\) µg Fe/g.
  3. \(\chi^2_{13;0.975}=24.74\), \(\chi^2_{13;0.025}=5.01\): $$\Big(\frac{13\cdot8.11}{24.74};\ \frac{13\cdot8.11}{5.01}\Big)=(4.26;\ 21.05)\ (\text{µg Fe/g})^2$$
  4. New margin \(d=2.29/2=1.146\); with \(\psig\approx s\): \(n=\big(\frac{2.576\cdot2.848}{1.146}\big)^2=40.9\Rightarrow n=41\).
Conclusion. Mean between 13.2 and 17.8 µg Fe/g (99 %), variance between 4.3 and 21.1 (95 %). Doubling the precision takes 41 raspberries: halving \(d\) almost triples \(n\).
Exercise 5.3 Workbook · ch. 5, ex. 7

Poor eating habits

We want to estimate the proportion of people with poor eating habits in a city. (a) Sample size for 95 % confidence and a 4 % margin, if 12 out of 40 had them in a pilot. (b) Out of 500 people, 124 have them: estimate.

Step-by-step solution
  1. \(\pp'=12/40=0.30\): $$n=\frac{1.96^2\cdot0.30\cdot0.70}{0.04^2}=504.2\Rightarrow n=505$$
  2. \(h=124/500=0.248\) (unbiased and consistent estimator of \(\pp\)).
  3. $$0.248\pm1.96\sqrt{\frac{0.248\cdot0.752}{500}}=0.248\pm0.038\Rightarrow(0.210;\ 0.286)$$
Conclusion. With 95 % confidence, between 21.0 % and 28.6 % of the population has poor eating habits.
Integrative exercises
Exercise 5.4 Workbook · ch. 5, ex. 4Integrative

Twenty sodium aliquots: coverage and width of the intervals

To estimate the sodium concentration of a solution, 9 measurements are made on an aliquot. The experiment is repeated with 20 aliquots of the same solution. The workbook gives the 18 intervals of the other aliquots; those for aliquots 4 and 15 are missing (mg/L):

Aliquot 41.981.882.111.621.392.151.701.991.95
Aliquot 152.161.831.891.752.031.981.721.871.95

(a) 90 % CI for aliquots 4 and 15 with \(\psig=0.2\) mg/L. (b) If the true value is 2 mg/L, what proportion of the 20 intervals covers it? (c) Repeat assuming \(\psig\) unknown. (d) With a 95 % CI, how does the width change and how many intervals are expected to cover the true value? (e) What happens to the width if the number of measurements per aliquot increases?

Step-by-step solution
  1. (a) σ known. \(z_{0.95}=1.645\) and \(\psig/\sqrt n=0.2/3=0.0667\): half-width \(d=1.645\cdot0.0667=0.110\), the same for all aliquots. $$\text{Aliquot 4: }\bar x=1.863\Rightarrow(1.753;\ 1.973)\qquad\text{Aliquot 15: }\bar x=1.909\Rightarrow(1.799;\ 2.019)$$
  2. (b) With \(\pmu=2\), aliquot 2 \((2.020;\ 2.240)\) and aliquot 4 \((1.753;\ 1.973)\) miss it: 18 out of 20 cover it, i.e. 90 %, equal to the confidence. That is what to expect: in the long run, 90 % of the intervals built this way cover \(\pmu\).
  3. (c) σ unknown. Use \(t_{8;0.95}=1.860\) and the standard deviation of each aliquot: $$\text{Aliquot 4: }s=0.248\Rightarrow 1.863\pm1.860\cdot\tfrac{0.248}{3}=(1.709;\ 2.017)$$ $$\text{Aliquot 15: }s=0.139\Rightarrow 1.909\pm1.860\cdot\tfrac{0.139}{3}=(1.823;\ 1.995)$$ Now the widths change from one aliquot to another because \(s\) varies. Aliquot 2 \((2.013;\ 2.247)\) and aliquot 15 miss it: again 18 out of 20 (90 %), although different intervals fail.
  4. (d) 95 %. The intervals are wider: with σ known the half-width goes from 0.110 to \(1.96\cdot0.0667=0.131\); with σ unknown the critical value goes from 1.860 to \(t_{8;0.975}=2.306\). 19 out of the 20 are expected to cover it.
  5. (e) The half-width is \(z\,\psig/\sqrt n\) (or \(t\,s/\sqrt n\)): increasing \(n\) at the same confidence narrows the intervals in proportion to \(1/\sqrt n\); with σ unknown the t percentile also drops.
Conclusion. Confidence is not a property of a particular interval but of the procedure: in both cases 18 out of 20 intervals cover the true value. More confidence means wider intervals; more measurements, narrower intervals.
Exercise 5.5 Workbook · ch. 5, ex. 15Integrative

Active ingredient in tablets: plan the sample and estimate

We want to estimate the mean content of the active ingredient of a product. The variable is normal with \(\psig=0.0068\) g. (a) How many tablets must be processed to estimate with a margin of error of 0.005 g and 99 % confidence? (b) Estimate with an interval using the results obtained (g):

0.84030.83630.84470.84900.83520.8471
0.83120.84120.84560.83690.84780.8302
Step-by-step solution
  1. (a) With \(z_{0.995}=2.576\): $$n=\Big(\frac{z_{0.995}\,\psig}{d}\Big)^2=\Big(\frac{2.576\cdot0.0068}{0.005}\Big)^2=12.27\Rightarrow n=13$$ Always round up, so as not to exceed the required margin.
  2. (b) With the 12 values: \(\bar x=0.84046\) g. Since \(\psig\) is known, use \(z\): $$0.84046\pm2.576\cdot\frac{0.0068}{\sqrt{12}}=0.84046\pm0.00506\Rightarrow(0.8355;\ 0.8455)\ \text{g}$$
  3. With 12 tablets (one fewer than planned) the margin turns out to be 0.00506 g, slightly above the required 0.005: that is why the calculation in (a) gave 13.
Conclusion. With 99 % confidence, the mean content of the active ingredient is between 0.8355 and 0.8455 g.
6

Hypothesis tests based on one sample

Mean, proportion and variance; errors, power and sample size.

Concepts
Concept

Null and alternative hypotheses

\(H_0\): statement about the parameter that represents the status quo; it is assumed true and is not rejected without sufficient evidence. \(H_1\): the research question, which contradicts \(H_0\).

Possible conclusions: reject \(H_0\) (strong conclusion, \(\alpha\) bounded) or do not reject \(H_0\) (weak conclusion, \(\beta\) not bounded). That is why we never say “\(H_0\) is accepted”.

The trial analogy: \(H_0\) “innocent”, \(H_1\) “guilty”. Failing to convict for lack of evidence does not prove innocence.

  • Simple: a single value (\(\pmu=50\)). Composite: several (\(\pmu\gt50\)).
  • Right-tailed (\(H_1:\theta\gt\theta_0\)), left-tailed (\(\theta\lt\theta_0\)) or two-tailed (\(\theta\ne\theta_0\)): defines the tail of the rejection region.
Concept

Type I and II errors, power

Decision\(H_0\) true\(H_0\) false
Reject \(H_0\)Type I error (\(\alpha\))Correct (power \(1-\beta\))
Do not reject \(H_0\)CorrectType II error (\(\beta\))
$$\alpha=P(\text{rech. }H_0\mid H_0\text{ cierta})\qquad\beta=P(\text{no rech. }H_0\mid H_0\text{ falsa})\qquad \text{Potencia}=1-\beta$$
  • With \(n\) fixed, lowering \(\alpha\) raises \(\beta\). Only increasing \(n\) lowers both.
  • \(\alpha\) is fixed (significance level: 0.01, 0.05, 0.10) and the rejection region is built from it; \(\beta\) depends on the true value of the parameter.
  • Power increases the farther \(\pmu_1\) is from \(\pmu_0\), the smaller \(\psig\) is and the larger \(n\) is.
Concept

Test statistic, rejection region and p-value

Test statistic: function of the sample on which the decision is based. Critical region: values of the statistic that lead to rejecting \(H_0\). Critical value \(c_\alpha\): separates the regions; it is derived from \(P(E_I)=\alpha\).

p-value (associated probability): probability of observing a value of the statistic as extreme as or more extreme than the one obtained, assuming \(H_0\) is true. A single rule for every test: reject \(H_0\) if \(p_{asoc}\le\alpha\).

Steps: (1) hypotheses, (2) \(\alpha\), (3) test statistic and its distribution under \(H_0\), (4) rejection region, (5) sample and observed value, (6) decision and conclusion in terms of the problem.

Formulas
Formula · test

Test for \(\pmu\) with known \(\psig\)

$$z_{obs}=\frac{\bar x_{obs}-\pmu_0}{\psig/\sqrt n}$$
\(H_1\)Reject \(H_0\) if\(p_{asoc}\)
\(\pmu\gt\pmu_0\)\(\bar x\ge\pmu_0+z_{1-\alpha}\frac{\psig}{\sqrt n}\) ⇔ \(z_{obs}\ge z_{1-\alpha}\)\(P(Z\ge z_{obs})\)
\(\pmu\lt\pmu_0\)\(\bar x\le\pmu_0-z_{1-\alpha}\frac{\psig}{\sqrt n}\) ⇔ \(z_{obs}\le -z_{1-\alpha}\)\(P(Z\le z_{obs})\)
\(\pmu\ne\pmu_0\)\(|z_{obs}|\ge z_{1-\alpha/2}\)\(2P(Z\ge|z_{obs}|)\)
Proof of the critical value (right-tailed)
  1. $$P(E_I)=\alpha\Rightarrow P(\text{rech. }H_0\mid H_0\text{ cierta})=\alpha$$Definition of type I error.
  2. $$P(\bar X\ge c_\alpha\mid\pmu=\pmu_0)=\alpha$$Type I error in this test.
  3. $$P\Big(Z\ge\frac{c_\alpha-\pmu_0}{\psig/\sqrt n}\Big)=\alpha$$Under \(H_0\), \(\bar X\sim N(\pmu_0;\psig/\sqrt n)\).
  4. $$\frac{c_\alpha-\pmu_0}{\psig/\sqrt n}=z_{1-\alpha}\Rightarrow c_\alpha=\pmu_0+z_{1-\alpha}\frac{\psig}{\sqrt n}$$Standard normal percentile and solving. In the two-tailed test, \(\alpha/2\) goes to each tail.
Formula · power

Type II error, power and sample size

For \(H_0:\pmu=\pmu_0\) vs \(H_1:\pmu\gt\pmu_0\), if the true mean is \(\pmu_1\):

$$\beta=P\Big(Z\lt\frac{c_\alpha-\pmu_1}{\psig/\sqrt n}\Big)\qquad n=\frac{(z_{1-\alpha}+z_{1-\beta})^2\,\psig^2}{(\pmu_0-\pmu_1)^2}$$

The same formula for \(n\) holds for the left-tailed test.

Proof of the formula for \(n\)
  1. $$P(\bar X\lt c_\alpha\mid\pmu=\pmu_1)=\beta$$Definition of type II error in this test.
  2. $$P\Big(Z\lt\frac{\pmu_0+z_{1-\alpha}\psig/\sqrt n-\pmu_1}{\psig/\sqrt n}\Big)=P\Big(Z\lt\frac{\pmu_0-\pmu_1}{\psig/\sqrt n}+z_{1-\alpha}\Big)=\beta$$Substitute \(c_\alpha\) and standardize under \(H_1\).
  3. $$-z_{1-\beta}=\frac{\pmu_0-\pmu_1}{\psig}\sqrt n+z_{1-\alpha}$$The right-hand side is the \(z_\beta=-z_{1-\beta}\) percentile.
  4. $$\sqrt n=\frac{(-z_{1-\beta}-z_{1-\alpha})\psig}{\pmu_0-\pmu_1}\Rightarrow n=\frac{(z_{1-\alpha}+z_{1-\beta})^2\psig^2}{(\pmu_0-\pmu_1)^2}$$Solving and squaring.
Formula · test

Test for \(\pmu\) with unknown \(\psig\) (Student's t)

$$t_{obs}=\frac{\bar x_{obs}-\pmu_0}{s/\sqrt n}\qquad T\overset{H_0}{\sim}t_{n-1}$$

Right: reject if \(t_{obs}\ge t_{n-1;1-\alpha}\) (equivalent to \(\bar x\ge\pmu_0+t_{n-1;1-\alpha}\,s/\sqrt n\)). Left: \(t_{obs}\le-t_{n-1;1-\alpha}\). Two-tailed: \(|t_{obs}|\ge t_{n-1;1-\alpha/2}\), \(p=2P(T\ge|t_{obs}|)\). Requires normal \(X\).

Formula · test

Test for a proportion \(\pp\)

$$z_{obs}=\frac{h_{obs}-\pp_0}{\sqrt{\pp_0\pq_0/n}}\qquad h\overset{H_0}{\sim}N\Big(\pp_0;\sqrt{\tfrac{\pp_0\pq_0}{n}}\Big),\quad n\ge30$$

Right: \(c_\alpha=\pp_0+z_{1-\alpha}\sqrt{\pp_0\pq_0/n}\). Left: \(\pp_0-z_{1-\alpha}\sqrt{\cdot}\). Two-tailed: \(|z_{obs}|\ge z_{1-\alpha/2}\).

The test uses \(\pp_0\pq_0\) (the value under \(H_0\)); the interval uses \(h(1-h)\).

Proof of the critical value (right)
  1. $$P(h\ge c_\alpha\mid\pp=\pp_0)=\alpha\Rightarrow P\Big(Z\ge\frac{c_\alpha-\pp_0}{\sqrt{\pp_0\pq_0/n}}\Big)=\alpha$$Type I error and normality of \(h\) under \(H_0\).
  2. $$c_\alpha=\pp_0+z_{1-\alpha}\sqrt{\frac{\pp_0\pq_0}{n}}$$Percentile and solving.
Formula · test

Test for \(\psig^2\) of a normal population

\(H_0:\psig^2=\psig_0^2\) vs \(H_1:\psig^2\gt\psig_0^2\) (loss of precision):

$$u_{obs}=\frac{(n-1)s^2_{obs}}{\psig^2_0}\qquad\text{rechazar si }u_{obs}\ge\chi^2_{n-1;1-\alpha}\ \Leftrightarrow\ s^2_{obs}\ge\frac{\chi^2_{n-1;1-\alpha}\,\psig_0^2}{n-1}$$
Proof
  1. $$P(S^2\ge c_\alpha\mid\psig^2=\psig^2_0)=\alpha\Rightarrow P\Big(\frac{(n-1)S^2}{\psig^2_0}\ge\frac{(n-1)c_\alpha}{\psig^2_0}\Big)=\alpha$$Both sides are multiplied by the same constant.
  2. $$\frac{(n-1)c_\alpha}{\psig^2_0}=\chi^2_{n-1;1-\alpha}\Rightarrow c_\alpha=\frac{\chi^2_{n-1;1-\alpha}\psig^2_0}{n-1}$$\(U\sim\chi^2_{n-1}\); percentile and solving.
Interactive lab
Interactive chart

Rejection regions, α, β and power

Test for \(\pmu\) with known \(\psig\). The blue curve is the distribution of \(\bar X\) if \(H_0\) is true; the orange one, if the true mean is \(\pmu_1\). Move \(\pmu_1\), \(n\), \(\psig\) or \(\alpha\) and watch how the areas split. The initial values come from the hepcidin exercise (6.2).

α: reject with H₀ trueβ: do not reject with H₁ truePower 1 − βp-valuerejection regionnon-rejection
Worked exercises
Exercise 6.1 Workbook · ch. 6, ex. 3

Arsenic in water: is reverse osmosis needed?

The maximum allowed is 0.05 mg/L. It was measured over 10 days (mg/L). Is there evidence that the maximum is exceeded with \(\alpha=0.05\)? And with \(\alpha=0.01\)?

0.0720.0620.0670.0690.0800.0360.0860.0810.0760.022
Step-by-step solution
  1. \(H_0:\pmu\le0.05\) vs \(H_1:\pmu\gt0.05\) (the equipment is installed only with evidence).
  2. \(\bar x=0.0651\), \(s=0.0206\), \(n=10\). $$t_{obs}=\frac{0.0651-0.05}{0.0206/\sqrt{10}}=2.32$$
  3. \(t_{9;0.95}=1.833\); critical value in mg/L: \(c_\alpha=0.05+1.833\cdot0.0206/\sqrt{10}=0.0619\). \(\bar x=0.0651\ge0.0619\).
  4. \(p_{asoc}=P(T\ge2.32)=0.0227\).
  5. With \(\alpha=0.01\): \(t_{9;0.99}=2.821\gt2.32\) and \(p=0.0227\gt0.01\): not rejected.
Conclusion. At the 5 % significance level there is evidence that mean arsenic exceeds 0.05 mg/L, and installing the equipment is recommended (p = 0.023). At 1 % the evidence is not enough.
Exercise 6.2 Workbook · ch. 6, ex. 5

Hepcidin in thalassemia carriers

In the general population the mean is 21 ng/mL. It was measured in 12 carriers. (a) Is it lower in carriers? (\(\alpha=0.05\)). (b) Power if the true mean is 17 ng/mL (\(\psig=5\)). (c) What \(n\) gives power 0.95?

7.25.215.414.116.220.510.813.59.512.111.7523.1
Step-by-step solution
  1. The normal probability plot in the workbook shows aligned points: normality is accepted. \(H_0:\pmu=21\) vs \(H_1:\pmu\lt21\).
  2. \(\bar x=13.28\), \(s=5.12\): $$t_{obs}=\frac{13.28-21}{5.12/\sqrt{12}}=-5.22\lt -t_{11;0.95}=-1.796,\quad p=0.00014$$
  3. Power with \(\psig=5\): \(c_\alpha=21-1.645\cdot5/\sqrt{12}=18.63\). $$1-\beta=P(\bar X\le18.63\mid\pmu=17)=P\Big(Z\le\frac{18.63-17}{5/\sqrt{12}}\Big)=P(Z\le1.13)=0.870$$
  4. $$n=\frac{(1.645+1.645)^2\cdot5^2}{(21-17)^2}=16.9\Rightarrow n=17$$
Conclusion. Mean hepcidin in carriers is significantly lower than 21 ng/mL (p < 0.001). With 12 patients, the test detects a drop to 17 ng/mL with probability 0.87; for 0.95, 17 patients are needed.
Exercise 6.3 Workbook · ch. 6, ex. 7

Side effects of a painkiller

Out of 440 arthritis patients, 23 had some side effect. Can the percentage be assumed to be below 10 %? (\(\alpha=0.05\)). Estimate the proportion with 95 %.

Step-by-step solution
  1. \(H_0:\pp=0.10\) vs \(H_1:\pp\lt0.10\). \(h=23/440=0.0523\).
  2. $$z_{obs}=\frac{0.0523-0.10}{\sqrt{0.10\cdot0.90/440}}=\frac{-0.0477}{0.0143}=-3.34$$
  3. \(-3.34\lt-1.645\); \(p_{asoc}=P(Z\le-3.34)=0.0004\).
  4. 95 % CI: $$0.0523\pm1.96\sqrt{\frac{0.0523\cdot0.9477}{440}}=0.0523\pm0.0208$$ that is, \((0.031;\ 0.073)\).
Conclusion. There is evidence that fewer than 10 % of patients suffer side effects (p = 0.0004); the estimate is between 3.1 % and 7.3 %.
Integrative exercises
Exercise 6.4 Workbook · ch. 6, ex. 4Integrative

Malathion: switch suppliers? Sample size, test, power and CI

A calibration curve uses malathion with 99.2 % purity. Supplier B offers a product of higher purity. Purity is normal with \(\psig=0.1\) %. (a) State the hypotheses. (b) Minimum number of measurements to have probability 0.05 of recommending the switch when purity equals the usual one, and 0.01 of staying with the usual supplier when B's is 0.15 % higher. (c) Test the hypotheses with 10 measurements of B. (d) Is the power with 10 measurements greater or less than 0.99? (e) If \(H_0\) is rejected, estimate B's purity with a 95 % CI.

99.3599.3799.2599.3299.4499.1899.2299.2899.4199.15
Step-by-step solution
  1. (a) \(H_0:\pmu=99.2\) % vs \(H_1:\pmu\gt99.2\) %. The supplier is switched only with evidence of higher purity.
  2. (b) \(\alpha=0.05\) (\(z_{0.95}=1.645\)), \(\beta=0.01\) (\(z_{0.99}=2.326\)) and \(\pmu_1=99.35\): $$n=\frac{(1.645+2.326)^2\cdot0.1^2}{(99.2-99.35)^2}=7.01$$ The workbook reports 7 measurements.
  3. (c) \(\bar x=99.297\) %, \(\psig/\sqrt{10}=0.0316\): $$z_{obs}=\frac{99.297-99.2}{0.0316}=3.07\gt z_{0.95}=1.645,\qquad c_\alpha=99.2+1.645\cdot0.0316=99.252$$ \(p_{asoc}=P(Z\ge3.07)=0.0011\). \(H_0\) is rejected.
  4. (d) With 10 measurements (more than the 7 needed) the power exceeds 0.99: $$1-\beta=P(\bar X\ge99.252\mid\pmu=99.35)=P\Big(Z\ge\frac{99.252-99.35}{0.0316}\Big)=P(Z\ge-3.10)=0.999$$
  5. (e) $$99.297\pm1.96\cdot0.0316=99.297\pm0.062\Rightarrow(99.24;\ 99.36)\ \%$$
Conclusion. There is evidence that B's product is purer (p = 0.001), and the test had more than enough power to detect it. Its mean purity is between 99.24 % and 99.36 % (95 %): switching suppliers is recommended.
Exercise 6.5 Workbook · ch. 6, ex. 9Integrative

Creatinine: accuracy and precision of the enzymatic method

30 repeated creatinine measurements were made on a 0.8 mg/dL solution, with \(\bar x=0.81\) mg/dL and \(s=0.025\) mg/dL. (a) Test the hypothesis that there are only random errors (\(\alpha=0.01\)). (b) The maximum accepted variability is a coefficient of variation of 5 %. Is there evidence to reject that the process meets this specification? (\(\alpha=0.05\)).

Step-by-step solution
  1. (a) Accuracy. “Only random errors” means no systematic error: the mean of the measurements is the true value. \(H_0:\pmu=0.8\) vs \(H_1:\pmu\ne0.8\) (two-tailed).
  2. $$t_{obs}=\frac{0.81-0.8}{0.025/\sqrt{30}}=2.19\qquad t_{29;0.995}=2.756\qquad p_{asoc}=2P(T\ge2.19)=0.0367$$ Since \(|t_{obs}|\lt2.756\) (and \(p\gt0.01\)), \(H_0\) is not rejected.
  3. (b) Precision. A CV of 5 % on 0.8 mg/dL: \(\psig_0=0.05\cdot0.8=0.04\) mg/dL, \(\psig_0^2=0.0016\). \(H_0:\psig^2\le0.0016\) vs \(H_1:\psig^2\gt0.0016\).
  4. $$u_{obs}=\frac{(n-1)s^2}{\psig_0^2}=\frac{29\cdot0.025^2}{0.0016}=11.33\qquad\chi^2_{29;0.95}=42.56\qquad p_{asoc}=0.9987$$ \(H_0\) is not rejected. The observed CV is \(0.025/0.81=3.1\) %.
Conclusion. At the 1 % significance level there is no evidence of systematic error (although at 5 % there would be, p = 0.037). The precision comfortably meets the specification: the observed CV is 3.1 %.
7

Design of experiments and two samples

Independent and dependent samples; classical and nonparametric tests.

Concepts
Concept

Design of experiments vocabulary

  • Response variable: what is measured (time until symptoms disappear).
  • Factor: what distinguishes the populations being compared (antibiotic). Levels: its categories (tetracycline, penicillin).
  • Treatment: combination of levels applied to a unit. Experimental unit: smallest portion of material to which a treatment is applied (patient).
Concept

DCA and DBCA: independent or dependent samples

Completely randomized design (DCA): homogeneous units, randomly assigned to the levels → independent samples. They also arise when comparing natural groups (women of different ethnicities).

Randomized complete block design (DBCA): heterogeneous units grouped into homogeneous blocks; each block receives all the treatments at random → dependent samples. Extreme case: the same unit measured before and after.

Independent samples
Formula · test

Comparing variances: the F ratio

The larger sample variance goes in the numerator (if \(s_1^2\gt s_2^2\)): \(H_0:\psig_1^2=\psig_2^2\) vs \(H_1:\psig_1^2\gt\psig_2^2\).

$$F_{obs}=\frac{s^2_1}{s^2_2}\qquad\text{rechazar si }F_{obs}\ge F_{n_1-1;\,n_2-1;\,1-\alpha},\quad p=P(F\ge F_{obs})$$
Proof
  1. $$\frac{S_1^2/\psig_1^2}{S_2^2/\psig_2^2}\sim F_{n_1-1;n_2-1}\ \overset{H_0}{\Longrightarrow}\ \frac{S_1^2}{S_2^2}\sim F_{n_1-1;n_2-1}$$Ratio of chi-squares over their df; under \(H_0\) the variances cancel out.
  2. $$P\Big(\frac{S_1^2}{S_2^2}\ge c_\alpha\Big)=\alpha\Rightarrow c_\alpha=F_{n_1-1;n_2-1;1-\alpha}$$Percentile of the F.
Formula · test

Difference of means with known variances

$$\bar X_1-\bar X_2\sim N\Big(\pdm;\ \frac{\psig_1^2}{n_1}+\frac{\psig_2^2}{n_2}\Big)\qquad z_{obs}=\frac{\bar x_1-\bar x_2}{\sqrt{\frac{\psig_1^2}{n_1}+\frac{\psig_2^2}{n_2}}}$$

Notation in unit 7: the second parameter of the normal is the variance. If \(H_0\) postulates a difference \(\delta\ne0\), subtract \(\delta\) in the numerator.

Proof
  1. Linear combination of independent normals: if \(Y_1,\dots,Y_m\) are \(m\) independent normal variables with means \(\mu_j\) and variances \(\sigma_j^2\), and \(a_j\) are real constants, the combination \(W=\sum_{j=1}^m a_jY_j\) is normal: \(W\sim N\big(\sum a_j\mu_j;\sum a_j^2\sigma_j^2\big)\). With \(a_1=1,\ a_2=-1\) we get the distribution of \(\bar X_1-\bar X_2\).
  2. $$P(\bar X_1-\bar X_2\ge c_\alpha\mid\pdm=0)=\alpha\Rightarrow c_\alpha=z_{1-\alpha}\sqrt{\tfrac{\psig_1^2}{n_1}+\tfrac{\psig_2^2}{n_2}}$$Standardization and percentile (right-tailed).
Formula · test

Unknown, equal variances: t with pooled variance

First run the F test. If equality is not rejected:

$$s_a^2=\frac{(n_1-1)s_1^2+(n_2-1)s_2^2}{n_1+n_2-2}\qquad t_{obs}=\frac{\bar x_1-\bar x_2}{s_a\sqrt{\frac1{n_1}+\frac1{n_2}}}\overset{H_0}{\sim}t_{n_1+n_2-2}$$

\(s_a^2\) is a weighted average of the sample variances. Right: \(t_{obs}\ge t_{n_1+n_2-2;1-\alpha}\); left: \(\le -t\); two-tailed: \(|t_{obs}|\ge t_{n_1+n_2-2;1-\alpha/2}\).

Formula · test

Unknown, unequal variances: Welch's test

$$t_{obs}=\frac{\bar x_1-\bar x_2}{\sqrt{\frac{s_1^2}{n_1}+\frac{s_2^2}{n_2}}}\sim t_f\qquad f=\frac{\Big(\frac{s_1^2}{n_1}+\frac{s_2^2}{n_2}\Big)^2}{\frac{(s_1^2/n_1)^2}{n_1-1}+\frac{(s_2^2/n_2)^2}{n_2-1}}$$

Same decision rules as the previous case, with \(f\) degrees of freedom.

Formula · test

Two independent proportions (large samples)

Under \(H_0:\pp_1=\pp_2=\pp\), the common value is estimated with the frequency in the combined sample:

$$h=\frac{f_1+f_2}{n_1+n_2}\qquad z_{obs}=\frac{h_1-h_2}{\sqrt{h(1-h)\Big(\frac1{n_1}+\frac1{n_2}\Big)}}$$
Proof
  1. $$h_1-h_2\sim N\Big(\pp_1-\pp_2;\ \frac{\pp_1\pq_1}{n_1}+\frac{\pp_2\pq_2}{n_2}\Big)$$CLT (\(n_i\gt30\)) and linear combination of normals.
  2. $$\overset{H_0}{\Longrightarrow}\ h_1-h_2\sim N\Big(0;\ \pp\pq\big(\tfrac1{n_1}+\tfrac1{n_2}\big)\Big)$$With \(\pp_1=\pp_2=\pp\); \(\pp\) is estimated by \(h\).
  3. $$c_\alpha=z_{1-\alpha}\sqrt{h(1-h)\big(\tfrac1{n_1}+\tfrac1{n_2}\big)}$$Type I error, standardization and percentile (right).
Dependent samples
Formula · test

Comparing paired means: \(\pmd\)

Compute the difference within each block, \(d_i=x_{1i}-x_{2i}\), and assume \(D\sim N(\pmd;\psig_D^2)\). It is a one-sample t test on the differences:

$$H_0:\pmd=0\qquad t_{obs}=\frac{\bar d_{obs}}{s_D/\sqrt n}\overset{H_0}{\sim}t_{n-1}\qquad c_\alpha=t_{n-1;1-\alpha}\frac{s_D}{\sqrt n}$$
Proof
  1. $$\bar D\sim N\Big(\pmd;\frac{\psig^2_D}{n}\Big),\quad \frac{(n-1)S^2_D}{\psig^2_D}\sim\chi^2_{n-1}\Rightarrow T=\frac{\bar D-\pmd}{S_D/\sqrt n}\sim t_{n-1}$$Same as the one-sample T.
  2. $$P(\bar D\ge c_\alpha\mid\pmd=0)=\alpha\Rightarrow\frac{c_\alpha}{s_D/\sqrt n}=t_{n-1;1-\alpha}$$Type I error and t percentile (right).
Formula · test

Two proportions with dependent samples

Only the \(n'=f(A,\bar A)+f(\bar A,A)\) blocks with different responses are informative. Under \(H_0:\pp_1=\pp_2\), among them the probability of “A with treatment 1 and not with 2” is 0.5:

$$h'_1=\frac{f(A,\bar A)}{n'}\qquad z_{obs}=\frac{h'_1-0.5}{\sqrt{0.5\cdot0.5/n'}}\qquad c_\alpha=0.5+z_{1-\alpha}\sqrt{\tfrac{0.5\cdot0.5}{n'}}$$

\(H_1:\pp_1\gt\pp_2\) is equivalent to \(\pp'_1\gt0.5\) (right); \(\pp_1\lt\pp_2\) to \(\pp'_1\lt0.5\); \(\ne\) is two-tailed.

Nonparametric tests
Concept · ranks

Wilcoxon rank-sum (independent, Mann-Whitney)

When \(X_1\) or \(X_2\) are not normal. Hypotheses about location. The \(n=n_1+n_2\) observations are sorted and assigned ranks 1…n (ties: average rank).

$$W_1=\sum\text{rangos muestra 1},\quad W_2=\sum\text{rangos muestra 2},\quad W_1+W_2=\frac{n(n+1)}2$$

If \(H_1\): population 2 shifted to the right, reject if \(w_1\le w_{1;\alpha}\) (or \(w_2\ge w_{2;1-\alpha}\)). If population 1 is to the right, \(w_1\ge w_{1;1-\alpha}\). Critical values from tables.

Example from the notes: samples 25, 26, 27, 28, 30 and 29, 31, 32, 35 give \(w_1=16\), \(w_2=29\), with sum \(45=9\cdot10/2\).

Concept · ranks

Wilcoxon signed-rank (dependent)

When \(D\) is not normal. Zero differences are dropped, the rest are sorted by absolute value and assigned ranks.

$$T^-=\sum\text{rangos de }d_j\lt0,\quad T^+=\sum\text{rangos de }d_j\gt0,\quad T^-+T^+=\frac{n'(n'+1)}2$$
  • Two-tailed: \(T=\min(T^-,T^+)\); reject if \(t_{obs}\le t_\alpha\).
  • \(X_1\) to the right of \(X_2\): reject if \(t^-_{obs}\le t_\alpha\). \(X_2\) to the right: \(t^+_{obs}\le t_\alpha\).
Interactive lab
Interactive chart · simulation

Two independent samples: from F to the t test

Define two normal populations and the size of each sample. The chart follows the procedure of the unit: first the F test for variances (larger on top), and depending on its result the pooled-variance t or Welch's test, two-tailed with \(\alpha=0.05\). Initial values similar to the tetracycline vs penicillin example.

Group 1Group 2Rejection region (α = 0.05)p-value
Worked exercises
Exercise 7.1 Workbook · data from ch. 7, ex. 2(a)the workbook only asks to identify factor and variable; the test was added

Tetracycline vs penicillin

Twenty infected rats: 10 treated with tetracycline and 10 with penicillin. Time (h) until symptoms disappear. Do the mean times differ? (\(\alpha=0.05\), normal populations).

T51492542403332366420
P80783553594441498430
Step-by-step solution
  1. Design: DCA, independent samples. \(\bar x_T=39.2\), \(s^2_T=169.96\); \(\bar x_P=55.3\), \(s^2_P=376.90\).
  2. Variances (larger on top): $$F_{obs}=\frac{376.90}{169.96}=2.22\lt F_{9;9;0.95}=3.18\quad(p=0.126)$$ They are assumed equal.
  3. $$s_a^2=\frac{9\cdot169.96+9\cdot376.90}{18}=273.43,\quad s_a=16.54$$
  4. \(H_0:\pdm=0\) vs \(H_1:\pdm\ne0\): $$t_{obs}=\frac{39.2-55.3}{16.54\sqrt{0.2}}=-2.18,\quad |t_{obs}|\ge t_{18;0.975}=2.101,\quad p=0.043$$
Conclusion. At the 5 % significance level, the mean time until symptoms disappear differs between antibiotics; it is shorter with tetracycline (16 h less on average).
Exercise 7.2 Workbook · ch. 7, ex. 17FVC data, revisited in ch. 8, ex. 11

Forced vital capacity: baseline vs 6 months

FVC (%) in 10 children at baseline and after 6 months of treatment. Does mean FVC improve? (\(\alpha=0.05\), normal differences).

Baseline94.792.195.291.193.594.295.188.990.187.7
6 months98.896.594.998.094.993.998.093.195.390.1
d4.14.4−0.36.91.4−0.32.94.25.22.4
Step-by-step solution
  1. Each child is a block: dependent samples. \(d=\) 6 months − baseline. \(H_0:\pmd=0\) vs \(H_1:\pmd\gt0\).
  2. \(\bar d=3.09\), \(s_D=2.34\): $$t_{obs}=\frac{3.09}{2.34/\sqrt{10}}=4.18\ge t_{9;0.95}=1.833,\quad p=0.0012$$
Conclusion. There is evidence that the treatment increases mean FVC at 6 months (estimated mean increase of 3.1 points, p = 0.001). Comparing them as independent samples would ignore the variability between children.
Exercise 7.3 Course notes · U7, Wilcoxon signed-rank example

Wilcoxon signed-rank test on 10 blocks

Ten pairs of observations with non-normal differences. Does the location of the distributions differ? (two-tailed, \(\alpha=0.05\); table critical value for \(n'=10\): \(t_{0.05}=8\)).

BlockX1X2DRank
180.096.5−16.58
242.040.02.02
357.246.710.56
492.043.548.59
544.035.58.55
635.029.85.24
750.065.0−15.07
832.034.5−2.53
929.030.5−1.51
1090.029.061.010
Step-by-step solution
  1. Ranks by absolute value of \(D\) (no zeros, \(n'=10\)).
  2. \(t^-=8+7+3+1=19\), \(t^+=2+6+9+5+4+10=36\). Check: \(19+36=55=10\cdot11/2\).
  3. \(t_{obs}=\min(19,36)=19\gt t_{0.05}=8\).
Conclusion. \(H_0\) is not rejected: there is no evidence of a difference in location (with software, p ≈ 0.43).
Integrative exercises
Exercise 7.4 Workbook · ch. 7, ex. 7Integrative

Yield of two soybean varieties: F, t and interval for the difference

The yield of a medium-cycle soybean variety and a long-cycle one is compared in northwestern Argentina, with plots chosen at random in the same region:

Varietynx̄ (kg/ha)s (kg/ha)
Medium cycle153001.3201.5
Long cycle192741.8174.3

(a) Is there evidence that mean yield differs by variety? Report the p-value. (b) 95 % CI for the difference of means. (c) Required assumptions.

Step-by-step solution
  1. Independent samples (different plots). First, the variances, with the larger on top: $$F_{obs}=\frac{201.5^2}{174.3^2}=1.336\lt F_{14;18;0.95}=2.29\qquad p=0.278$$ \(\psig_1^2=\psig_2^2\) is not rejected: the pooled variance is used.
  2. $$s_a^2=\frac{14\cdot201.5^2+18\cdot174.3^2}{32}=34852.5\qquad s_a=186.69$$
  3. \(H_0:\pdm=0\) vs \(H_1:\pdm\ne0\): $$t_{obs}=\frac{3001.3-2741.8}{186.69\sqrt{\frac1{15}+\frac1{19}}}=\frac{259.5}{64.48}=4.02\gt t_{32;0.975}=2.037\qquad p=0.0003$$
  4. (b) $$259.5\pm2.037\cdot64.48=259.5\pm131.3\Rightarrow(128.2;\ 390.8)\ \text{kg/ha}$$ The workbook gives (127.95; 391.04) because of rounding of the table percentile.
  5. (c) Normal yield in both varieties, random and independent samples, and equal variances (checked with the F test).
Conclusion. Mean yields differ (p = 0.0003): the medium-cycle variety yields between 128 and 391 kg/ha more than the long-cycle one (95 %). Since the interval does not contain 0, it agrees with rejecting \(H_0\).
Exercise 7.5 Workbook · ch. 7, ex. 11Integrative

Transfusions with fresh red blood cells: means and proportions

In a multicenter study, 1211 critically ill patients received red blood cells stored for less than 8 days (group I) and 1219 received cells stored longer (group II). Baseline hemoglobin and 90-day mortality were compared:

GroupnMean Hb (g/dL)SDDeaths
I12117.691.28430
II12197.761.01448

(a) Can it be concluded that the groups do not differ in baseline hemoglobin? (b) The authors conclude that fresh cells do not reduce mortality. Check it.

Step-by-step solution
  1. (a) Variances. $$F_{obs}=\frac{1.28^2}{1.01^2}=1.606\qquad p\lt0.0001$$ With such large samples, even this difference is significant: the variances differ and Welch's test is used.
  2. Means (\(H_0:\pdm=0\) vs \(H_1:\pdm\ne0\)): $$t_{obs}=\frac{7.69-7.76}{\sqrt{\frac{1.28^2}{1211}+\frac{1.01^2}{1219}}}=\frac{-0.07}{0.0468}=-1.50\qquad f\approx2297\qquad p=0.135$$ \(H_0\) is not rejected: the groups are comparable in baseline hemoglobin, as intended in a randomized trial.
  3. (b) Mortality. \(h_1=430/1211=0.355\) and \(h_2=448/1219=0.368\). “Fresh cells reduce mortality” would be \(H_1:\pp_1\lt\pp_2\). Under \(H_0\) the common proportion is estimated from the combined sample: \(h=878/2430=0.361\).
  4. $$z_{obs}=\frac{0.355-0.368}{\sqrt{0.361\cdot0.639\big(\frac1{1211}+\frac1{1219}\big)}}=\frac{-0.0124}{0.0195}=-0.64\qquad p=P(Z\le-0.64)=0.26$$
Conclusion. The groups start from the same mean hemoglobin (p = 0.135) and there is no evidence that fresh cells reduce mortality (p = 0.26): the data support the authors' conclusion.
8

ANOVA: more than two samples

One-factor, fixed effects, balanced, in DCA and DBCA.

Concepts
Concept

Analysis of variance and notation

The total variability is split into sources in order to compare \(I\) means at once. Fixed effects: the levels studied are exactly the ones of interest. Random effects: levels drawn from a population of levels. Balanced design: \(J\) observations per level.

$$\bar Y_{i\cdot}=\frac1J\sum_{j=1}^JY_{ij}\qquad\bar Y_{\cdot\cdot}=\frac1{IJ}\sum_{i=1}^I\sum_{j=1}^JY_{ij}$$

The dot in the subscript means the sum was taken over that index.

DCA
Formula · model

Model equation, estimators and residuals (DCA)

$$Y_{ij}=\pmi{i}+\varepsilon_{ij}=\pmu+\pai{i}+\varepsilon_{ij},\qquad\sum_{i=1}^I\pai{i}=0,\qquad\varepsilon_{ij}\sim NI(0;\psig^2)$$

\(\pmu\): overall mean; \(\pai{i}\): effect of level \(i\); \(\varepsilon_{ij}\): random error.

$$\hat{\pmu}=\bar Y_{\cdot\cdot}\qquad\hat{\pai{i}}=\bar Y_{i\cdot}-\bar Y_{\cdot\cdot}\qquad\hat{\pmi{i}}=\bar Y_{i\cdot}\qquad e_{ij}=Y_{ij}-\bar Y_{i\cdot}$$

Consequence: \(Y_{ij}\sim N(\pmi{i};\psig^2)\). The residuals of each level add up to zero.

Concept

Assumptions and how to check them

  • Normality: normal probability plot of the residuals; the points should line up.
  • Homoscedasticity (constant \(\psig^2\)): residuals vs levels (and vs blocks in DBCA) with a similar range.
  • Independence: ensured in the design through proper randomization.

If they do not hold: transform the variable (the conclusions apply to the transformed variable) or use nonparametric alternatives.

Formula

Hypotheses and partition of the sum of squares

$$H_0:\pmi{1}=\dots=\pmi{I}\ \ (\pai{1}=\dots=\pai{I}=0)\qquad H_1:\text{al menos un }\pmi{i}\text{ difiere}$$
$$\underbrace{\sum_i\sum_j(Y_{ij}-\bar Y_{\cdot\cdot})^2}_{SC_{Total},\ IJ-1}=\underbrace{J\sum_i(\bar Y_{i\cdot}-\bar Y_{\cdot\cdot})^2}_{SC_{Trat},\ I-1}+\underbrace{\sum_i\sum_j(Y_{ij}-\bar Y_{i\cdot})^2}_{SC_{Error},\ IJ-I}$$
Proof
  1. $$SC_{Total}=\sum_i\sum_j\big[(Y_{ij}-\bar Y_{i\cdot})+(\bar Y_{i\cdot}-\bar Y_{\cdot\cdot})\big]^2$$Add and subtract \(\bar Y_{i\cdot}\).
  2. $$=\sum\sum(Y_{ij}-\bar Y_{i\cdot})^2+\sum\sum(\bar Y_{i\cdot}-\bar Y_{\cdot\cdot})^2+2\sum_i(\bar Y_{i\cdot}-\bar Y_{\cdot\cdot})\sum_j(Y_{ij}-\bar Y_{i\cdot})$$Square of a binomial.
  3. $$\sum_j(Y_{ij}-\bar Y_{i\cdot})=J\bar Y_{i\cdot}-J\bar Y_{i\cdot}=0$$The cross product vanishes, leaving \(SC_{Error}+SC_{Trat}\). The df satisfy \(IJ-1=(I-1)+(IJ-I)\).
Formula · test

Mean squares, F statistic and ANOVA table

$$CM_{Trat}=\frac{SC_{Trat}}{I-1}\quad CM_{Error}=\frac{SC_{Error}}{IJ-I}\quad E(CM_{Error})=\psig^2\quad E(CM_{Trat})=\psig^2+\frac{J}{I-1}\sum_i\pai{i}^2$$
$$F=\frac{CM_{Trat}}{CM_{Error}}\overset{H_0}{\sim}F_{I-1;\,IJ-I}\qquad\text{rechazar si }F_{obs}\ge F_{I-1;IJ-I;1-\alpha}\ \text{ o }\ p=P(F\ge F_{obs})\le\alpha$$

The rejection region is always right-tailed: a large \(F\) means the levels explain a lot of variability. An \(F\) much smaller than 1 may point to an uncontrolled factor.

FVSCglCMFp
Treatment\(SC_{Trat}\)\(I-1\)\(CM_{Trat}\)\(CM_{Trat}/CM_{Error}\)\(P(F\ge F_{obs})\)
Error\(SC_{Error}\)\(IJ-I\)\(CM_{Error}\)
Total\(SC_{Total}\)\(IJ-1\)
Proof of the F distribution and the critical value
  1. $$\frac{SC_{Trat}}{\psig^2}\overset{H_0}{\sim}\chi^2_{I-1},\qquad\frac{SC_{Error}}{\psig^2}\sim\chi^2_{IJ-I}$$\(SC_{Error}=\sum_i(J-1)S^2_{i\cdot}\); under \(H_0\) all the \(\pai{i}=0\).
  2. $$F=\frac{SC_{Trat}/[\psig^2(I-1)]}{SC_{Error}/[\psig^2(IJ-I)]}=\frac{CM_{Trat}}{CM_{Error}}\sim F_{I-1;IJ-I}$$Definition of F; \(\psig^2\) cancels out.
  3. $$P(F\ge c_\alpha\mid H_0)=\alpha\Rightarrow c_\alpha=F_{I-1;IJ-I;1-\alpha}$$Percentile of the F.
Concept

Multiple comparisons

If \(H_0\) is rejected, we look for which means differ by comparing them in pairs (\(\pmi{i}=\pmi{j}\) vs \(\ne\)) with the type I error controlled overall: Tukey, Scheffé, Dunnett, Bonferroni, Duncan, LSD.

Reading: levels whose asterisks line up in the same column do not differ; if they share no column, they differ. In the interval plot, overlapping intervals indicate no significant difference.

DBCA
Formula · model

ANOVA in randomized complete blocks

$$Y_{ij}=\pmu+\pai{i}+\pbj{j}+\varepsilon_{ij}\qquad \hat{\pbj{j}}=\bar Y_{\cdot j}-\bar Y_{\cdot\cdot}\qquad e_{ij}=Y_{ij}-\bar Y_{i\cdot}-\bar Y_{\cdot j}+\bar Y_{\cdot\cdot}$$
$$SC_{Total}=SC_{Trat}+SC_{Bloques}+SC_{Error},\qquad SC_{Bloques}=I\sum_j(\bar Y_{\cdot j}-\bar Y_{\cdot\cdot})^2$$
FVglF
Treatment\(I-1\)\(CM_{Trat}/CM_{Error}\sim F_{I-1;(I-1)(J-1)}\)
Blocks\(J-1\)\(CM_{Bloq}/CM_{Error}\sim F_{J-1;(I-1)(J-1)}\)
Error\((I-1)(J-1)\)
Total\(IJ-1\)

Blocking takes degrees of freedom away from the error: it only pays off if the blocks really are heterogeneous. Since blocks are not assigned at random, the test for the block effect should be interpreted with caution.

Proof of the partition
  1. $$Y_{ij}-\bar Y_{\cdot\cdot}=(\bar Y_{i\cdot}-\bar Y_{\cdot\cdot})+(\bar Y_{\cdot j}-\bar Y_{\cdot\cdot})+(Y_{ij}-\bar Y_{i\cdot}-\bar Y_{\cdot j}+\bar Y_{\cdot\cdot})$$Add and subtract \(\bar Y_{i\cdot}\), \(\bar Y_{\cdot j}\) and \(\bar Y_{\cdot\cdot}\).
  2. When squaring and summing over \(i\) and \(j\), the three cross products vanish because the deviations of row means, column means and the residuals add up to zero in every row and every column.
  3. Degrees of freedom: $$IJ-1=(I-1)+(J-1)+(I-1)(J-1)$$
Interactive lab
Interactive chart · simulation

ANOVA: variability between and within groups

Four levels with means \(\pmi{i}\) and a common \(\psig\). The thin lines are the deviations within each group (\(SC_{Error}\)); the thick ones, the deviations of each mean from the overall mean (\(SC_{Trat}\)). Bring the means closer or raise \(\psig\) and watch \(F\) drop. Initial values: means from the amines exercise (8.3).

Within deviation (Y − ȳᵢ.)Between deviation (ȳᵢ. − ȳ..)Overall mean
Worked exercises
Exercise 8.1 Workbook · ch. 8, ex. 2

Carbon gases in four industrial zones

Five readings per zone (mg/m³). Does the mean level differ between zones? (\(\alpha=0.05\)).

A0.0470.0390.0510.0480.046
B0.0320.0360.0310.0300.035
C0.0190.0210.0180.0220.017
D0.0410.0370.0380.0470.048
Step-by-step solution
  1. Model \(Y_{ij}=\pmu+\pai{i}+\varepsilon_{ij}\), \(i\)=zone (A–D), \(j\)=reading (1–5). The residual plots in the workbook show no departures from normality or homoscedasticity.
  2. Means: A 0.0462, B 0.0328, C 0.0194, D 0.0422. Residual of the 3rd reading of B: \(0.031-0.0328=-0.0018\).
  3. FVSCglCMFp
    Zone0.00212730.00070950.28<0.0001
    Error0.000226160.0000141
    Total0.00235319
    \(F_{3;16;0.95}=3.24\).
  4. Scheffé (α = 0.05): C (0.0194) < B (0.0328) < D (0.0422) = A (0.0462).
Conclusion. There is a zone effect (p < 0.0001). Zones A and D have the highest levels and do not differ from each other; B is intermediate and C is the least polluted.
Exercise 8.2 Workbook · ch. 8, ex. 4

Washing solutions for milk containers (DBCA)

Three solutions, one trial of each per day for 6 days (each day is a block). Number of colonies. Work with \(\alpha=0.01\) and compare with the analysis without blocks.

SolutionD1D2D3D4D5D6
1132218392219
2162417442528
354122715
Step-by-step solution
  1. Factor: solution (3 levels); block: day (6); response: number of colonies. Model \(Y_{ij}=\pmu+\pai{i}+\pbj{j}+\varepsilon_{ij}\).
  2. FVSCglCMFp
    Solution926.782463.3944.89<0.0001
    Day1118.945223.7921.68<0.0001
    Error103.221010.32
    Total2148.9417
    \(F_{2;10;0.99}=7.56\): \(H_0\) is rejected.
  3. Scheffé (α = 0.01): solution 3 (9.0) < solutions 1 (22.2) and 2 (25.7), which do not differ.
  4. Without blocks, the SC for days goes into the error: \(SC_{Error}=1222.17\), 15 df, \(CM=81.48\), \(F=5.69\), \(p=0.0145\gt0.01\) (\(F_{2;15;0.99}=6.36\)).
Conclusion. Solution 3 is the one that delays bacterial growth the most. The day effect is significant: without blocking, with α = 0.01 no difference between solutions would have been detected.
Exercise 8.3 Workbook · ch. 8, ex. 8

Antifungal amines on wood-decay fungi

Mycelial growth (cm) with three amines and a control, 6 replicates. Given \(CM_{Trat}=48.5556\) and \(SC_{Error}=19.9467\), complete the table and draw a conclusion (\(\alpha=0.05\)).

Control8.610.512.510.311.49.3
DMA48.39.67.78.18.87.5
DMA125.66.43.75.85.05.3
DMA163.94.53.64.05.63.6
Step-by-step solution
  1. \(I=4\), \(J=6\): df Trat = 3, df Error = 20, df Total = 23. \(SC_{Trat}=3\cdot48.5556=145.67\).
  2. \(CM_{Error}=19.9467/20=0.9973\); \(F=48.5556/0.9973=48.69\).
    FVSCglCMFp
    Treatment145.667348.55648.69<0.0001
    Error19.947200.997
    Total165.61323
  3. Tukey: minimum difference \(q_{4;20;0.05}\sqrt{CM_E/J}=3.958\cdot0.408=1.61\). DMA16 (4.20) and DMA12 (5.30) differ by 1.10: not significant. DMA4 (8.33) and Control (10.43) differ from all the others.
Conclusion. The three amines reduce growth compared with the control (p < 0.0001), and the medium- and long-chain ones are the most effective. The data support the authors' claim.
Integrative exercises
Exercise 8.4 Workbook · ch. 8, ex. 5Integrative

Paracetamol: do the five analysts measure the same?

Tablets were ground into a fine homogeneous powder and each of five analysts made six determinations of the paracetamol content (% w/w). (a) Identify factor, levels and variable. (b) Write the model equation. (c) Complete the analysis and conclude, with Tukey comparisons (\(\alpha=0.05\)).

A84.3284.5184.6384.6184.6484.51
B84.2484.2584.4184.1384.0084.30
C84.2984.4084.6884.2884.4084.36
D84.1484.2284.0284.4884.2784.33
E84.5084.2084.4984.4084.1184.06
Step-by-step solution
  1. (a) Factor: analyst, with 5 levels (A to E). Response variable: paracetamol content (% w/w). The units are aliquots of the same homogeneous powder: completely randomized design, \(I=5\), \(J=6\).
  2. (b) \(Y_{ij}=\pmu+\pai{i}+\varepsilon_{ij}\), with \(\varepsilon_{ij}\sim NI(0;\psig^2)\); \(\pai{i}\) is the effect of analyst \(i\). \(H_0:\pmi{A}=\dots=\pmi{E}\).
  3. (c) The residual plots in the workbook show no departures from normality or homoscedasticity.
    FVSCglCMFp
    Analyst0.408040.10204.290.0089
    Error0.5948250.0238
    Total1.002829
    \(F_{obs}=4.29\gt F_{4;25;0.95}=2.76\): \(H_0\) is rejected.
  4. Tukey. Minimum significant difference: $$q_{5;25;0.05}\sqrt{CM_{Error}/J}=4.153\sqrt{0.0238/6}=0.262$$ Means: B 84.222, D 84.243, E 84.293, C 84.402, A 84.537. Only A − B = 0.315 and A − D = 0.293 exceed 0.262. Homogeneous groups: {B, D, E, C} and {E, C, A}.
Conclusion. The analysts do not get the same result on average (p = 0.009): A measures more than B and D, and there is no evidence of differences between the other pairs. The procedure of those analysts should be reviewed.
Exercise 8.5 Workbook · ch. 8, ex. 9Integrative

Methylmercury in fish: three techniques in blocks

Three techniques are compared: cold vapor atomic absorption (A), optical emission (B) and mass spectrometry (C). In each of 8 fish muscle samples the concentration was measured with all three (ng/g). (a) Model equation. (b) Null hypothesis. (c) Assumptions and residual of observation 11.3. (d) ANOVA table and Scheffé. (e) What would have been concluded without accounting for the variation between samples?

Sample12345678
A10.215.89.328.533.651.221.541.5
B11.316.37.035.428.360.319.239.2
C14.520.410.137.241.265.829.651.2
Step-by-step solution
  1. (a) Each fish sample is a block (it receives all three techniques): DBCA with \(I=3\) techniques and \(J=8\) blocks. \(Y_{ij}=\pmu+\pai{i}+\pbj{j}+\varepsilon_{ij}\), \(\varepsilon_{ij}\sim NI(0;\psig^2)\).
  2. (b) \(H_0:\pmi{A}=\pmi{B}=\pmi{C}\): the three techniques measure the same on average.
  3. (c) Assumptions: normal, independent errors with constant variance across techniques and blocks. For 11.3 (technique B, sample 1): $$e_{21}=Y_{21}-\bar Y_{2\cdot}-\bar Y_{\cdot1}+\bar Y_{\cdot\cdot}=11.3-27.125-12.0+29.108=1.283$$
  4. (d)
    FVSCglCMFp
    Technique260.362130.1812.710.0007
    Sample6123.267874.7585.43<0.0001
    Error143.361410.24
    Total6526.9823
    \(F_{2;14;0.95}=3.74\): \(H_0\) is rejected. Scheffé: A (26.45) and B (27.13) form one group; C (33.75) gives higher values.
  5. (e) Without blocks, the SC for samples goes into the error: \(SC_{Error}=143.36+6123.26=6266.62\) with 21 df, \(CM_{Error}=298.41\), \(F=130.18/298.41=0.44\), \(p=0.65\). No difference would be detected.
Conclusion. Mass spectrometry gives higher concentrations on average than the other two techniques, which do not differ from each other. The variability between fish samples is huge: without the block design that effect would have stayed hidden.
9

Linear regression and correlation

Regression line, inference on its coefficients, R² and Pearson's coefficient.

Concepts
Concept

Regression vs correlation

Regression: a random response variable \(Y\) depends on a controlled explanatory variable \(x\) (set by the researcher). E.g.: absorbance as a function of the concentration of a standard.

Correlation: two random variables measured on the same unit, with no roles; the interest is the strength of the relationship (weight and height; sodium measured by two methods).

Always start with the scatter plot. A deterministic relationship (\(y=5000+2500x\)) leaves no variability; a stochastic one does, and requires a model with error.

Simple linear regression
Formula · model

Simple linear regression model

$$Y_i=\pa+\pb x_i+\varepsilon_i,\qquad\varepsilon_i\sim NI(0;\psig^2)\qquad\Longrightarrow\qquad Y_i\sim N(\pmyxi{i}=\pa+\pb x_i;\ \psig^2)$$
  • \(\pa\): intercept, mean of \(Y\) when \(x=0\) (it may be meaningless if 0 is outside the range).
  • \(\pb\): slope or regression coefficient, mean change in \(Y\) per unit increase in \(x\): \(\pmyxi{i+1}-\pmyxi{i}=\pb\).
  • The theoretical line \(\pmyx=\pa+\pb x\) goes through the means of \(Y\) at each \(x\); all the populations have the same variance \(\psig^2\).
Formula · estimation

Least squares

$$\hat y=a+bx\qquad b=\frac{\sum x_iy_i-n\bar x\bar y}{(n-1)s^2_x}\qquad a=\bar y-b\bar x\qquad e_i=y_i-\hat y_i$$

They are the values that minimize the sum of squared residuals: the line that passes as close as possible to all the points at once.

Proof (normal equations)
  1. $$SC_{Error}(a,b)=\sum(y_i-a-bx_i)^2\to\min$$Least squares criterion.
  2. $$\frac{\partial}{\partial a}=-2\sum(y_i-a-bx_i)=0\Rightarrow\sum y_i=na+b\sum x_i\Rightarrow a=\bar y-b\bar x$$Derivative with respect to \(a\) set to zero.
  3. $$\frac{\partial}{\partial b}=-2\sum x_i(y_i-a-bx_i)=0\Rightarrow\sum x_iy_i=a\sum x_i+b\sum x_i^2$$Derivative with respect to \(b\).
  4. $$\sum x_iy_i=(\bar y-b\bar x)n\bar x+b\sum x_i^2\Rightarrow b=\frac{\sum x_iy_i-n\bar x\bar y}{\sum x_i^2-n\bar x^2}=\frac{\sum x_iy_i-n\bar x\bar y}{(n-1)s_x^2}$$Substitute \(a\) and solve; \(\sum x_i^2-n\bar x^2=(n-1)s^2_x\).
Formula · estimation

Estimating \(\psig^2\) and the distribution of \(A\) and \(B\)

$$\hat{\psig}^2=CM_{Error}=\frac{\sum e_i^2}{n-2}\qquad\frac{(n-2)CM_{Error}}{\psig^2}\sim\chi^2_{n-2}$$
$$B\sim N\Big(\pb;\ \frac{\psig^2}{(n-1)s^2_x}\Big)\qquad A\sim N\Big(\pa;\ \psig^2\Big[\frac1n+\frac{\bar x^2}{(n-1)s^2_x}\Big]\Big)$$

Divide by \(n-2\) because two parameters were estimated. \(A\) and \(B\) are unbiased and consistent.

Formula · CI

Confidence intervals for \(\pb\), \(\pa\) and \(\pmyxi{0}\)

$$\pb:\ b\pm t_{n-2;1-\alpha/2}\sqrt{\frac{CM_{Error}}{(n-1)s^2_x}}\qquad\pa:\ a\pm t_{n-2;1-\alpha/2}\sqrt{CM_{Error}\Big(\frac1n+\frac{\bar x^2}{(n-1)s^2_x}\Big)}$$
$$\pmyxi{0}:\ \hat y_0\pm t_{n-2;1-\alpha/2}\sqrt{CM_{Error}\Big(\frac1n+\frac{(x_0-\bar x)^2}{(n-1)s^2_x}\Big)}$$

The precision of \(\hat y_0\) gets worse as \(x_0\) moves away from \(\bar x\). Only estimate within the range of \(x\) studied (do not extrapolate).

Proof of the CI for \(\pb\)
  1. $$T=\frac{B-\pb}{\sqrt{CM_{Error}/[(n-1)s^2_x]}}\sim t_{n-2}$$Standardize \(B\) and replace \(\psig^2\) by \(CM_{Error}\).
  2. $$P\big(-t_{n-2;1-\alpha/2}\le T\le t_{n-2;1-\alpha/2}\big)=1-\alpha$$Two values that leave \(\alpha/2\) in each tail.
  3. $$P\Big(B-t\sqrt{\tfrac{CM_E}{(n-1)s^2_x}}\le\pb\le B+t\sqrt{\tfrac{CM_E}{(n-1)s^2_x}}\Big)=1-\alpha$$Multiply, subtract \(B\) and multiply by \(-1\).
Concept

Model adequacy: residual analysis

  • Linearity: residuals vs \(x\) with no curved pattern.
  • Normality: normal probability plot of the residuals lined up.
  • Homoscedasticity: residuals vs \(x\) within a band of constant width (a funnel indicates increasing variance).
  • Independence: guaranteed by the design (same equipment, different units, no time trend).
Formula

Partition of variability and \(R^2\)

$$\sum(Y_i-\bar Y)^2=\sum(Y_i-\hat Y_i)^2+\sum(\hat Y_i-\bar Y)^2\quad\Longrightarrow\quad SC_{Total}=SC_{Error}+SC_{Reg}$$
$$R^2=\frac{SC_{Reg}}{SC_{Total}}=1-\frac{SC_{Error}}{SC_{Total}},\qquad0\le R^2\le1$$

Proportion of the variability of \(Y\) explained by the line. \(R^2=1\): perfect fit; \(R^2=0\): horizontal line \(\hat y=\bar y\). A high \(R^2\) does not guarantee linearity: always look at the residuals.

Formula · test

Tests for \(\pb\) (ANOVA and t) and for \(\pa\)

$$H_0:\pb=0\qquad F=\frac{CM_{Reg}}{CM_{Error}}\overset{H_0}{\sim}F_{1;n-2},\quad E(CM_{Reg})=\psig^2+\pb^2(n-1)s^2_x$$
$$t_{obs}=\frac{b-0}{\sqrt{CM_{Error}/[(n-1)s^2_x]}}\qquad t_{obs}=\frac{a-0}{\sqrt{CM_{Error}\big(\frac1n+\frac{\bar x^2}{(n-1)s^2_x}\big)}}\qquad T\overset{H_0}{\sim}t_{n-2}$$

ANOVA only tests \(\pb\ne0\); the t test allows one-sided tests. In the two-tailed case \(t_{obs}^2=F_{obs}\) and the p-values match. For \(\pa\) the usual question is whether the line passes through the origin.

FVSCglCMF
Regression\(SC_{Reg}\)1\(SC_{Reg}/1\)\(CM_{Reg}/CM_{Error}\)
Error\(SC_{Error}\)\(n-2\)\(SC_{Error}/(n-2)\)
Total\(SC_{Total}\)\(n-1\)
Proof of the critical value (t, right)
  1. $$P(B\ge c_\alpha\mid\pb=0)=\alpha\Rightarrow P\Big(T\ge\frac{c_\alpha-0}{\sqrt{CM_E/[(n-1)s^2_x]}}\Big)=\alpha$$Type I error and construction of the T.
  2. $$c_\alpha=t_{n-2;1-\alpha}\sqrt{\frac{CM_{Error}}{(n-1)s^2_x}}$$Percentile of the t and solving.
Linear correlation
Formula

Covariance and Pearson's coefficient

$$\class{p-rho}{\sigma_{XY}}=E[(X-\mu_X)(Y-\mu_Y)]\qquad S_{XY}=\frac1{n-1}\sum(X_i-\bar X)(Y_i-\bar Y)$$
$$\prho=\frac{\class{p-rho}{\sigma_{XY}}}{\sigma_X\sigma_Y}\qquad r=\frac{S_{XY}}{S_XS_Y}\qquad -1\le\prho\le1$$
  • The covariance gives the direction but is unbounded and depends on the units; \(\prho\) fixes both.
  • \(\prho=\pm1\): perfect linear relationship. Independence ⇒ \(\prho=0\), but \(\prho=0\) does not imply independence (there may be a nonlinear relationship).
  • Practical guide: \(|r|\lt0.5\) weak; \(0.5\le|r|\lt0.8\) moderate; \(|r|\ge0.8\) strong.
Formula

The two regression lines

$$\hat y=a_1+b_1x,\ \ b_1=\frac{\sum x_iy_i-n\bar x\bar y}{(n-1)s^2_x}\qquad\hat x=a_2+b_2y,\ \ b_2=\frac{\sum x_iy_i-n\bar x\bar y}{(n-1)s^2_y}$$
$$r=\pm\sqrt{b_1b_2}\qquad r^2=R^2$$

\(b_1\) and \(b_2\) have the same sign. With \(|r|=1\) the lines coincide; with \(r=0\) they are perpendicular (\(\hat y=\bar y\), \(\hat x=\bar x\)).

Interactive lab
Interactive chart

Least squares regression: drag the points

Drag any point or tap an empty spot to add one. The line, the residuals, the 95 % confidence band for \(\pmyx\), \(R^2\), \(r\) and the test for \(\pb=0\) are recomputed instantly. Try moving a single point away from the line and see how much the slope changes.

Observationsŷ = a + bxResiduals95 % CI bandx̂ = a₂ + b₂y
Worked exercises
Exercise 9.1 Workbook · ch. 9, ex. 2

Calibration curve for starch in sugar

Absorbance of starch standards (mg/kg). (a) Least squares line. (b) Residual at \(x=100\). (c) Does the line pass through the origin? (\(\alpha=0.05\)).

x012.520100200250350500600
and0.0250.0310.0370.0730.1250.1480.2000.2700.322
Step-by-step solution
  1. \(n=9\), \(\bar x=225.83\), \(\bar y=0.13678\), \((n-1)s^2_x=386550\), \(\sum x_iy_i=468.6275\). $$b=\frac{468.6275-9\cdot225.83\cdot0.13678}{386550}=0.000493\qquad a=0.13678-0.000493\cdot225.83=0.0254$$
  2. \(\hat y(100)=0.0254+0.0493=0.0747\); \(e=0.073-0.0747=-0.0017\).
  3. \(CM_{Error}=1.6245\times10^{-5}/7=2.32\times10^{-6}\). $$t_{obs}=\frac{0.0254}{\sqrt{2.32\times10^{-6}\big(\frac19+\frac{225.83^2}{386550}\big)}}=\frac{0.0254}{0.000751}=33.83$$ \(t_{7;0.975}=2.365\), p < 0.0001.
Conclusion. \(\hat y=0.0254+0.000493\,x\). \(\pa=0\) is rejected: the line does not pass through the origin (there is a background absorbance of about 0.025 units). Each mg/kg of starch increases absorbance by 0.000493 on average.
Exercise 9.2 Workbook · ch. 9, ex. 3

Caffeine by HPLC: calibration and inverse prediction

Peak area vs caffeine concentration (ppm). (a) Line. (b) Test \(\pb=0\) (\(\alpha=0.05\)). (c) \(R^2\). (d) Concentration for an area of 520. (e) And for 2500?

ppm2468101216
Area127252391497611756999
Step-by-step solution
  1. \(\bar x=8.286\), \(\bar y=519\), \((n-1)s^2_x=139.43\): \(b=62.02\), \(a=5.08\). $$\hat y=5.08+62.02\,x$$
  2. FVSCglCMFp
    Regression53638915363895763.4<0.0001
    Error465.34593.07
    Total5368546
    $$t_{obs}=\frac{62.02}{\sqrt{93.07/139.43}}=\frac{62.02}{0.817}=75.92,\qquad 75.92^2=5763=F_{obs}$$
  3. \(R^2=536389/536854=0.9991\).
  4. \(x=(520-5.08)/62.02=8.30\) ppm.
  5. For 2500 it would give ≈ 40 ppm, far outside the range studied (2 to 16 ppm): extrapolating is not reliable.
Conclusion. There is a significant linear regression and the line explains 99.9 % of the variability of the area. A sample with area 520 contains about 8.3 ppm of caffeine.
Exercise 9.3 Workbook · ch. 9, ex. 9

Co-expression of two genes in Arabidopsis

mRNA expression of two genes under 10 experimental conditions. Both variables are random: analyze their association.

Gene 1445128472330452031009113218948342300
Gene 290451694365343092836981196013850203942039425290
Step-by-step solution
  1. It is a correlation problem (no controlled variable). The scatter plot shows a direct linear relationship.
  2. \(\bar x=1286.9\), \(s_x=881.5\); \(\bar y=15903.6\), \(s_y=8555.8\); \(S_{XY}=6\,923\,846\). $$r=\frac{6\,923\,846}{881.5\cdot8555.8}=0.918$$
  3. Lines: \(\hat y=4437.39+8.910\,x\) and \(\hat x=-217.34+0.0946\,y\). Check: \(\sqrt{8.910\cdot0.0946}=0.918\).
  4. \(r^2=0.843\).
Conclusion. Strong direct linear association (\(r=0.918\)): the genes are co-expressed, and 84 % of the variability of one is linearly associated with the other.
Integrative exercises
Exercise 9.4 Workbook · ch. 9, ex. 5Integrative

Degradation of a drug: choose the model and predict

The label of a solution states 1.5 % of active ingredient, but at the start of the experiment (day 0) 1.25 % was measured. The concentration was followed for 25 days:

Days0510152025
C (%)1.251.040.870.720.600.50

The process is zero order if \(C\) is linear in \(t\); first order if \(\ln C\) is (\(C_t=C_0e^{-kt}\)); second order if \(1/C\) is. (a) Determine the order. (b) Estimate the rate constant \(k\). (c) How much time passed between manufacture and day 0? (d) Half-life and time for the concentration to drop 10 % below the label. (e) Concentration at 10 days.

Step-by-step solution
  1. (a) The three lines are fitted by least squares:
    ModelLineR²Residuals
    Order 0: C1.2029 − 0.02983 t98.30 %curvature (+ − − − − +)
    Order 1: ln C0.22374 − 0.03669 t99.99 %no pattern
    Order 2: 1/C0.7310 + 0.04774 t98.25 %curvature (+ − − − − +)
    All three \(R^2\) are high, but only the first-order one has residuals with no curved pattern. The reaction is first order.
  2. (b) The slope of \(\ln C\) as a function of \(t\) is \(-k\): \(k=0.03669\) day⁻¹. The intercept gives \(\hat C_0=e^{0.22374}=1.251\) %.
  3. (c) Find \(t\) such that \(C=1.5\): $$\ln1.5=0.22374-0.03669\,t\Rightarrow t=\frac{0.22374-0.40547}{0.03669}=-4.95$$ The drug was manufactured about 5 days before the start.
  4. (d) Half-life (from 1.5 % to 0.75 %): \(t_{1/2}=\ln2/k=18.9\approx19\) days. Dropping 10 % below the label means reaching 1.35 %: $$t=\frac{\ln(1.5/1.35)}{k}=\frac{0.1054}{0.03669}=2.9\ \text{days after manufacture}$$ On the experiment's time scale that is \(t=-2.1\): about 2 days before day 0, which is the workbook's answer.
  5. (e) $$\hat C(10)=e^{0.22374-0.03669\cdot10}=e^{-0.1432}=0.87\ \%$$
Conclusion. The degradation is first order, with \(k=0.0367\) day⁻¹ and a half-life of about 19 days. The product had already lost more than 10 % of its stated content when the experiment began: that happened 3 days after manufacture.
Exercise 9.5 Workbook · ch. 9, ex. 11Integrative

Lead in juices by two methods: correlation and paired test

Lead (µg/mL) was measured in 10 juices with a new potentiometric method (APR) and by atomic absorption (EAA). (a) Scatter plot. (b) Estimate the parameter that measures the strength of the relationship. (c) Do both methods measure, on average, the same concentration? (\(\alpha=0.05\)).

Juice12345678910
EAA35757580125205205215240350
APR35708080120200220200250330
Step-by-step solution
  1. (a) Both are random variables measured on the same juice, with no controlled variable: it is a correlation problem. The points line up along an increasing line.
  2. (b) \(\bar x_{EAA}=160.5\), \(s_{EAA}=98.47\); \(\bar x_{APR}=158.5\), \(s_{APR}=95.40\); \(S_{XY}=9342.5\). $$r=\frac{S_{XY}}{S_XS_Y}=\frac{9342.5}{98.47\cdot95.40}=0.9945$$ Very strong direct linear association.
  3. (c) A high correlation does not guarantee that the methods agree: they could differ by a constant. To compare means, use the paired test (each juice is a block). With \(d=\text{EAA}-\text{APR}\): 0, 5, −5, 0, 5, 5, −15, 15, −10, 20, we get \(\bar d=2.0\) and \(s_D=10.59\).
  4. \(H_0:\pmd=0\) vs \(H_1:\pmd\ne0\): $$t_{obs}=\frac{2.0}{10.59/\sqrt{10}}=0.60\lt t_{9;0.975}=2.262\qquad p=0.565$$
Conclusion. The methods are strongly correlated (r = 0.9945) and there is no evidence that they differ on average (p = 0.57): the new APR method agrees with atomic absorption.
Σ

Summary table

Parameter, estimator, pivot variable and distribution. Rows are marked when you pick a parameter.

ParameterEstimatorVariable for CI / testDistributionAssumptionsUnit
\(\pmu\) (\(\psig\) known)\(\bar X\)\(\frac{\bar X-\pmu}{\psig/\sqrt n}\)\(N(0;1)\)Normal or \(n\gt30\)5, 6
\(\pmu\) (\(\psig\) unknown)\(\bar X\)\(\frac{\bar X-\pmu}{S/\sqrt n}\)\(t_{n-1}\)Normal5, 6
\(\psig^2\)\(S^2\)\(\frac{(n-1)S^2}{\psig^2}\)\(\chi^2_{n-1}\)Normal5, 6
\(\pp\)\(h\)CI: \(\frac{h-\pp}{\sqrt{h(1-h)/n}}\); test: \(\frac{h-\pp_0}{\sqrt{\pp_0\pq_0/n}}\)\(N(0;1)\) approx.\(n\ge30\)5, 6
\(\psig_1^2/\psig_2^2\)\(S_1^2/S_2^2\)\(\frac{S_1^2}{S_2^2}\)\(F_{n_1-1;n_2-1}\)Independent normals7
\(\pdm\) (\(\psig_i\) known)\(\bar X_1-\bar X_2\)\(\frac{\bar X_1-\bar X_2}{\sqrt{\psig_1^2/n_1+\psig_2^2/n_2}}\)\(N(0;1)\)Normal or CLT7
\(\pdm\) (equal, unknown)\(\bar X_1-\bar X_2\)\(\frac{\bar X_1-\bar X_2}{s_a\sqrt{1/n_1+1/n_2}}\)\(t_{n_1+n_2-2}\)Normal, F does not reject7
\(\pdm\) (unequal)\(\bar X_1-\bar X_2\)\(\frac{\bar X_1-\bar X_2}{\sqrt{s_1^2/n_1+s_2^2/n_2}}\)\(t_f\) (Welch)Normal7
\(\pp_1-\pp_2\)\(h_1-h_2\)\(\frac{h_1-h_2}{\sqrt{h(1-h)(1/n_1+1/n_2)}}\)\(N(0;1)\) approx.\(n_i\gt30\)7
\(\pmd\)\(\bar D\)\(\frac{\bar D}{S_D/\sqrt n}\)\(t_{n-1}\)\(D\) normal7
\(\pmi{1}=\dots=\pmi{I}\)\(\bar Y_{i\cdot}\)\(CM_{Trat}/CM_{Error}\)\(F_{I-1;IJ-I}\) (DCA), \(F_{I-1;(I-1)(J-1)}\) (DBCA)\(\varepsilon\sim NI(0;\psig^2)\)8
\(\pb\)\(b\)\(\frac{b-\pb}{\sqrt{CM_E/[(n-1)s_x^2]}}\) · \(CM_{Reg}/CM_E\)\(t_{n-2}\) · \(F_{1;n-2}\)\(\varepsilon\sim NI(0;\psig^2)\)9
\(\pa\)\(a\)\(\frac{a-\pa}{\sqrt{CM_E(1/n+\bar x^2/[(n-1)s_x^2])}}\)\(t_{n-2}\)Same9
\(\prho\)\(r\)Descriptive in the course—Linear relationship9
≡

Notation

What each symbol in the notes means. Tap one to highlight it in every formula. The notation follows the original Spanish course: SC = sum of squares, CM = mean square, gl = degrees of freedom, FV = source of variation, DCA = completely randomized design, DBCA = randomized complete block design.