Trend Lines

From LibreOffice Help
Jump to: navigation, search

Trend lines can be added to all 2D chart types except for Pie and Stock charts.

If an element of a data series is selected, this command works on that data series only. If no element is selected, this command works on all data series.

Choose Insert - Trend Lines (Charts)

Note.png If you insert a trend line to a chart type that uses categories, like Line or Column, then the numbers 1, 2, 3, are used as x-values to calculate the trend line.
  1. To insert trend lines for all data series, double-click the chart to enter edit mode. Choose Insert - Trend Lines, then select the type of trend line from None, Linear, Logarithmic, Exponential, or Power trend line.
  2. To insert a trend line for a single data series, select the data series in the chart, right-click to open the context menu, and choose Insert - Trend Line.
  3. To delete a single trend line or mean value line, click the line, then press the Del key.
  4. To delete all trend lines, choose Insert - Trend Lines, then select None.
Note.png A trend line is shown in the legend automatically.

Mean Value Lines are special trend lines that show the mean value. Use Insert - Mean Value Lines to insert mean value lines for data series.

If an element of a data series is selected, this command works on that data series only. If no element is selected, this command works on all data series.

The trend line has the same color as the corresponding data series. To change the line properties, select the trend line and choose Format - Format Selection - Line.

To show the trend line equation, select the trend line in the chart, right-click to open the context menu, and choose Insert Trend Line Equation.

When the chart is in edit mode, LibreOffice gives you the equation of the trend line and the coefficient of determination R². Click on the trend line to see the information in the status bar.

Note.png For a category chart (for example a line chart), the trend line information is calculated using numbers 1, 2, 3, … as x-values. This is also true if your data series uses other numbers as names for the x-values. For such charts the XY chart type might be more suitable.

To show the equation and the coefficient of determination, select the trend line and choose Format - Format Selection - Equation.

You can also calculate the parameters using Calc functions as follows.

The linear regression equation

The linear regression follows the equation y=m*x+b.

m = SLOPE(Data_Y;Data_X)

b = INTERCEPT(Data_Y ;Data_X)

Calculate the coefficient of determination by

r² = RSQ(Data_Y;Data_X)

Besides m, b and r² the array function LINEST provides additional statistics for a regression analysis.

The logarithm regression equation

The logarithm regression follows the equation y=a*ln(x)+b.

a = SLOPE(Data_Y;LN(Data_X))

b = INTERCEPT(Data_Y ;LN(Data_X))

r² = RSQ(Data_Y;LN(Data_X))

The exponential regression equation

For exponential trend lines a transformation to a linear model takes place. The optimal curve fitting is related to the linear model and the results are interpreted accordingly.

The exponential regression follows the equation y=b*exp(a*x) or y=b*m^x, which is transformed to ln(y)=ln(b)+a*x or ln(y)=ln(b)+ln(m)*x respectively.

a = SLOPE(LN(Data_Y);Data_X)

The variables for the second variation are calculated as follows:

m = EXP(SLOPE(LN(Data_Y);Data_X))

b = EXP(INTERCEPT(LN(Data_Y);Data_X))

Calculate the coefficient of determination by

r² = RSQ(LN(Data_Y);Data_X)

Besides m, b and r² the array function LOGEST provides additional statistics for a regression analysis.

The power regression equation

For power regression curves a transformation to a linear model takes place. The power regression follows the equation y=b*x^a , which is transformed to ln(y)=ln(b)+a*ln(x).

a = SLOPE(LN(Data_Y);LN(Data_X))

b = EXP(INTERCEPT(LN(Data_Y);LN(Data_X))

r² = RSQ(LN(Data_Y);LN(Data_X))

Constraints

The calculation of the trend line considers only data pairs with the following values:

  1. logarithm regression: only positive x-values are considered,
  2. exponential regression: only positive y-values are considered,
  3. power regression: only positive x-values and positive y-values are considered.

You should transform your data accordingly; it is best to work on a copy of the original data and transform the copied data.

The polynomial regression equation

A polynomial regression curve cannot be added automatically. You must calculate this curve manually.

Create a table with the columns x, x², x³, … , xⁿ, y up to the desired degree n.

Use the formula =LINEST(Data_Y,Data_X) with the complete range x to xⁿ (without headings) as Data_X.

The first row of the LINEST output contains the coefficients of the regression polynomial, with the coefficient of xⁿ at the leftmost position.

The first element of the third row of the LINEST output is the value of r². See the LINEST function for details on proper use and an explanation of the other output parameters.


Related Topics

Y Error Bars tab page