weighting data for TREND line fit


Posted by laura jean on January 29, 2002 7:16 AM

HELP!

Does anybody know how to weight data before fitting
a line to it in Excel??? Say, [1,3,6,2,8] with weights
[2,1,4,1,3] ??? (I'm calculating the principle axis of
an object) Please, please, please! TY ;)

Posted by Mark W. on January 29, 2002 7:36 AM

Not quite sure what your trying to accomplish, but
the array formula...

{=TREND({1,3,6,2,8}*{2,1,4,1,3})}

...produces the trendline for {1,3,6,2,9} weighted
by {2,1,4,1,3} (which is {2,3,24,2,24}).

Posted by Mark W. on January 29, 2002 7:37 AM

FYI...

Array formulas must be entered using the
Control+Shift+Enter key combination. The
outermost braces, {}, are not entered by you --
they're supplied by Excel in recognition of a
properly entered array formula.

Posted by laura jean on January 29, 2002 8:25 AM

my bad...

Mark, THANK YOU for acknowledging my post!
My description of the problem was poor. What
I am trying is more like a weighted average...
a weighted line fit, so that the penalty (diff
between the line and input data in a LSQF) is
weighted, rather than the input data... I am
calculating the principle axis of an object.
y-data are slice centroids, and the weights are
slice areas... make sense? Array formulas must be entered using the

Posted by Mark W. on January 29, 2002 8:35 AM

Sorry, this is a bit like Greek to me...

...care to provide a small amount of sample data
and your desired result? Mark, THANK YOU for acknowledging my post!

Posted by laura jean on January 29, 2002 9:01 AM

with pleasure!

sticking with the original data, I would like
y={1,3,6,2,8}
weights={2,1,4,1,3}

... to produce the trendline for {1,3,6,2,8} weighted by {2,1,4,1,3}
(like this {2,2,3,6,6,6,6,2,8,8,8}).
some of my real weights, however, are non-integer

mo better? :) ...care to provide a small amount of sample data

Posted by laura jean on January 29, 2002 9:11 AM

(typo)

... to produce the trendline for {1,3,6,2,8} weighted by {2,1,4,1,3}
(like this {1,1,3,6,6,6,6,2,8,8,8}). ...care to provide a small amount of sample data

Posted by Mark W. on January 29, 2002 9:35 AM

Re: with pleasure!

This is a problem begging for a user-defined function
(UDF) because Excel built-in functions don't
provide a way to lengthen an array as an operation.

The array formula, {=REPT({1,2,6,2,8},{2,1,4,1,3})},
could be used to create the array...

{"11","2","6666","2","888"} in cells A1:E1.

Then, the formula, =CONCATENATE(A1,B1,C1,D1,E1),
in cell F1 could be used to produce "11266662888".

Finally, the array formula...

{=MID(F1,COLUMN(INDIRECT("1:"&LEN(F1))),1)+0}

...could be used to produce...

{1,1,2,6,6,6,6,2,8,8} in cells A2:J2, but...

It's still not clear to me what these values
mean, how you want them graphed, or how to
contend with non-integer weights.

Note: Array formulas must be entered using the
Control+Shift+Enter key combination. The
outermost braces, {}, are not entered by you --
they're supplied by Excel in recognition of a
properly entered array formula.

Posted by laura jean on January 29, 2002 10:00 AM

Re: with pleasure!

that's cool! and you have demonstrated that you
know 5x more about excell than I do, so please
bear with me!

what these values mean:
I am calculating the axis about which an object
would spin (like a top). I've sliced the object
(x index) and calculated the position of the
center of mass for each slice (y values) and
the area of each slice (weights).

how you want them graphed:
I really only want the line equation, but so far
have made a scatter plot and added a trendline
(simulating weighting effect by replicating data
points)

how to contend with non-integer weights:
THAT's the problem! most of my weights are not
integers. I replicated data points in order to
demonstrate what the weights mean. Ideally, I'd
like to just associate the weights with the y
values and avoid lengthening my arrays. This is a problem begging for a user-defined function



Posted by laura jean on January 30, 2002 8:16 AM

I have a MUCH better way to approach this in Excel! Is there a way for Excel to take measurement erorr into account when fitting a line to a set of data??? In another, similar application, data points are weighted by the inverse square of the measurement error. Is there a similar option in Excel? (I haven't found it in LINEST or TREND) Not quite sure what your trying to accomplish, but