PracticeVideosBlogFlashcards

2.4 Hypothesis Testing, Goodness of Fit, and Linear Regression

Key Takeaways

  • A hypothesis test rejects the null hypothesis when the test statistic falls beyond the critical value, or equivalently when the p-value is below the significance level alpha.

  • A Type I error rejects a true null hypothesis and has probability alpha; a Type II error fails to reject a false null hypothesis and has probability beta.

  • The least-squares slope is Sxy/Sxx and the line always passes through the point (x-bar, y-bar).

  • The coefficient of determination R-squared is the fraction of variation in y explained by the model and equals the square of the correlation coefficient r in simple linear regression.

  • A high R-squared confirms goodness of fit, not causation, and says nothing about whether the chosen model form is physically correct.

Last updated: August 2026

2.4 Hypothesis Testing, Goodness of Fit, and Linear Regression

Hypothesis testing asks whether an observed difference is larger than sampling variation can plausibly explain, and regression asks how well a straight line describes a data set. Both are examined under the NCEES sub-topics sample distributions and sizes and goodness of fit, and both are formula-driven once the correct test or statistic is identified.

1. Hypothesis Testing Methodology

Hypothesis testing evaluates competing claims regarding a population parameter using sample evidence.

Step-by-Step Procedure

  1. Formulate Hypotheses:
    • Null Hypothesis (H0H_0): Baseline status-quo claim (e.g., H0:μ=μ0H_0: \mu = \mu_0 or H0:μ≤μ0H_0: \mu \le \mu_0).
    • Alternative Hypothesis (HaH_a): Research hypothesis (e.g., Ha:μ≠μ0H_a: \mu \ne \mu_0, Ha:μ>μ0H_a: \mu > \mu_0, or Ha:μ<μ0H_a: \mu < \mu_0).
  2. Select Significance Level (α\alpha): Common values are α=0.05\alpha = 0.05 (5%) or α=0.01\alpha = 0.01 (1%).
  3. Compute Test Statistic:
    • ZZ-test (Known σ\sigma or n≥30n \ge 30): Zcalc=xˉ−μ0σ/nZ_{calc} = \frac{\bar{x} - \mu_0}{\sigma / \sqrt{n}}
    • tt-test (Unknown σ\sigma, n<30n < 30): tcalc=xˉ−μ0s/nt_{calc} = \frac{\bar{x} - \mu_0}{s / \sqrt{n}}
  4. Determine Critical Region / pp-value:
    • Critical Value Method: Compare test statistic to zcritz_{crit} or tcritt_{crit}.
    • pp-value Method: Compute pp-value =P(observing test statistic∣H0 is true)= P(\text{observing test statistic} \mid H_0 \text{ is true}).
  5. State Decision Rule:
    • If ∣Zcalc∣>Zcrit|Z_{calc}| > Z_{crit} (or p-value<αp\text{-value} < \alpha), Reject H0H_0.
    • If ∣Zcalc∣≤Zcrit|Z_{calc}| \le Z_{crit} (or p-value≥αp\text{-value} \ge \alpha), Fail to Reject H0H_0.

Decision Errors in Hypothesis Testing

Truth \ DecisionFail to Reject H0H_0Reject H0H_0
H0H_0 is TrueCorrect Decision (1−α1 - \alpha)Type I Error (α\alpha) (False Positive)
H0H_0 is FalseType II Error (β\beta) (False Negative)Correct Decision (1−β1 - \beta) (Power)

Worked Engineering Example: One-Tailed ZZ-Test

Problem: An environmental compliance regulation limits lead content in discharge water to μ0≤15.0 ppb\mu_0 \le 15.0\text{ ppb}. An inspector tests n=36n = 36 samples, finding a sample mean xˉ=16.2 ppb\bar{x} = 16.2\text{ ppb}. The known population standard deviation is σ=3.6 ppb\sigma = 3.6\text{ ppb}. Test at α=0.05\alpha = 0.05 significance level whether the plant violates effluent standards (Zcrit=1.645Z_{crit} = 1.645 for upper one-tailed test).

