R-Squared Calculator

Calculate coefficient of determination R squared from actual and predicted values

Example Results

1 examples

Evaluate regression fit

Calculate R squared from actual and predicted response values

{
  "result": {
    "rSquared": 0.6,
    "explainedVariancePercent": 60,
    "sumSquaredError": 2.4,
    "totalSumSquares": 6
  }
}
View input parameters
{ "actualValues": "2, 4, 5, 4, 5", "predictedValues": "2.8, 3.4, 4, 4.6, 5.2", "decimalPlaces": 4 }

Key Facts

Category
Math, Date & Finance
Input Types
textarea, number
Output Type
json
Sample Coverage
4
API Ready
Yes

Overview

The R-Squared Calculator is a specialized tool designed to measure the goodness of fit for regression models by calculating the coefficient of determination. By comparing actual observed data against predicted values, it quantifies how much of the variance in the dependent variable is explained by the model, providing essential metrics like R², explained variance percentage, and sum of squared errors.

When to Use

  • Evaluating the accuracy of a linear or non-linear regression model after training.
  • Comparing different statistical models to determine which one better fits a specific dataset.
  • Validating forecasting results against historical data to assess predictive performance.

How It Works

  • Input your set of actual observed values and the corresponding predicted values from your model into the respective text areas.
  • Specify the desired number of decimal places to control the precision of the calculated results.
  • The tool computes the Sum of Squared Errors (SSE) and the Total Sum of Squares (SST) based on your data points.
  • The final R-squared value is derived using the formula 1 - (SSE/SST) and returned as a JSON object containing the variance percentage.

Use Cases

Data scientists verifying the performance of machine learning algorithms on test datasets.
Financial analysts assessing the reliability of stock price prediction models against historical trends.
Researchers measuring the strength of the relationship between variables in experimental studies.

Examples

1. Regression Model Validation

Data Analyst
Background
A data analyst has developed a linear regression model to predict housing prices and needs to quantify its accuracy.
Problem
Determine the percentage of variance in prices explained by the model to justify its use to stakeholders.
How to Use
Enter the actual sale prices in the 'Actual Values' field and the model's estimates in the 'Predicted Values' field.
Example Config
decimalPlaces: 4
Outcome
The tool returns an R-squared of 0.60, indicating that 60% of the price variance is captured by the model.

2. Sales Forecast Accuracy Check

Business Intelligence Specialist
Background
A retail company wants to evaluate how well their monthly sales forecasts matched the actual revenue generated over the last quarter.
Problem
Quantify the goodness of fit for the forecasting algorithm used by the inventory team.
How to Use
Paste the actual monthly revenue figures and the corresponding forecasted values into the calculator.
Example Config
decimalPlaces: 2
Outcome
The result provides the explained variance percentage and the total sum of squares, highlighting the forecast's reliability.

Try with Samples

math-&-numbers

Related Hubs

FAQ

What does an R-squared value of 1.0 indicate?

It indicates a perfect fit where the model explains 100% of the variance in the data.

Can R-squared be negative?

Yes, if the chosen model fits the data worse than a horizontal line representing the mean of the actual values.

What is the difference between SSE and SST?

SSE measures the deviation of predicted values from actual values, while SST measures the deviation of actual values from their mean.

How many data points do I need?

You need at least two pairs of actual and predicted values, though more points provide a more reliable metric.

Is R-squared the same as the Correlation Coefficient?

In simple linear regression, R-squared is the square of the Pearson correlation coefficient (r).

API Documentation

Request Endpoint

POST /en/api/tools/r-squared-calculator

Request Parameters

Parameter Name Type Required Description
actualValues textarea No -
predictedValues textarea No -
decimalPlaces number No -

Response Format

{
  "key": {...},
  "metadata": {
    "key": "value"
  },
  "error": "Error message (optional)",
  "message": "Notification message (optional)"
}
JSON Data: JSON Data

AI MCP Documentation

Add this tool to your MCP server configuration:

{
  "mcpServers": {
    "elysiatools-r-squared-calculator": {
      "name": "r-squared-calculator",
      "description": "Calculate coefficient of determination R squared from actual and predicted values",
      "baseUrl": "https://elysiatools.com/mcp/sse?toolId=r-squared-calculator",
      "command": "",
      "args": [],
      "env": {},
      "isActive": true,
      "type": "sse"
    }
  }
}

You can chain multiple tools, e.g.: `https://elysiatools.com/mcp/sse?toolId=png-to-webp,jpg-to-webp,gif-to-webp`, max 20 tools.

If you encounter any issues, please contact us at [email protected]