Bookmark and Share

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: Re: [question on -gammafit- and -pgamma-]


From   Peter Maclean <[email protected]>
To   [email protected]
Subject   Re: st: Re: [question on -gammafit- and -pgamma-]
Date   Sat, 5 Mar 2011 14:25:59 -0800 (PST)

Thanks Nick.
My question was actually setting up a loop over a group and save the results. 
The number of group (n) is 600.
Hope you can help on that.
Peter Maclean
Department of Economics
UDSM 



----- Original Message ----
From: Nick Cox <[email protected]>
To: [email protected]
Sent: Sat, March 5, 2011 1:16:33 PM
Subject: st: Re: [question on -gammafit- and -pgamma-]

It is always helpful to specify a subject for your email.

This question refers to -gammafit- and -pgamma- from SSC, which are
user-written programs.
Statalist etiquette is to explain where user-written programs referred
to come from.

Peter quotes the syntax

by n:gammafit y, level(95)

which -gammafit- supports. However, as is standard with -by:- support,
this syntax is of limited use for _saving_ results, as after the
first, each invocation of -gammafit- stomps over the previous set of
saved results, so although parameter estimates are displayed in turn,
only the last such set is present in memory once all are done.

Peter correctly reports that -pgamma- does not support the -by()-
option (nor does it support the -by:- prefix).

I am not aware that Stata supports doubly subscripted variables.
Perhaps Peter means a Stata or Mata matrix.

To get results for different groups and put them together, Peter has
to arrange that himself. But this code shows that the steps are
simple.

sysuse auto, clear
matrix results = J(2,2,.)
gammafit mpg if foreign
matrix results[1,1] = e(alpha)
matrix results[1,2] = e(beta)
pgamma mpg if foreign, gen(tp1 ep1)
gammafit mpg if !foreign
matrix results[2,1] = e(alpha)
matrix results[2,2] = e(beta)
pgamma mpg if !foreign, gen(tp2 ep2)
matrix rownames results = Foreign Domestic
matrix colnames results = alpha beta
matrix li results
scatter tp1 ep1 || scatter tp2 ep2 , legend(order(1 "Foreign" 2 "Domestic"))

For a group variable with many more than 2 classes, it would be better
to set up a loop over the groups.

The help for -gammafit- includes a link to the help for -maximize-,
which explains how to set initial values.

Nick

On Sat, Mar 5, 2011 at 4:47 PM, Peter Maclean <[email protected]> wrote:

> I am new is Stata modelling.
> I am running the following model:
>
> by n:gammafit y, level(95)
> pgamma y, gen(g_p e_p)
>
> where n is  a group variable.
> I would like to save the estimated parameters by gammafit 
>(alpha,beta,alpha+beta
> and lower and upper limit of both alpha and beta) in a variable 'result(n,j).'
>
>
> Also, I would like pgamma to estimate the probabilities (g_p and e_p) by
> variable n.
> The pgamma module does not accept the 'by' option. In addition, is there a way
> to give starting values for the gammafit module?

*
*  For searches and help try:
*  http://www.stata.com/help.cgi?searchhttp://www.stata.com/support/statalist/faqhttp://www.ats.ucla.edu/stat/stata/



      

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index