Solution: Step 1: Set Hypotheses: H0:μ≤15.0 ppbvs.Ha:μ>15.0 ppbH_0: \mu \le 15.0\text{ ppb} \quad \text{vs.} \quad H_a: \mu > 15.0\text{ ppb}

Step 2: Calculate Test Statistic ZcalcZ_{calc}: Zcalc=xˉ−μ0σ/n=16.2−15.03.6/36=1.23.6/6=1.20.60=2.00Z_{calc} = \frac{\bar{x} - \mu_0}{\sigma / \sqrt{n}} = \frac{16.2 - 15.0}{3.6 / \sqrt{36}} = \frac{1.2}{3.6 / 6} = \frac{1.2}{0.60} = 2.00

Step 3: Compare to Critical Value: Since Zcalc=2.00>Zcrit=1.645Z_{calc} = 2.00 > Z_{crit} = 1.645, the calculated value lies in the critical rejection region.

Step 4: Conclusion: Reject H0H_0 at the α=0.05\alpha = 0.05 level (pp-value =1−Φ(2.00)=0.0228<0.05= 1 - \Phi(2.00) = 0.0228 < 0.05). There is sufficient evidence to conclude that the plant's mean discharge lead concentration significantly exceeds 15.0 ppb.

2. Simple Linear Regression and Correlation

Simple linear regression models the relationship between an independent predictor variable xx and a dependent response variable yy.

Least-Squares Regression Equations

Model: y^=a+bx\text{Model: } \hat{y} = a + b x

Where bb is the slope and aa is the yy-intercept.

NCEES Formulas for Sum of Squares

Sxx=∑i=1n(xi−xˉ)2=∑xi2−(∑xi)2nS_{xx} = \sum_{i=1}^n (x_i - \bar{x})^2 = \sum x_i^2 - \frac{(\sum x_i)^2}{n} Syy=∑i=1n(yi−yˉ)2=∑yi2−(∑yi)2nS_{yy} = \sum_{i=1}^n (y_i - \bar{y})^2 = \sum y_i^2 - \frac{(\sum y_i)^2}{n} Sxy=∑i=1n(xi−xˉ)(yi−yˉ)=∑xiyi−(∑xi)(∑yi)nS_{xy} = \sum_{i=1}^n (x_i - \bar{x})(y_i - \bar{y}) = \sum x_i y_i - \frac{(\sum x_i)(\sum y_i)}{n}

Least-Squares Parameters

Slope: b=SxySxx\text{Slope: } b = \frac{S_{xy}}{S_{xx}} Intercept: a=yˉ−bxˉ\text{Intercept: } a = \bar{y} - b \bar{x}

Sample Correlation Coefficient (rr) and Coefficient of Determination (R2R^2)

  • Sample Correlation Coefficient (rr): r=SxySxxSyy,−1≤r≤1r = \frac{S_{xy}}{\sqrt{S_{xx} S_{yy}}}, \quad -1 \le r \le 1
  • Coefficient of Determination (R2R^2): R2=r2R^2 = r^2 R2R^2 represents the proportion of total variation in yy explained by the linear relationship with xx. For example, R2=0.81R^2 = 0.81 means 81% of the variation in yy is explained by xx.

Worked Engineering Example: Stress-Strain Calibration Curve

Problem: An experiment measures force xx (kN) and resulting deflection yy (mm) for a structural bracket (n=5n = 5 data points):

  • Sxx=20.0 kN2S_{xx} = 20.0\text{ kN}^2
  • Syy=80.0 mm2S_{yy} = 80.0\text{ mm}^2
  • Sxy=36.0 kN⋅mmS_{xy} = 36.0\text{ kN}\cdot\text{mm}
  • xˉ=10.0 kN,yˉ=25.0 mm\bar{x} = 10.0\text{ kN}, \quad \bar{y} = 25.0\text{ mm}

