gls calculator

Generalized Least Squares (GLS) Calculator

Estimate a linear model y = b0 + b1x using GLS with diagonal covariance (weighted least squares). Enter values as comma, space, or new-line separated lists.

Leave blank to use equal variance (ordinary least squares).
Enter your data and click Calculate GLS.

What this GLS calculator does

This tool calculates a straight-line regression using Generalized Least Squares (GLS) under a common practical case: each data point can have a different error variance, but errors are uncorrelated. In that setting, GLS becomes Weighted Least Squares (WLS), where each point is weighted by:

weighti = 1 / variancei

Points with lower variance receive more weight, and points with noisier measurements receive less. This often produces better coefficient estimates than ordinary least squares when heteroskedasticity is present.

How to use the calculator

1) Enter your X and Y values

Use matching lists. If X has 12 values, Y must also have 12 values. You can separate numbers with commas, spaces, or line breaks.

2) Add variances if you have them

Variance entries are optional. If provided, you must include one positive variance per observation. If left blank, all weights are equal.

3) Optional prediction

If you enter a value for X in the prediction field, the calculator returns the predicted Y using your fitted GLS equation.

Output explained

  • Intercept (b0): expected Y when X = 0.
  • Slope (b1): expected change in Y for a one-unit increase in X.
  • Weighted R²: goodness-of-fit based on weighted sums of squares.
  • SSE: weighted sum of squared residuals.
  • Standard errors: uncertainty estimates for b0 and b1.

When GLS is useful

Use GLS/WLS when residual variance is not constant across observations. Common examples include:

  • Measurements where precision changes by instrument or batch.
  • Rates and means computed from different sample sizes.
  • Economic data where volatility grows with scale.
  • Any regression where diagnostics suggest heteroskedasticity.

Practical tips

Start with a residual plot

If residual spread increases with fitted values, equal-variance OLS may be inefficient. GLS can stabilize estimation by assigning appropriate weights.

Use defensible variance estimates

Weights should come from measurement theory, replicated observations, or a justified variance model. Arbitrary weights can bias interpretation.

Interpret coefficients in context

A mathematically significant coefficient is not automatically practically important. Always combine model output with domain knowledge.

Limitations of this online implementation

This calculator handles GLS with a diagonal covariance structure (no correlation between errors). Full GLS can also model correlated errors using a complete covariance matrix, which is outside the scope of this page.

Bottom line

If your regression data points do not have equal reliability, a GLS approach can give you more trustworthy line estimates than standard OLS. Use this calculator to quickly estimate the model, inspect key metrics, and test predictions.

🔗 Related Calculators