LINEST array issues

dpofarre

New Member
Joined
Jan 12, 2003
Messages
37
Okay, here's one I've been trying to work for some time, with LINEST.

Overview:

I have seven numbers in "A" column (x) and seven in "B" (y). In "C", I display a "YES" if the value in "B" is less than or equal to 10, and a "NO" if the value in "B" is greater than 10. This is to attempt to use the linest array to find the slope and y-intercept of the curve fit. The idea is to eliminate the y-values with a "NO" next to them (greater than 10), and the corresponding x-values that make up the curve, and then find slope and intercept. Here is what I have so far:

Code:
{=LINEST(IF(C1:C7="YES",B1:B7,A1:A7))}
I get some values, but they are not the slope and y-intercept of the curve. So I thought another attempt would do it.

Second idea:

I took the "NO" points, which I considered invalid for the curve, and reassigned an #N/A value to the x and y-value for that point. When I chart this data, and highlight all cells, good and bad, the chart is able to throw out the #N/A points, and still produce a curve with a correct trendline, and equation.

I thought this would work for LINEST as well. However, let's say I moved the "redone" points to "D" and "E". Then I just tried LINEST again like so:

Code:
{=LINEST(E1:E7,D1:D7,TRUE,TRUE)}

Now I get #VALUE! for the array, so long as there are any #N/A points in the curve data.

Question:

How in the world do I get Excel to take an x-y data set, thrown out the points with y-values greater than 10, and still give me the correct slope, y-intercept, and correlation coefficient with the remaining "acceptable" points? I can get the chart to understand, but convincing LINEST is quite another issue! Your help is greatly appreciated.

Dustin
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Acivate Insert|Name|Define.
Enter BigNum as name in the Names in Workbook box.
Enter the following big number in the Refers to box:

9.99999999999999E+307

Click OK.

What follows shows a significant use of BigNum...

Formulas...

C2 must house a 0.

C3, which is copied down:

=IF(ISNUMBER(B3)*(B3<=10),LOOKUP(Bignum,$C$2:C2)+1,"")

D2:

=LOOKUP(Bignum,C:C)

D3:

=MATCH(Bignum,E:E)

E3, which is copied across then down:

=IF(ROW()-ROW(E$3)+1<=$D$2,INDEX(A:A,MATCH(ROW()-ROW(E$3)+1,$C:$C,0)),"")

G2:

=LINEST(E3:INDEX(E:E,D3),F3:INDEX(F:F,D3))

H2:

=LINEST(E3:INDEX(E:E,D3),F3:INDEX(F:F,D3),TRUE,TRUE)

which must be confirmed with control+shift+enter after selecting H2:I6.

You can graph the area E:F by first defining a named range that you can feed to Excel's charting component.
 
Upvote 0
Wow, thank you so much Aladin! I thought nobody would answer my question, as it seemed very tricky. However, you definitely came through, and saved me on this one for sure. Thanks again,

Here's an additional question though, which would be a nice thing to have, but not a necessity. How do I get the linest to just display the slope, y-intercept, and correlation coefficient? I don't really need the rest of the info from the array, and I would rather not display it if at all possible. Anybody?

Dustin
 
Upvote 0
dpofarre said:
Wow, thank you so much Aladin! I thought nobody would answer my question, as it seemed very tricky. However, you definitely came through, and saved me on this one for sure. Thanks again,

Here's an additional question though, which would be a nice thing to have, but not a necessity. How do I get the linest to just display the slope, y-intercept, and correlation coefficient? I don't really need the rest of the info from the array, and I would rather not display it if at all possible. Anybody?

Dustin
aaLinestArrayIssues dpofarre.xls
ABCDEFGHIJ
1
2XY04XxYySlope0.7534850.753485
3710.9 665.7Intercept1.4440941.444094
465.716.27.1Correlationcoefficient0.88906
5312 88.3
66.27.126.97.2
788.33  
86.97.24  
9
Sheet2


Formulas for slope, intercept, & correlation coefficient:

I2 (slope)...

=SLOPE(E3:INDEX(E:E,D3),F3:INDEX(F:F,D3))

J2 (slope, alternative using LINEST)...

=INDEX(LINEST(E3:INDEX(E:E,D3),F3:INDEX(F:F,D3)),1)

I3 (intercept)

=INTERCEPT(E3:INDEX(E:E,D3),F3:INDEX(F:F,D3))

J3 (intercept, alternative using LINEST)

=INDEX(LINEST(E3:INDEX(E:E,D3),F3:INDEX(F:F,D3)),2)

I4 (correlation coefficient)

=CORREL(E3:INDEX(E:E,D3),F3:INDEX(F:F,D3))
 
Upvote 0
Perfect! Once again Aladin, you have saved the day. I forgot about the slope, intercept, and correlation functions. I'm glad there's others out there who have the capability of remembering all of this stuff! Thanks,

Dustin
 
Upvote 0
LINEST array issues (changing input scatter size)

Here is what I have a series x and y which is somtimes 10 rows or 20 or any other number of rows long. I then want to use LINEST to get the polynomial coefficients. I have it figured out how to get the coefficients if the series is always the same length but the array messes up if I change the length of my series. What should I do for a changing series length?
Thank you! Joe

X y
10400 10370
10477 10462
10568 10548
etc....
 
Upvote 0
Re: LINEST array issues (changing input scatter size)

Runcer said:
Here is what I have a series x and y which is somtimes 10 rows or 20 or any other number of rows long. I then want to use LINEST to get the polynomial coefficients. I have it figured out how to get the coefficients if the series is always the same length but the array messes up if I change the length of my series. What should I do for a changing series length?
Thank you! Joe

X y
10400 10370
10477 10462
10568 10548
etc....

What is the current formula that you use?
 
Upvote 0
Current formula is:

=LINEST(B2:B10,A2:A10^{1,2,3})

problem is that the input changes, currently 10 rows but it could be 20 or even more.
Joe
 
Upvote 0
Runcer said:
Current formula is:

=LINEST(B2:B10,A2:A10^{1,2,3})

problem is that the input changes, currently 10 rows but it could be 20 or even more.
Joe

Did you try the BigNum idea in my reply to the dpofarre query?
 
Upvote 0

Forum statistics

Threads
1,216,165
Messages
6,129,235
Members
449,496
Latest member
Patupaiarehe

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top