Hi,
How does OpenOffice calculate the trend lines that can be inserted in graphs? According to Wikipedia there are several methods to do linear regression, and I would like to know which one OO uses... http://en.wikipedia.org/wiki/Linear_regression
Any help appreciated!
[Solved] Trend line calculation in chart
[Solved] Trend line calculation in chart
Last edited by MrProgrammer on Thu Sep 05, 2024 3:53 am, edited 2 times in total.
Reason: Edited topic's subject
Reason: Edited topic's subject
OpenOffice 3.2 on MacOS 10.6
- Robert Tucker
- Volunteer
- Posts: 1250
- Joined: Mon Oct 08, 2007 1:34 am
- Location: Manchester UK
Re: Trend line
This page:
http://dataninja.wordpress.com/2006/02/ ... lications/
would lead me to believe that it is an ordinary least squares (OLS) fit – or was in 2006!
http://dataninja.wordpress.com/2006/02/ ... lications/
would lead me to believe that it is an ordinary least squares (OLS) fit – or was in 2006!
LibreOffice 7.x.x on Arch and Fedora.
Re: Trend line
Self made solution:
For linear regression use the 'LINEST' function, for logarithmic regression use the 'LOGEST' function. See in OOo Help. Attention: the LINEST and LOGEST functions are ARRAY FUNCTIONS! See in OOo Help too!
If 'y' datas of chart scattered along a theoretical straight line, then the linear regression will be really "LINEAR" estimation:
y = a*x^1+b*x^0 or the known format y = a*x+b: this is the equotion of straigth line.
The LINEST function able to determine the 'a' and 'b' constant values of equotion.
The format of more-degree of polynomial expession:
The linear regression maybe write to polinomial format with 'n' exponent: y = c0*x^0 + c1*x^1 + c2*x^2 +... cn*x^n
see the example file:
Another solution:
In chart edit: Click on serial (on line) Insert->trendline...
For linear regression use the 'LINEST' function, for logarithmic regression use the 'LOGEST' function. See in OOo Help. Attention: the LINEST and LOGEST functions are ARRAY FUNCTIONS! See in OOo Help too!
If 'y' datas of chart scattered along a theoretical straight line, then the linear regression will be really "LINEAR" estimation:
y = a*x^1+b*x^0 or the known format y = a*x+b: this is the equotion of straigth line.
The LINEST function able to determine the 'a' and 'b' constant values of equotion.
The format of more-degree of polynomial expession:
The linear regression maybe write to polinomial format with 'n' exponent: y = c0*x^0 + c1*x^1 + c2*x^2 +... cn*x^n
see the example file:
Another solution:
In chart edit: Click on serial (on line) Insert->trendline...
Tibor Kovacs, Hungary; LO7.5.8/25.8.5.2 /Win7-10-11 x64Prof.
PortableApps: LO3.3.0-25.8.5.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
PortableApps: LO3.3.0-25.8.5.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
- MrProgrammer
- Moderator
- Posts: 5455
- Joined: Fri Jun 04, 2010 7:57 pm
- Location: Wisconsin, USA
Re: Trend line
I inserted a linear trendline on a graph and had it's equation displayed. (R squared was .9916 so the relationship was close to linear but not exact.) Then I used LINEST to calculate the slope and intercept of the least squares line. The trendline equation matches the LINEST calculation to 9 significant digits. Help says "LINEST finds a straight line y = a + bx that best fits the data, using linear regression (the least squares method)" therefore the graph's trendline is calculated the same way.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.8, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).
AOO 4.1.7 Build 9800, MacOS 13.7.8, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).
Re: Trend line
Great, that must be the answer then!MrProgrammer wrote:I inserted a linear trendline on a graph and had it's equation displayed. (R squared was .9916 so the relationship was close to linear but not exact.) Then I used LINEST to calculate the slope and intercept of the least squares line. The trendline equation matches the LINEST calculation to 9 significant digits. Help says "LINEST finds a straight line y = a + bx that best fits the data, using linear regression (the least squares method)" therefore the graph's trendline is calculated the same way.
OpenOffice 3.2 on MacOS 10.6
- MrProgrammer
- Moderator
- Posts: 5455
- Joined: Fri Jun 04, 2010 7:57 pm
- Location: Wisconsin, USA
Re: [Solved] Trend line
If we aren't sure how LINEST does its calculations we can use the actual least squares formulas for Slope and InterceptIn Calc terms the slope is COVAR(x;y)/VARP(x) and the intercept is AVERAGE(y)-Slope*AVERAGE(x). These results are the same as the values from LINEST, proving that it uses the least squares method.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.8, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).
AOO 4.1.7 Build 9800, MacOS 13.7.8, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).