Regressions

Creating a regression in the Desmos Graphing Calculator, Geometry Tool, and 3D Calculator allows you to find a mathematical expression (like a line or a curve) to model the relationship between two sets of data. Get started with the video on the right, then dive deeper with the resources below.

Getting Started

To get started with regressions, you can follow a Regressions Tour in the help menu in the upper right of the calculator.

Screenshot of Graphing Calculator with the Help Menu open and tours highlighted.

 

Regressions from a Table

Screenshot of Graphing Calculator with the Help Menu open and tours highlighted.

To get started, you’ll need to add data to a table. You can either create a table and enter the data manually, or copy data from a spreadsheet and paste it into a blank expression line.

Use the Zoom Fit icon in the bottom left of the expression line to automatically adjust the graph settings to best display your data.

GIF using the Add Regression icon in the expression list and the Add Regression button in the options menu next to the y variable for a table of data.

To create a regression, click the Add Regression icon to the left of your expression, or open the options menu next to your y variable. This will automatically add a Linear Regression below your table.

Animation shown in the Graphing Calculator with 3 columns of data (x1, y1, and y2). A regression is added with a dropdown menu open to choose between a regression for y1 or y2.

Click on Linear Regression to open the regression model dropdown menu and explore which regression model best fits your data.

If you have multiple columns of data for the same independent variable, you will also see a dropdown to choose which column you want to use in your model.

Screenshot of graphing calculator showing a linear regression with plotted residuals.

From the model, you can explore the statistics, the correlation coefficient r (for linear regressions) or coefficient of determination R^2 (for nonlinear regressions), and plot the residuals (the vertical distance between your data points and the model).

Once the residuals are plotted, you can use the Zoom Fit icon to adjust the graph to best display your residuals.

GIF turning on draggable points for a table with a Quadratic Regression. As the points are moved, the regression model updates. Then, the regression model is exported, converted from y= to f(x)=, and test the value f(0).

To explore, press and hold the colored circle in the table to open the Options Menu and make your points draggable. This allows you to see how changing their values affects the regression model.

You can also copy a snapshot to the expression list. Once the snapshot is in the expression list, you can define it as a function, plug in different variables, and test predictions based on your model.

GIF exporting a quadratic regression model to the expression list.

Table regressions allow you to model curves to best fit your graph from a built in list of options. To edit the model, try viewing the model source and exporting it to the expression list or creating a standalone regression model directly in an expression line.

Note: Table regressions are only available in the Graphing Calculator and Geometry Tool.

 

Custom Regression Models

Table regressions only model curves from a set list of options. To use your own model, try creating a custom regression directly in an expression line.

Once you have data in a table, you can create a custom regression model in a new line by using the tilde symbol (~) in place of the equals sign (\(=\)). Use your table's column names (e.g., \(x_1\) and \(y_1\)) to reference the data in your model.

For example, if your quadratic model should follow the form \(y=ax^2\), enter the expression \(y_1\) ~ \(ax_1^2\) to find the parameter a that best fits your data.

Note that the ~ symbol is usually to the left of the \(1\) on most keyboards or in the bottom row of the ABC part of the Desmos keypad.

Screenshot of a table of data with the regression a~x1^2.

You can also experiment with models that are not listed in the dropdown menu, such as a sinusoidal model. For example, you can enter \(y_1\) ~ \(a\) \(sin(bx_1+c)+d\) to fit a sine wave to your data. This will find the parameters \(a\), \(b\), \(c\), and \(d\) that best match the sinusoidal pattern in your data.

Once you’ve performed a regression, the parameter values are stored to their respective variables, allowing you to use them in other calculations. For example, after performing the sinusoidal regression above, try defining a new function, \(f(x) = a\) \(sin(bx+c)+d\), using the values of \(a\), \(b\), \(c\), and \(d\). You can then test values, such as \(f(0)\), to find the y-intercept.

Screenshot of a table of data with a sinusoidal wave regression. The y-axis has label Temperature and the x-axis has label Time

 

To get more information about how Desmos does non-linear regressions and for some tips on how to best find a regression model, see our article on Non-Linear Regressions.

 

Learn More

Please write in with any questions or feedback to support@desmos.com.