Skip to content

rsq

Square of the Pearson correlation coefficient (R²).

v = rsq(knownys, knownxs)

Returns pearson(y, x)^2 — the coefficient of determination for a linear fit. A value in [0, 1] indicating the proportion of variance in y explained by a linear model in x.

rsq([1 2 3 4], [2 4 6 8]) % 1.0
  • pearson — Pearson product-moment correlation coefficient.
  • linest — Linear regression coefficients (with optional statistics).
  • trend — Linear-trend predictions.