Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: How to generate an index for the calculation of geometric mean
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: How to generate an index for the calculation of geometric mean
Date
Tue, 11 Dec 2012 10:03:14 +0000
You are correct; you wrote 2, 3. But why count repeated 25s but not
repeated 1s? There can be no code without a logic to how you are
counting.
Nick
On Tue, Dec 11, 2012 at 9:57 AM, Yuval Arbel <[email protected]> wrote:
> It's not 2.3 but rather t=1 for reduct_per==25, t=2 for
> reduct_per==625, t=3 for reduct_per==15625 etc, so that when I
> calculate 625^(1/2) and 15625^(1/3) I get 25
>
> On Tue, Dec 11, 2012 at 11:46 AM, Nick Cox <[email protected]> wrote:
>> I didn't understand what you want when you asked this yesterday, and
>> the same applies to this repetition. Specifically, where does the 2.3
>> come from? Please show the formula which produces this result.
>>
>> Nick
>>
>> On Tue, Dec 11, 2012 at 7:31 AM, Yuval Arbel <[email protected]> wrote:
>>
>>> I would like to generate an index variable for the calculation of the
>>> geometrical mean of an unbalanced panel (namely, the exponent, which
>>> makes the product a
>>> geometrical mean).
>>>
>>> Here is an example of one panel:
>>>
>>> . list reduct_per y3 if appt==2862
>>>
>>> +---------------------+
>>> | reduct~r y3 |
>>> |---------------------|
>>> 30. | 1 1 |
>>> 31. | 1 1 |
>>> 32. | 1 1 |
>>> 33. | 1 1 |
>>> 34. | 1 1 |
>>> |---------------------|
>>> 35. | 1 1 |
>>> 36. | 1 1 |
>>> 37. | 1 1 |
>>> 38. | 1 1 |
>>> 39. | 1 1 |
>>> |---------------------|
>>> 40. | 1 1 |
>>> 41. | 1 1 |
>>> 42. | 1 1 |
>>> 43. | 1 1 |
>>> 44. | 1 1 |
>>> |---------------------|
>>> 45. | 1 1 |
>>> 46. | 1 1 |
>>> 47. | 1 1 |
>>> 48. | 1 1 |
>>> 49. | 1 1 |
>>> |---------------------|
>>> 50. | 1 1 |
>>> 51. | 1 1 |
>>> 52. | 1 1 |
>>> 53. | 1 1 |
>>> 54. | 1 1 |
>>> |---------------------|
>>> 55. | 25 25 |
>>> 56. | 25 625 |
>>> 57. | 25 15625 |
>>> 58. | 25 390625 |
>>> 59. | 25 9765625 |
>>> |---------------------|
>>> 60. | 25 2.44e+08 |
>>> 61. | 25 6.10e+09 |
>>> 62. | 25 1.53e+11 |
>>> 63. | 25 3.81e+12 |
>>> 64. | 25 9.54e+13 |
>>> |---------------------|
>>> 65. | 25 2.38e+15 |
>>> 66. | 25 5.96e+16 |
>>> +---------------------+
>>>
>>>
>>> The problem is that for reduct_per==1 I would like
>>> the index to become a constant and remain the same until the next
>>> reduct_per, which is different from zero, comes.
>>>
>>> Consider the example above: during the first 26 periods the index
>>> should be one and and starting from the 26th period it should change
>>> to 2,3 etc.
>>>
>>> If, on the other hand, we would have opposite descending trail (namely
>>> 25 percent reduction rate from 1-25 and zero starting from the 26th
>>> period), the index should be 1, 2,..,25 and then becomes a constant 25 from
>>> the 26th period.
>>>
>>> What is the simplest way to generate such an index? Can it be done
>>> without a loop?
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/