Other lines parallel to a Best fit line on a scatter graph?
Can you put Lines of equal gradient to the best fit line on a scatter graph going through to points furthest above and below the best fit line?
Simplified a bit so I am not so ashamed
I2=SLOPE(C2:C9,B2:B9)
I3=INTERCEPT(C2:C9,B2:B9)
Y Linear (column D) =$I$3+B2×$I$2
Y - YLinear (column G) is what it says
Max Line (column E) = $D2+MAX(G)
Min Line (column F) = =$D2+MIN(G)
You have to format the "trend" lines with connecting lines and no data symbol
Similar Messages
-
Add a trend line to a scatter graph
for my physics work i had to plot a graph and i need to add a trendline to the graph. I have plotted the graph as a scatter chart but dont know how to add a line of best fit, please help
Search "linear regression' in Numbers Help.
The FORECAST() function can be used to calculate the end points for the trend line using the minimum and maximum X values in your data set for the x value argument.
For example, with your data pairs listed in B3:B12 (x values) and C3:C12 (y values), add these values and formulas:
D3: 0
E3: =FORECAST(D3, C3:C$12, B3:B12)
D4: =MAX(B3:B12)
E4: =FORECAST(D4, C3:C$12, B3:B12)
The data pair on row 3 mark the y axis intercept of the trend line.
The pair on line 4 mark the position of the trend line where its x value is equal to the maximum x value of the data set. As plotting this pair may obscure the data point at this x value, you may want to move the trend line point to the right. To do this, add an arbitrary amount to the value in D4. The size of the added amount will depend on the scale of your graph.
eg. D4: =MAX(B3:B12)+2
If your data set includes negative x values, replace the formula in D3 with the mirror of the one in D4:
D3: =MIN(B3:B12)-2
Again, the "-2" is an arbitrary value used to extend the trend line beyond the collected x values.
This will allow you to plot these two points onto your scatter graph as a second data set. I don't see a means of making Numbers connect the points, so you will have to add the line manually.
Regards,
Barry -
How do i generate the formula line for a scatter graph?
While using Numbers_08 to create a scatter graph, I am able to easily create the graph, but cannot generate the graph formula line (the line which shows the average of the points for the graph).
Is there a way to do this, as with Excel and Quattro Pro?I have just found out from the Archives, it is not possible to generate a formula line (trend line) in Numbers_08.
I am currently upgrading to Numbers_09. -
How is a line of best fit created from a scatter graph in NUMBERS. There is a function called SLOPE which seems to do this but no information on how to use it!
no information on how to use it!
you can tap the blue arrow next to the function name for a small guide on how to use the function
You can tap on the name of the function two times (pause in between) and the same dialog appears above it
There is an entire manual dedicated to the functions used in Numbers.
As almost all of these functions are identical between spreadsheets many examples can be found on the internet but for the other programs (XL for example). Just remember that Array formulas (ones that require Ctrl-Shift-Enter in XL) dont exist in Numbers. You would use the Index function to wrap those functions that require CSE XL functions, as described in the help file for LINEST.
You might also look at LINEST as well if your working with lines of best fit.
Jason -
How do i find where 2 best fit lines cross?
Hi
I was wondering if anyone knows a way to find where 2 best fit lines cross, I don't have the equation for the lines and i'm not sure if I can get it.
I currently have the program tracing the lines and comparing y values however it will only increment in steps of 0.1 on the x-axis and i need an accuraccy of 0.0001If you have or can get a series of XY value pairs for both of the lines, getting the equation of the line is as simple as calling Linear Fit.vi. Once you have the equations of both lines, the intersection is simple algebra, subject to the accuracy of your fit. If the XY data pairs describe a curve, not a line, and you want more accuracy, you can try a polynomial fit using General Polynomial Fit.vi. To find the intersection, set one polynomial equation equal to the other, compute the coefficients of the resulting polynomial equation, and find the root using Polynomial Roots.vi. All this assumes you have a Pro or better version of LabVIEW. If you don't, you can still do it, but you will need to write some code for the fits and roots. Check out a copy of Numerical Recipes in C, by Press et. al. from your local library and it will give you the equations for all the above. With LabVIEW's native matrix handling capabilities, the rest is straighforward.
Let us know if you need more help.
This account is no longer active. Contact ShadesOfGray for current posts and information. -
How to Make a Line of Best Fit/Best Fit Line/Trendline in iWork Numbers '09
I'm not sure if this is well-known or has been answered elsewhere already, but multiple Google searches have not shown this solution on how to create a line of best fit in Numbers '09 (there is another method that involves drawing a line yourself, but this is much easier and more accurate).
I stumbled across this trying the above self-draw technique and got so excited I wanted to post the technique. So here is what you do:
1) Type out your X and Y data
2) Select the data and select Charts, then select the Scatter Plot
3) Open up Inspector and select the Chart tab
4) Select the "Series" tab below the picture of the Scatter Plot and the "Chart Colors..." button
5) At the bottom of the Inspector window, open the "Advanced" arrow
6) Select the "Trendline" tab and select the "Linear" trendline from the drop-down bar
That's it! You can even select the options to show the line equation or the R-squared value!
Here is a picture of the selected options and what your graph should look like (check that nice R-squared value!).
http://i.imgur.com/AvfPv.png
I hope this helps and hope it moves up to the top of the Google search page for this feature.Hi Asclepius37,
Why not just search "trend" or "trendline" in the Numbers '09 User Guide?
That would take you to page 149 of the guide and the article "Showing Trendlines in Charts," which lists a set of instructions very similar to those in your post.
The Numbers '09 User Guide and the iWork Formulas and Functions User Guide are searchable pdf files, and may both be downloaded through kinks in the Help menu in Numbers. Both are excellent resources to have on hand.
Regards,
Barry
PS: Searching "best fit" will return zero results, but "best" or "best-fit" will get you to the same article.
B -
regarding a graph made from spreadsheet data...
how do i make a best fit line to a set of points?
also, is there a way to find the slope and intercept of this line?
Thank you!Hello
The named functions are not available in AppleWorks.
One way to mimic them is to use AppleScripts .
Here is an old one which calculate the slope.
--{SCRIPT}
tell application "AppleWorks 6"
activate
tell front document
set laSelection to get object specifier of the selection
set debutCible to name of first cell of laSelection
-- nom de la première cellule cible
-- • name of first dest cell
set premColonne to item 1 of (index of first column of laSelection) as list
set premRangee to item 1 of (index of first row of laSelection) as list
set dernColonne to item 1 of (index of last column of laSelection) as list
set dernRangee to item 1 of (index of last row of laSelection) as list
set nb_Rangees to dernRangee - premRangee + 1
if not (dernColonne - premColonne) = 1 then error 8088
set cell11 to name of row premRangee of column premColonne
set cell12 to name of row dernRangee of column premColonne
set cell21 to name of row premRangee of column dernColonne
set cell22 to name of row dernRangee of column dernColonne
set vX to get select (cells cell11 thru cell12)
set the clipboard to vX
set vY to get select (cells cell21 thru cell22)
set nb to count of vX
set {X, Y, XY, x2} to {0, 0, 0, 0}
repeat with i from 1 to nb
set xi to vX's item i
set yi to vY's item i
set X to X + xi
set Y to Y + yi
set XY to XY + (xi * yi)
set x2 to x2 + (xi * xi)
end repeat
set slope to (XY - (X * Y) / nb) / (x2 - (X * X) / nb)
select menu item 4 of menu 3 (* copier *)
set slope to my calcule(nb_Rangees)
display dialog "" & slope
end tell
end tell
on calcule(nb_)
tell application "AppleWorks 6"
activate
set AWversion to (version as text)
select menu item 2 of menu item 1 of menu 2 (* Nouveau tableur
• New spreadsheet *)
tell front document
select cell "A1"
select menu item 5 of menu 3 (* Colle • Paste *)
set formula of cell "C1" to "=A1*B1"
set formula of cell "D1" to "=A1^2"
select cell ("C1..D" & nb_)
select menu item 3 of menu 5 (* Recopier vers le bas
• Fill down *)
if AWversion starts with "FU1-" then
set formula of cell "E1" to "=(SOMME(C1..C" & nb_ & ")-SOMME(A1..A" & nb_ & ")*SOMME(B1..B" & nb_ & ")/NOMBRE(A1..A" & nb_ & "))/(SOMME(D1..D" & nb_ & ")-SOMME(A1..A" & nb_ & ")^2/NOMBRE(A1..A" & nb_ & "))"
else
set formula of cell "E1" to "=(SUM(C1..C" & nb_ & ")-SUM(A1..A" & nb_ & ")*SUM(B1..B" & nb_ & ")/count(A1..A" & nb_ & "))/(SUM(D1..D" & nb_ & ")-SUM(A1..A" & nb_ & ")^2/count(A1..A" & nb_ & "))"
end if
set slope_ to cell "E1"
end tell
close document 1 without saving
end tell
return {slope_}
end calcule
--{/SCRIPT}
Yvan KOENIG (from FRANCE mercredi 1 août 2007 06:51:46)
edit:
When I edit my message, the script appears but when I look in the forum it doesn't appear.
It appears that it is a recent "feature" of this forum;
I made a last attempt.
If it doesn't work, you may send a mail to
koenig then a dot then yvan then an @ then tele2 then a dot then fr
I will send you the script as a mail attachment.
Yvan KOENIG (from FRANCE mercredi 1 août 2007 07:07:17)
Message was edited by: KOENIG Yvan -
How do I make a best fit line on a scatter plot?
I have a set of data and I made a scatter plot on numbers, but how do I put a best fit line in there?
select the graph, then open the Charts Inspector.
Open the series section (from the options at the top "Chart", "Axis", "Series"), Then select the "Trendline" in the "Advanced" section near the bottom. Finally select the type of trendline -
Help with Line of Best Fit equation!
Alright, I'm making a graphing program where the user can input up to 10 coordinates (all ints) and when they click draw, the points will be graphed on a cartesian plain and the program will calculate and draw the line of best fit... including displaying the equation.
I've got the yIntercept to work perfectly, but sometimes the slope comes out to be 0.0, and such.
The equation to do it can be found on this site (in the big white space)
http://people.hofstra.edu/faculty/Stefan_Waner/RealWorld/calctopic1/regression.html
There are several things you must do first:
- Find the sum of all the X values
- Find the sum of all the Y values
- Find the sum of all the X*Y values
- Find the sum of all the X^2 values
You then stick it into the equation (you can see on that site) and you will get the slope. You then take the slope value and insert it into another equation to get the y-intercept
I was just wondering if you could just look over my calculation and see where I may be going wrong. (Sometimes, I get an error in the console saying I cannot divide by 0)
public void lineOfBestFit(int numOfPoints, int largeNumX, float increment, float incrementY)
Graphics g = canvas.getGraphics();
float sumX = 0;
float sumY = 0;
float sumXY = 0;
float sumXSqr = 0;
int smallNumX=9999999;
int firstPoint, lastPoint;
//Creates the variables for the line of best fit equation
for(int j=0;j<numOfPoints;j++)
sumX+=xValue[j];
sumY+=yValue[j];
sumXY+=(xValue[j]*yValue[j]);
sumXSqr+=(Math.pow(xValue[j],2));
//Line of best fit equation
float slope = ((numOfPoints*sumXY)-(sumX*sumY))/((numOfPoints*sumXSqr)-(sumX*sumX));
float yInt = (sumY - (slope*sumX))/numOfPoints;
for(int j=0;j<numOfPoints;j++)
if(xValue[j]<smallNumX)
smallNumX=xValue[j];
firstPoint=((int)((slope*smallNumX)+yInt)*50/(int)incrementY+210);
lastPoint=((int)(slope*largeNumX+yInt)*50/(int)incrementY+210);
int firstX=((int)(smallNumX*50/(int)increment+210));
int lastX=((int)(largeNumX*50/(int)increment+210));
g.drawLine(firstX,firstPoint,lastX,lastPoint);
//Rounds and displays the line of best fit equation
slope = (Math.round(slope*100))/100;
yInt = (Math.round(yInt*100))/100;
if(numOfPoints>1)
if(yInt < 0)
g.drawString("y = " +slope+ "x " +yInt,250,350);
else
g.drawString("y = " +slope+ "x +" +yInt,250,350);I think I may have solved it.... seems to be working now.
I casted all the numOfPoints as (float) .... and commented out the rounding. Since some of the slopes were coming out to be 0.00003, that would display 0.0 if I rounded. -
Extrapolation and Line of Best Fit
Hello,
I'm working on a project and I need to make a line of best fit for a scatter plot graph as well as make an extrapolation on the graph...any possibility someone could help me with these two questions?
Thank you,
MikeMike,
Numbers 08 have functions that you can use to calculate your lines of best fit, then chart the line calculations along with your data.
See INTERCEPT and SLOPE for 1st order lines.
Numbers 09 added quite a few new functions and also automatic Trendline generation.
Jerry -
How to I insert a line of best fit on a scatter plot????
I have data already organized in tables, and I created a scatter plot. NOw I need to insert a line of best fit and get the equation. How do I do this??? I already calculated a and b (for y=a+bx) but I have no idea how to insert it on the plot. Every search tells me to "insert a trendline"..... but numbers doesnt have that function. Help please???
Open inspector
Go to chart tab
Series
Click on the "Advanced" to reveal the menu
Trendline
Choose the desired trendline (linear etc)
Hope this helps.
Dimitris -
How do I do a line of best fit graph!!?
Hi guys, I need to do a line of best fit graph comparing two sets of numbers. I have the info on a scatter graph but can not find how to insert a line of best fit. The other graph options dont represent the data correctly. any help would be appreciated, thanks, Nick.
Here's a link to how we did it in the "old days":
http://www.regentsprep.org/Regents/math/data/linefit.htm
http://mathdemos.gcsu.edu/mathdemos/lsq-demonew/indexnew.html
Regards, -
Line of best fit and reverse axis
Hi, How do i do a line of best fit in Numbers? Instead of having a line like do to dot i need it to be smooth, Excel does it but does Numbers?
I also need the bottom axis to start at 10 and go down to 0 and i need the left axis to be on the right! How do i do this?
thanks a lotHello
*go to "Provide Numbers Feedback" in the "Numbers" menu*, describe what you wish.
Then, cross your fingers, and wait at least for iWork'09
Yvan KOENIG (from FRANCE lundi 4 février 2008 13:36:58) -
Line of Best Fit / Linear Regression
I am trying ot get a line of best fit for a set of data in oracle
Lets say i have the following dataset.
Since there are a lot of 0 in the Terms I would like to ignore those Terms
Only use the Terms which have values to get a line of best fit.
Any help will be appreciated.
Thank you.
TERMS Count
TERM_0801 78
TERM_0802 58
TERM_0803 0
TERM_0804 82
TERM_0805 0
TERM_0806 0
TERM_0807 32
TERM_0808 0
TERM_0901 92
TERM_0902 0
TERM_0903 0
TERM_0904 56
TERM_0905 0
TERM_0906 0
TERM_0907 0
TERM_0908 0
TERM_1001 85
TERM_1002 0
TERM_1003 0
TERM_1004 67
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
Edited by: Chloe_19 on Jul 24, 2012 11:14 PMArgh, i wonder about the values i got, different from what excel says ;-), till you came up with your solution.
They changed the order of the paramters from that what i consider as common:
"expr1 is interpreted as a value of the dependent variable (a y value), and expr2 is interpreted as a value of the independent variable (an x value)."
Do they also have left-hand traffic in the new world?
However, didnt OP wanted to have the zeros eliminated before the calculus?
with data as
select 'TERM_0801' t, 78 y from dual union all
select 'TERM_0802', 58 from dual union all
select 'TERM_0803', 0 from dual union all
select 'TERM_0804', 82 from dual union all
select 'TERM_0805', 0 from dual union all
select 'TERM_0806', 0 from dual union all
select 'TERM_0807', 32 from dual union all
select 'TERM_0808', 0 from dual union all
select 'TERM_0901', 92 from dual union all
select 'TERM_0902', 0 from dual union all
select 'TERM_0903', 0 from dual union all
select 'TERM_0904', 56 from dual union all
select 'TERM_0905', 0 from dual union all
select 'TERM_0906', 0 from dual union all
select 'TERM_0907', 0 from dual union all
select 'TERM_0908', 0 from dual union all
select 'TERM_1001', 85 from dual union all
select 'TERM_1002', 0 from dual union all
select 'TERM_1003', 0 from dual union all
select 'TERM_1004', 67 from dual
select
round(regr_slope(y,x), 4) slope
,round(regr_intercept (y, x) , 4) intercept
,round(regr_r2(y,x), 4) best_fit
from (
select
row_number() over ( order by t ) x, y
from data
where
y!=0
SLOPE INTERCEPT BEST_FIT
.4762 66.6071 .0035 regards
Edited by: chris227 on 25.07.2012 04:58
Edited by: chris227 on 25.07.2012 05:10
best fit added -
Line of best fit in scatter plots
when making a line of best fit ( in this case a curve of best fit) how do I extend the curve beyond my data so that I can extrapolate information? Can I do this or will I have to do it manually? (print it out and draw it myself)
If you graph your data you can allow Numbers to plot a best fit AND show the equation it used (which will depend on the type of fit you selected).
Here I plotted some data where I introduced random noise (so it won't be "perfect") then had Numbers provide the best fit.:
The bluse graph is the original data. The Green is a prediction based on the coefficients from Numbers.
Once you graph the original data click on the graph, and then click a second time on one of the points in the graph to highlight the series:
Once you have the series highlighted you can use the Chart Inspector to turn on the Trendline.
I selected Polynomial because (1) It fit best and (2) the equation I used to make my made-up data was actually a polynomial. Check the "Show Equation" box to see the coefficients. Now take these coefficients and place then in cells of your table that has the original data (or some other table).
Now add a new column to your data (I called mine Ypredicated or Yextrapolated):
Now add a fomula to use the coefficients which will produce a 2nd graph you may extend beyond the data set:
C2=$E$6*A2*A2+$E$7*A2+$E$8
select C2 and fill down as needed (make sure the references to the coefficients are absolute... hence the "$" before the cell row and column names in the formula)
Finally add the extrapolated curve to your graph to see if it fits:
click on the graph
1) click the little cog at the top of the X column and select "Share X values"
<can't include screen shot right now... not sure why>
2) then expand the graph data set by clicking and holding the little circle at the bottom right of the highlighted area, and drag to the right so the new predicted column is included.
<can't include screen shot right now... not sure why>
Maybe you are looking for
-
All of my plug ins are erased?
hey there....i have logic express 9....on a macbook....my interface is an m-audio fast track pro....i went to play a song i was working on and i couldn't hear anything...then i noticed all of the plug in indicators on each channel had a slash through
-
Netflix, Safari, Silverlight crashing on "Add to Your List"
I use Safari 6.0.3 on OS X 10.8.2 on a mid-2009 MBP. When adding movies + tvseries to Netflix's List (using the "Add to Your List"-button), I have experienced 3 kernel panics. Anyone have any suggestions as to what to do? Most of the time the reactio
-
I am finding copying audiobooks to iTunes and then into my iPod to be rather confusing and not terribly intuitive. I am trying to copy audiobooks borrowed from the library to iTunes and then to my iPod for listening to on long drives cross country. I
-
Connection between SD and FSCM credit management
Hi expert, Right now, i used SAP ERP 6.0 and i want to implement FSCM credit management in the same system. I already done for configuration in SPRO-> Integration with Sales and Distribution implemente
-
Can i replace my 1.5gb hard drive in my Muvo2 with a bigger hard dri
Can?I replace my .5gb hard dri've in my Muvo2 with a bigger hard dri've? My hard dri've is shot, it clicks on startup and goes to recovery mode. None of the options work in recovery mode and it says media error if?I select them. I am wondering is it