Confidence Interval Trendline

fishme147

New Member
Joined
Jul 28, 2015
Messages
1
Hi All. New to the forum, so please be gentle.

I have a bubble chart that I have a weighted trendline on. I'm not happy with how the line of best fit gives a misleading representation of the predictability of the data, hence I would like to replace this single line with a band of possible trendlines instead. (Essentially an x% confidence interval range, where x is unlikely to be greater than 80).

I appreciate that there is no one perfect answer to this problem, so I am simply looking for the best possible solution (if it exists!)

First thing to master is the mathematics behind the problem. Then I will aim to code up something in VBA (of which, my experience is limited, so any help here would be appreciated too!).

My first approach to this involved splitting up the data points into thin vertical bands (about 30 of them) and calculating the weighted standard deviation for each band, and by assuming a normal distribution of the spread within each band calculate an upper band and lower band. Then I fit a trendline to the set of upper bands and also one to the set of lower bands. Where this falls over slightly is in the bands (in the extremes where data becomes sparse) that have less than two data points in, as the variance cannot be calculated. The result (possibly influenced by this data sparsity) was that the two curves were different shapes and almost crossed at the extreme right of the chart. I feel like the lack of data in the tails should increase the distance between the lines.
I also pondered to what extent each band's spread should be influenced by it's neighbouring band's spread, but I can't work out a way to incorporate this.

The chart that I have been testing on has around 500 data points. However, I hope to repeat this process for many different bubble charts, with varying numbers of data points.

Any thoughts?

Many thanks
:)
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Hi, If you're just interested in the mathematics, I hope the following is helpful.
A3:B12 are Fertiliser amounts and Crop yields.
If you set up an X Y scatter plot with straight lines using A21:B25 that will give you a regression line for the data.
If you add the Lower and Upper 90% Confidence Levels in D21:D25 and E21:25 respectively you will find that they form curves that diverge from the regression line as you have indicated you would expect to see Quote <<I feel like the lack of data in the tails should increase the distance between the lines>>
The value of 1.86 that prefixes the formulae in C21:C25 is Student's t critical point for n - 2 = 8 degrees of freedom.


Excel 2007
ABCDEFGHI
114740180611
2YXX^2X*Y
3122424
4132426
5133939
6143942
71541660
81541660
91452570
101652580
1117636102
1218636108
13
14Sxx20
15Sxy23
16Mean X4
17n X10
18
19
20XYLower Confidence IntervalUpper Confidence Interval
21212.400.8611.5413.26
22313.550.6112.9414.16
23414.700.4914.2115.19
24515.850.6115.2416.46
25617.000.8616.1417.86
26
27SUMMARY OUTPUT
28
29Regression Statistics
30Multiple R0.907738
31R Square0.823988
32Adjusted R Square0.801986
33Standard Error0.840387
34Observations10
35
36ANOVA
37dfSSMSFSignificance F
38Regression126.4526.4537.45132740.000283
39Residual85.650.70625
40Total932.1
41
42CoefficientsStandard Errort StatP-valueLower 95%Upper 95%Lower 90.0%Upper 90.0%
43Intercept10.10.79726112.66837441.417E-068.26151211.93848828.6174547711.58255
44X1.150.1879166.119748970.000283250.7166641.583335830.800560741.499439
Sheet1
Cell Formulas
RangeFormula
A1=SUM(A3:A12)
B1=SUM(B3:B12)
B14=C1-B1^2/B17
B15=D1-(B1*A1/B17)
B16=AVERAGE(B3:B12)
B17=COUNT(A3:A12)
B21=B43+B44*A21
B22=B43+B44*A22
B23=B43+B44*A23
B24=B43+B44*A24
B25=B43+B44*A25
C1=SUM(C3:C12)
C3=B3*B3
C4=B4*B4
C5=B5*B5
C6=B6*B6
C7=B7*B7
C8=B8*B8
C9=B9*B9
C10=B10*B10
C11=B11*B11
C12=B12*B12
C21=1.86*B33*SQRT(1/B17+(A21-B16)^2/B14)
C22=1.86*B33*SQRT(1/B17+(A22-B16)^2/B14)
C23=1.86*B33*SQRT(1/B17+(A23-B16)^2/B14)
C24=1.86*B33*SQRT(1/B17+(A24-B16)^2/B14)
C25=1.86*B33*SQRT(1/B17+(A25-B16)^2/B14)
D1=SUM(D3:D12)
D3=A3*B3
D4=A4*B4
D5=A5*B5
D6=A6*B6
D7=A7*B7
D8=A8*B8
D9=A9*B9
D10=A10*B10
D11=A11*B11
D12=A12*B12
D21=B21-C21
D22=B22-C22
D23=B23-C23
D24=B24-C24
D25=B25-C25
E21=B21+C21
E22=B22+C22
E23=B23+C23
E24=B24+C24
E25=B25+C25
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,428
Members
448,961
Latest member
nzskater

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