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]

From |
Yuval Arbel <yuval.arbel@gmail.com> |

To |
statalist <statalist@hsphsun2.harvard.edu> |

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

Date |
Tue, 11 Dec 2012 09:31:05 +0200 |

Dear Statalisters, 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? -- Dr. Yuval Arbel School of Business Carmel Academic Center 4 Shaar Palmer Street, Haifa 33031, Israel e-mail1: yuval.arbel@carmel.ac.il e-mail2: yuval.arbel@gmail.com * * 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:*Nick Cox <njcoxstata@gmail.com>

- Prev by Date:
**st: Boosted regression** - Next by Date:
**st: Multilevel analysis and clustering in case control study** - Previous by thread:
**st: predict the dummy variable after ordered probit model** - Next by thread:
**Re: st: How to generate an index for the calculation of geometric mean** - Index(es):