Find slope bb, intercept aa, regression equation y^\hat{y}, correlation coefficient rr, coefficient of determination R2R^2, and predicted deflection for x=15.0 kNx = 15.0\text{ kN}.

Solution: Step 1: Compute Slope bb and Intercept aa: b=SxySxx=36.020.0=1.80 mm/kNb = \frac{S_{xy}}{S_{xx}} = \frac{36.0}{20.0} = 1.80\text{ mm/kN} a=yˉ−bxˉ=25.0−(1.80×10.0)=25.0−18.0=7.0 mma = \bar{y} - b \bar{x} = 25.0 - (1.80 \times 10.0) = 25.0 - 18.0 = 7.0\text{ mm} Regression Line: y^=7.0+1.80x\text{Regression Line: } \hat{y} = 7.0 + 1.80 x

Step 2: Compute Correlation rr and R2R^2: r=SxySxxSyy=36.020.0×80.0=36.01600=36.040.0=0.900r = \frac{S_{xy}}{\sqrt{S_{xx} S_{yy}}} = \frac{36.0}{\sqrt{20.0 \times 80.0}} = \frac{36.0}{\sqrt{1600}} = \frac{36.0}{40.0} = 0.900 R2=r2=(0.900)2=0.8100(81.0% of variance explained)R^2 = r^2 = (0.900)^2 = 0.8100 \quad (81.0\% \text{ of variance explained})

Step 3: Predict Response at x=15.0 kNx = 15.0\text{ kN}: y^(15.0)=7.0+(1.80×15.0)=7.0+27.0=34.0 mm\hat{y}(15.0) = 7.0 + (1.80 \times 15.0) = 7.0 + 27.0 = 34.0\text{ mm}

Goodness of Fit: What Each Statistic Actually Tells You

NCEES lists goodness of fit as its own sub-topic and names three measures: the correlation coefficient, standard errors, and R2R^2. They answer different questions, and the exam tests whether you know which is which.

StatisticRangeWhat it measuresWhat it does not tell you
rr (correlation coefficient)−1-1 to +1+1Strength and direction of a linear associationWhether the relationship is causal, or whether a nonlinear model would fit better
R2R^2 (coefficient of determination)00 to 11Fraction of the variance in yy explained by the regressionDirection of the relationship (the sign is squared away)
SeS_e (standard error of estimate)≥0\ge 0, in units of yyTypical size of a residual — the scatter about the fitted lineAnything about the slope's own uncertainty
R2=r2=1−SSESST,Se=SSEn−2R^2 = r^2 = 1 - \frac{SSE}{SST}, \qquad S_e = \sqrt{\frac{SSE}{n-2}}

where SSE=∑(yi−y^i)2SSE = \sum(y_i - \hat{y}_i)^2 is the residual sum of squares and SST=∑(yi−yˉ)2SST = \sum(y_i - \bar{y})^2 is the total sum of squares. The n−2n-2 divisor reflects the two parameters (slope and intercept) already estimated from the data.

The Three Traps NCEES Builds Into Regression Items

  1. Sign confusion. R2=0.81R^2 = 0.81 is consistent with r=+0.9r = +0.9 or r=−0.9r = -0.9. You must read the slope's sign to know the direction. If a question gives you R2R^2 and asks for rr, it must also tell you whether the trend rises or falls.
  2. "High R2R^2 means the model is right." It does not. Fitting a straight line to genuinely curved data can still yield R2>0.9R^2 > 0.9 over a narrow range while extrapolating disastrously. Goodness of fit is a statement about residuals inside the sampled range only.
  3. Extrapolation. A calibration curve fit over 00–50 kPa50\ \text{kPa} says nothing about behavior at 200 kPa200\ \text{kPa}.

