Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Nick Cox <njcoxstata@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: How to generate an index for the calculation of geometric mean |

Date |
Tue, 11 Dec 2012 09:46:45 +0000 |

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 <yuval.arbel@gmail.com> 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/

**Follow-Ups**:**Re: st: How to generate an index for the calculation of geometric mean***From:*Yuval Arbel <yuval.arbel@gmail.com>

**References**:**st: How to generate an index for the calculation of geometric mean***From:*Yuval Arbel <yuval.arbel@gmail.com>

- Prev by Date:
**Re: st: Creating a local macro** - Next by Date:
**Re: st: How to generate an index for the calculation of geometric mean** - Previous by thread:
**st: How to generate an index for the calculation of geometric mean** - Next by thread:
**Re: st: How to generate an index for the calculation of geometric mean** - Index(es):