Documentation

Regression mathematics#

Trendline overview is the practical starting point. This page summarises the shared numerical methods behind the available models.

Least squares#

GraphX fits selected calibrated graph points by minimising residual error, where

ri=yi−y^i,SSE=∑iri2.r_i=y_i-\hat y_i,\qquad SSE=\sum_i r_i^2.

Linear regression#

Linear regression fits y=ax+by=ax+b by least squares. For Linear models, an optional fixed Y intercept constrains the fit to the supplied value rather than estimating bb. See Linear regression.

Polynomial regression#

Polynomial models use orders 2–6. Direct powers of a large or offset X value can be poorly conditioned, so GraphX centres and scales X with t=(x−c)/st=(x-c)/s, then constructs a polynomial design matrix. It solves the least-squares problem with modified Gram–Schmidt QR decomposition:

A=QR,Rc=QTy.A=QR,\qquad Rc=Q^Ty.

A fixed intercept uses a constrained basis. GraphX evaluates the stable centred/scaled basis; when expanding it into original-X coefficients would lose meaningful precision, it displays the centred/scaled representation instead. See Polynomial regression.

Transformed models#

  • Logarithmic regression uses z=ln⁡(x)z=\ln(x) and fits y=a+bzy=a+bz; x>0x>0 is required.
  • Exponential regression fits y=aebxy=ae^{bx} by fitting ln⁡(y)=ln⁡(a)+bx\ln(y)=\ln(a)+bx; y>0y>0 is required.
  • Power-law regression fits y=axby=ax^b by fitting ln⁡(y)=ln⁡(a)+bln⁡(x)\ln(y)=\ln(a)+b\ln(x); both x>0x>0 and y>0y>0 are required.

R²#

GraphX reports original-Y-space R2R^2 from

R2=1−SSESST,SST=∑i(yi−yˉ)2.R^2=1-\frac{SSE}{SST},\qquad SST=\sum_i(y_i-\bar y)^2.

Exponential and power models additionally report transformed-space R2R^2 for their transformed least-squares calculation. The two answer different questions; see Understanding R². Fit and display domains remain separate as described in Fit and display ranges.