Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: geometric means


From   Abu Camara <abucamara@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: geometric means
Date   Wed, 12 Jun 2013 18:21:59 +0300

Hi Nick,

This is very helpful.

On 12 June 2013 10:34, Nick Cox <njcoxstata@gmail.com> wrote:
> There's an -egen- function -gmean()- in -egenmore- (SSC), but the
> problem  yields also to elementary mathematics and official Stata:
>
> sysuse auto
> egen gmean = mean(ln(mpg)), by(rep78)
> replace gmean = exp(gmean)
>
> Note that you can't take this further and go
>
> egen gmean2 = exp(mean(ln(mpg))), by(rep78)
>
> because -egen- expects to see an -egen- function on the right-hand
> size and -exp()- is not an -egen- function. Why then is the first code
> OK? Because the -egen- function -mean()- can work on an expression and
> a call to a Stata function is fine.
>
> The overloading of the word "function" needs a little care here.
> -egen- functions are those documented under -egen-. Stata functions
> are documented under -functions-. There is sometimes scope to use
> Stata functions _inside_ calls to -egen- functions, as here. -egen-
> functions cannot be used outside -egen- in any circumstances.
>
> Nick
> njcoxstata@gmail.com
>
>
> On 11 June 2013 12:42, Nick Cox <njcoxstata@gmail.com> wrote:
>> Check out -egen-.
>>
>> Nick
>>
>>
>> On 11 Jun 2013, at 10:35, Abu Camara <abucamara@gmail.com> wrote:
>>
>>> Hi Stata list,
>>>
>>> I want to compute geometric means by year (time series)  for a list of
>>> countries with Stata's "ameans" command.
>>> BY and OVER are not supported by ameans.
> *
> *   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/



-- 
Best Wishes,
Abu Camara
*
*   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index