Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Hi,
I'm trying to write a custom function to calculate gini coefficients. I've been able to use this function when inputted manually: (Where X is a range) =SUM(ABS(X-TRANSPOSE(X)))/(2*AVERAGE(X)*((COUNT(X))*(COUNT(X)))) ....entered as an array function. What I am interested in creating is a custom function in Visual Basic. So far, I've gotten this far: Function GiniCalculator(Range) GiniCalculator = WorksheetFunction.Sum(Math.Abs(Range - WorksheetFunction.Transpose(Range))) / (2 * WorksheetFunction.Average(Range) * ((WorksheetFunction.Count(Range)) * (WorksheetFunction.Count(Range)))) End Function But when I use this function, I just arrive at the #VALUE! error message. I'm not sure why, but it might has something to do with the fact the above function is an array function. Does anybody have any thoughts on how to write a custom function for gini coefficients so it is not necessary to manually input the array address each time? |
#2
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]() |
#3
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Harlan,
Your code is very helpful. Thanks! I have noticed one thing though. In order for the calculation to be accurate, there cannot be any missing data in the array. At first I thought that maybe the functions are treating the missing values as zeros, but they are not. The effect of the missing values on the gini coefficient is less than zero. Is there something that can be added to function to have it ignore missing values? John |
#4
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]() |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
IS THERE AN INTERPOLATION FUNCTION IN EXCEL 2003 | Excel Worksheet Functions | |||
Excel 2003 Slow Function Argument Window | Excel Discussion (Misc queries) | |||
Excel option to store trendline's coefficients in cells for use | Charts and Charting in Excel | |||
Creating custom colours in Excel 2002 | Excel Discussion (Misc queries) | |||
HOW CAN I GET OFFICE 2003 EXCEL BASIC TO NEST FUNCTIONS LIKE EXCE. | Excel Worksheet Functions |