#1   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 1
Default weighted trendline

Can anyone tell me if it possible to weight a linear trendline in excel?
Like a calibration line where you can weight by 1/x where x is the variance
at each point on the line.
  #2   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 3,346
Default weighted trendline

Hi,

I don't believe that can be done with anything built into the trendline
chart feature, but you can use the trendline formula in the spreadsheet and
then apply your weighting to it. Then plot that rather than the built-in
trendline. You can get the formula of the trendline from the chart by
choosing to display it or in the spreadsheet by using the LINEST function or
the related SLOPE and INTERCEPT functions.

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"Always need excel help" wrote:

Can anyone tell me if it possible to weight a linear trendline in excel?
Like a calibration line where you can weight by 1/x where x is the variance
at each point on the line.

  #3   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 1
Default weighted trendline

Hi,

Many thanks for your quick reply but want to make sure I am going to do this
correcly.
I know how to get the trendline formula. ok there.
The weighting factor will be different for each point on the line and I
guess I can calculate them x(trendline)=y-c/m from the trendline and my
weight for each point will be w = 1/ (x(trendline) - x(measured)) ie. inverse
of the variance at each point. But how do I apply it back to the trendline
to plot this new weighted line? Just multiply my measured x values by w in a
new column and plot these?

I am basically trying to remove heteroscedasticity (increasing variance)
across my regression line.
Thanks for any further help you can give.

"Shane Devenshire" wrote:

Hi,

I don't believe that can be done with anything built into the trendline
chart feature, but you can use the trendline formula in the spreadsheet and
then apply your weighting to it. Then plot that rather than the built-in
trendline. You can get the formula of the trendline from the chart by
choosing to display it or in the spreadsheet by using the LINEST function or
the related SLOPE and INTERCEPT functions.

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"Always need excel help" wrote:

Can anyone tell me if it possible to weight a linear trendline in excel?
Like a calibration line where you can weight by 1/x where x is the variance
at each point on the line.

  #4   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 120
Default weighted trendline

Somebody else's plume from my notepad that follows Bernard's advice, still it
should serve:

Function WLR(YRange As Range, XRange As Range, WeightRange As Range)
'calculates the weighted linear regression - returns an array {a,b}
{slope,intercept}
'by Adam Slim

Dim SigmaW As Double, SigmaWX As Double, SigmaWX2 As Double
Dim SigmaWY As Double, SigmaWXY As Double
Dim i As Long, outWLR(1 To 2) As Double

'validate ranges
If XRange.Count < YRange.Count Or XRange.Count < WeightRange.Count Then
'fails - the ranges must be the same size
WLR = CVErr(xlErrRef)
Exit Function
End If

'calculate the sigmas
For i = 1 To XRange.Count
SigmaW = SigmaW + WeightRange.Cells(i).Value
SigmaWX = SigmaWX + WeightRange.Cells(i).Value * XRange.Cells(i).Value
SigmaWX2 = SigmaWX2 + WeightRange.Cells(i).Value * XRange.Cells(i).Value ^ 2
SigmaWY = SigmaWY + WeightRange.Cells(i).Value * YRange.Cells(i).Value
SigmaWXY = SigmaWXY + WeightRange.Cells(i).Value * XRange.Cells(i).Value *
YRange.Cells(i).Value
Next i

'calculate the outputs
outWLR(1) = (SigmaWX2 * SigmaWY - SigmaWX * SigmaWXY) / (SigmaW * SigmaWX2 -
SigmaWX ^ 2)
outWLR(2) = (SigmaW * SigmaWXY - SigmaWX * SigmaWY) / (SigmaW * SigmaWX2 -
SigmaWX ^ 2)
WLR = outWLR
End Function
--
Petr Bezucha


"Always need excel help" wrote:

Hi,

Many thanks for your quick reply but want to make sure I am going to do this
correcly.
I know how to get the trendline formula. ok there.
The weighting factor will be different for each point on the line and I
guess I can calculate them x(trendline)=y-c/m from the trendline and my
weight for each point will be w = 1/ (x(trendline) - x(measured)) ie. inverse
of the variance at each point. But how do I apply it back to the trendline
to plot this new weighted line? Just multiply my measured x values by w in a
new column and plot these?

I am basically trying to remove heteroscedasticity (increasing variance)
across my regression line.
Thanks for any further help you can give.

"Shane Devenshire" wrote:

Hi,

I don't believe that can be done with anything built into the trendline
chart feature, but you can use the trendline formula in the spreadsheet and
then apply your weighting to it. Then plot that rather than the built-in
trendline. You can get the formula of the trendline from the chart by
choosing to display it or in the spreadsheet by using the LINEST function or
the related SLOPE and INTERCEPT functions.

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"Always need excel help" wrote:

Can anyone tell me if it possible to weight a linear trendline in excel?
Like a calibration line where you can weight by 1/x where x is the variance
at each point on the line.

  #5   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 1,104
Default weighted trendline

Can you scan a page or two of a textbook that explains this weighting
(hopefully with example) and send files to my private email (remove
TRUENORTH. or visit website to get my real email address)
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email


"Always need excel help" <Always need excel
wrote in message ...
Can anyone tell me if it possible to weight a linear trendline in excel?
Like a calibration line where you can weight by 1/x where x is the
variance
at each point on the line.





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
weighted average elaine9412 Excel Worksheet Functions 6 August 28th 08 07:40 PM
weighted mean kalyan Excel Discussion (Misc queries) 6 July 18th 08 12:29 AM
Weighted Avg Jose Aleman Excel Discussion (Misc queries) 3 May 5th 06 07:54 PM
weighted average inoexcel Excel Discussion (Misc queries) 3 May 1st 06 10:03 PM
Weighted values when one is zero Tom Excel Discussion (Misc queries) 6 February 16th 06 05:51 PM


All times are GMT +1. The time now is 04:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"