[R] OT: computing percentage changes with negative and zero values?

Jim Lemon jim at bitwrit.com.au
Wed Feb 17 12:13:42 CET 2010


On 02/17/2010 04:06 AM, Liviu Andronic wrote:
> Dear all
> I need to compute percentage changes of my data, but unfortunately
> they contain both negative and zero values, and I am quite confused on
> how to proceed. Searching the internet I found that many people ran
> into similar issues, with no obvious solution available.
> ...
> As you have noticed, I'm quite unsure on how to proceed. My actual
> data represents financial EPS (earnings per share) forecasts, ranging
> from -1 to 5. So, it has a "natural zero point"  (see David Winsemius'
> comments in [2]). However, I need to compute percentage variations
> since I am primarily interested in the evolution of the forecasts (for
> a given company), while EPS data between two companies are not
> necessarily comparable. The percentage data would subsequently be used
> in performing statistical analyses (regression, etc.).
>
Hi Liviu,
My understanding of percentage change is the absolute value of the 
change divided by the absolute value of the initial value and the result 
multiplied by 100. Thus:

100*abs(diff(x$var))/abs(x$var[1:19])
  [1] 283.720930 187.341772  10.144928 100.000000        Inf  52.980132
  [7] 212.676056  46.250000  35.042735   6.329114 223.648649  51.912568
[13] 263.636364 150.000000  69.444444 959.090909 167.195767  40.157480
[19] 275.000000

gives me correct values (and the Inf for the fifth value is correct, as 
the denominator is zero). My definition might not be the only one, though.

Jim



More information about the R-help mailing list