Second-difference test of a linear mean profile (source code)

= Second-difference test of a linear mean profile

At equally spaced distinct times, a mean profile is affine exactly when its consecutive second differences vanish. These form $p-2$ independent contrasts. At unequal times, compare adjacent slopes instead: $(\mu_{i+1}-\mu_i)/(t_{i+1}-t_i)-(\mu_i-\mu_{i-1})/(t_i-t_{i-1})$. A <Hotelling test of linear hypotheses> tests these restrictions jointly with unknown covariance.