Interpretation script for the exam: "R2=0.94R^2 = 0.94 means 94% of the observed variation in the response is accounted for by the linear model; the remaining 6% is residual scatter." That sentence, with the right number substituted, is the correct answer to most conceptual regression items.

3. NCEES Reference Summary Table

Statistical ToolFormula / StatisticConditions / Critical Values
Z-Confidence Intervalxˉ±zα/2(σ/n)\bar{x} \pm z_{\alpha/2} (\sigma / \sqrt{n})Known σ\sigma or n≥30n \ge 30; z0.025=1.960z_{0.025} = 1.960
t-Confidence Intervalxˉ±tα/2,n−1(s/n)\bar{x} \pm t_{\alpha/2, n-1} (s / \sqrt{n})Unknown σ\sigma, n<30n < 30, df=n−1df = n-1
Z-Test StatisticZ=xˉ−μ0σ/nZ = \frac{\bar{x} - \mu_0}{\sigma / \sqrt{n}}Compare to ZcritZ_{crit} or Φ(Z)\Phi(Z) for pp-value
t-Test Statistict=xˉ−μ0s/nt = \frac{\bar{x} - \mu_0}{s / \sqrt{n}}Compare to tcritt_{crit} with df=n−1df = n-1
Regression Slopeb=SxySxxb = \frac{S_{xy}}{S_{xx}}Least-squares fit minimizing ∑ei2\sum e_i^2
Regression Intercepta=yˉ−bxˉa = \bar{y} - b\bar{x}Line passes through (xˉ,yˉ)(\bar{x}, \bar{y})
Correlation Coefficientr=SxySxxSyyr = \frac{S_{xy}}{\sqrt{S_{xx} S_{yy}}}Scale-invariant measure of linear association
Test Your Knowledge

An environmental engineer tests wastewater samples for lead concentration. The regulatory limit standard is 15 ppb. A sample of n = 36 readings yields a mean concentration of 16.2 ppb with a known population standard deviation sigma = 3.6 ppb. At a significance level alpha = 0.05 (Z_crit = 1.645 for a one-tailed test), what is the calculated test statistic Z_calc and the statistical decision regarding H0: mu <= 15 vs Ha: mu > 15?

A

Z_calc = 0.33; Do not reject H0

B

Z_calc = 2.00; Reject H0

C

Z_calc = 1.20; Do not reject H0

D

Z_calc = 3.33; Reject H0

Test Your Knowledge

A simple linear regression model is fit to n = 5 paired data points relating applied force x (kN) to structural beam deflection y (mm). Summary statistics are: S_xx = 20.0, S_yy = 80.0, and S_xy = 36.0. What is the sample correlation coefficient r and the coefficient of determination R^2?

A

r = 0.4500, R^2 = 0.2025

B

r = 0.8000, R^2 = 0.6400

C

r = 0.9000, R^2 = 0.8100

D

r = 0.9500, R^2 = 0.9025

Test Your Knowledge

In a simple linear regression analysis of calibration data, sample means are x_bar = 10.0 and y_bar = 25.0. The calculated regression slope is b = 1.80. What is the y-intercept 'a' of the regression line y_hat = a + b*x, and what is the predicted response y_hat when x = 15.0?

A

a = 43.0, y_hat = 70.0

B

a = 15.0, y_hat = 42.0

C

a = 2.5, y_hat = 29.5

D

a = 7.0, y_hat = 34.0

Test Your Knowledge

A quality test uses alpha = 0.05. In the long run, what does that value represent?

A

The probability of accepting a defective production lot

B

The probability of rejecting a true null hypothesis, that is, a Type I error

C

The probability of failing to detect a real shift in the process mean

D

The proportion of the population lying outside the confidence interval

Test Your Knowledge

A regression of thermocouple output on temperature gives R-squared = 0.64 with a clearly decreasing trend. What is the correlation coefficient?

A

+0.80

B

-0.64

C

-0.80

D

+0.64

Sections you finish are checked off in the contents.