graph
n 20
ρ 0.85
random seed 212
×

Directions

Select graph 1, 2, or 3 to change the display. Graph 1 shows the data (blue points) and the fitted least-squares regression line (red). Graph 2 shows the data and the fitted points (red). Graph 3 adds a rug on each of the \(y\) axes: the blue rug on the left axis shows the \(y\) values, and the red rug on the right axis shows the fitted \(\hat{y}\) values.

Use the n slider to change the sample size, the \(\rho\) slider to change the correlation parameter of the bivariate normal distribution from which the sample is drawn, and the random seed slider to generate a different random sample.

Notice how the plot changes dramatically as the parameter \(\rho\) is changed. You may also wish to experiment with different sample sizes by changing \(n\) or different random samples by changing the seed.

×

Details

In general, \(R^2\) is often referred to as the coefficient of determination and its verbal interpretation is that it is the fraction of variation explained by the model. This in fact is illustrated in our Demonstration in the case of simple linear regression.

A random sample of size \(n\) is generated from a bivariate normal distribution with correlation parameter \(\rho\), means 0, and variances 1. The first plot, graph 1, shows the data and the fitted regression line. Next, graph 2 shows the data and the fitted points. In graph 3, a rug is added on each of the \(y\) axes. The axes on the left with the blue rug show the \(y\) values; the axes on the right with the red rug show the fitted \(y\) values.

The plot label shows \(R^2 = r^2 = S_{reg}/S_y\), where \(r\) is the correlation coefficient, \(S_y\) is the sum of the squared deviations of the \(y\)'s from their mean, and \(S_{reg}\) is the sum of the squared deviations of the \(\hat{y}\)'s from their mean. In graph 3, the rugs provide a visualization of the spread of the \(y\)'s and \(\hat{y}\)'s.

In statistics courses not based on calculus, it is often mentioned when discussing simple linear regression that \(R^2 = r^2\) and that \(r^2\) is the fraction of variation explained by the model. This Demonstration is especially useful for explaining the concept to these students.

×

About

This simulation was made at the University of Colorado Boulder, Department of Chemical and Biological Engineering. It is a browser-based version of the Wolfram Demonstration "Visualizing R-Squared in Statistics", contributed by Ian McLeod.

⚠️ Simulation Under ReviewThis content is still being reviewed for quality and accuracy and may be updated in the future. Feel free to send us feedback.