Y Hat Linear Algebra Calculator

Enter observations and clean predictor matrix rows. Get y hat, residuals, leverage, and projection details. Export clear reports for study, teaching, and checks quickly.

Calculator

Use commas, spaces, or one value per line.
Use one row per observation. Separate columns with commas.
Optional rows for new fitted estimates.

Formula Used

For ordinary least squares, the coefficient vector is calculated as:

β = (XTX)-1XTy

The fitted vector is:

ŷ = Xβ

The hat matrix is:

H = X(XTX)-1XT

Residuals are calculated with e = y - ŷ. Leverage values are the diagonal entries of H. With ridge enabled, the inverse uses XTX + λI.

How to Use This Calculator

  1. Enter the y values as a vertical list or comma list.
  2. Enter each X row on a new line.
  3. Keep the same row count in y and X.
  4. Choose whether an intercept column should be added.
  5. Enter ridge lambda only when stabilization is needed.
  6. Press Submit to view results above the form.
  7. Use CSV or PDF buttons to export the same calculation.

Example Data Table

Row X1 X2 y
1125
2216
33410
44311
55514

Y Hat Values in Linear Algebra

A y hat value is a fitted value. It comes from a linear model. In matrix terms, the model starts with a response vector y and a design matrix X. The calculator estimates the coefficient vector beta. Then it multiplies X by beta to produce y hat.

Why Y Hat Matters

Y hat helps you compare observed values with fitted values. The gap between them is the residual. Small residuals can suggest a stronger fit. Large residuals can reveal outliers, missing predictors, or a weak model form. In linear algebra classes, y hat also shows projection. The fitted vector sits in the column space of X when ordinary least squares is used.

Using Matrix Inputs

This tool accepts y as a list and X as matrix rows. Each row must match one observation. Each column is a predictor. You can add an intercept column automatically. That option is useful because many regression models include a constant term. You can also enter new predictor rows. The calculator will use the same coefficient vector to estimate new fitted values.

Projection and Leverage

The hat matrix maps y to y hat. It is named H because it puts the hat on y. Its diagonal values are leverages. A high leverage row has an unusual predictor pattern. It can strongly affect the fitted line, plane, or higher dimensional surface. This calculator reports leverage so you can inspect influential rows.

Ridge Stabilizer

Some matrices are singular or nearly singular. That means the normal equation inverse may fail. The ridge option adds a small value to the diagonal of X transpose X. This can stabilize the calculation. With ridge enabled, the fitted values are shrinkage estimates. They are helpful for practice, but they are not the exact orthogonal projection used in plain least squares.

Good Practice

Check the row counts first. Then review coefficients, y hat, residuals, and summary error. Use more decimals for homework checks. Use fewer decimals for reports. Download the CSV for spreadsheets. Download the PDF for quick sharing or printing. Keep source data unchanged before exporting. That makes each saved result easier to audit. Recheck units when predictors represent different measurement scales or transformed variables later.

FAQs

What is y hat?

Y hat is the fitted or predicted value from a model. In linear algebra, it is the projection of y onto the column space of X for ordinary least squares.

What does the hat matrix do?

The hat matrix maps observed y values to fitted y hat values. It is written as H, where y hat equals H multiplied by y.

Should I add an intercept?

Add an intercept when the model should include a constant baseline. Most regression tasks use it. Turn it off only when your matrix already includes one.

Why did the inverse fail?

The inverse can fail when columns are dependent or the matrix is singular. Try removing duplicate predictors, adding rows, or using a small ridge lambda.

What is leverage?

Leverage is a diagonal value from the hat matrix. Higher leverage means that row has an unusual predictor pattern and may strongly influence the fitted result.

What does ridge lambda change?

Ridge lambda adds a stabilizing value to the diagonal. It helps with singular matrices, but the result is no longer the exact ordinary least squares projection.

Can I predict new y hat values?

Yes. Enter new predictor rows with the same column count as X. The calculator multiplies them by the fitted coefficient vector.

What does the CSV file include?

The CSV includes coefficients, observed y values, y hat values, residuals, leverage, new predictions, and summary metrics for spreadsheet review.

Related Calculators

Paver Sand Bedding Calculator (depth-based)Paver Edge Restraint Length & Cost CalculatorPaver Sealer Quantity & Cost CalculatorExcavation Hauling Loads Calculator (truck loads)Soil Disposal Fee CalculatorSite Leveling Cost CalculatorCompaction Passes Time & Cost CalculatorPlate Compactor Rental Cost CalculatorGravel Volume Calculator (yards/tons)Gravel Weight Calculator (by material type)

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.