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 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]

Re: st: Fit chi2 as in gammafit


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Fit chi2 as in gammafit
Date   Tue, 30 Aug 2011 21:19:09 +0100

Ho hum. A conservative might want the free parameter to be integer-valued.

Nick

On Tue, Aug 30, 2011 at 9:11 PM, Tirthankar Chakravarty
<tirthankar.chakravarty@gmail.com> wrote:
> You could do this pretty easily using -ml-, allowing additionally the
> possibility of including covariates to parameterise the mean
> (exponential) of the distribution.
>
> /*******************************************/
> // chi2 regression
> webuse dollhill3, clear
> poisson deaths smokes i.agecat
>
> cap prog drop chi2reg
> program chi2reg
>        version 11
>        args lnf theta
>        qui replace `lnf' = -0.5*exp(`theta')*log(2) ///
>                        -lngamma(exp(`theta')/2) + ///
>                        (exp(`theta')/2 - 1)*log($ML_y1) ///
>                        -$ML_y1/2
> end
>
> ml model lf chi2reg (deaths = smokes i.agecat)
> ml maximize
> /*******************************************/
>
> T
>
>
> On Tue, Aug 30, 2011 at 12:53 PM, Maarten Buis <maartenlbuis@gmail.com> wrote:
>> Acutually you can use -gammafit- to estimate a chi square distribution
>> by constraining [beta]_b[_cons] to be 2. The estimated degrees of
>> freedom are than 2*[alpha]_b[_cons]:
>>
>> *------------ begin example -------------
>> drop _all
>> set obs  100
>> gen chi2 = rchi2(3)
>> constraint 1 [beta]_b[_cons]=2
>> gammafit chi2, constraint(1)
>>
>> // display estimated degrees of freedom:
>> lincom [alpha]_b[_cons]*2
>> *------------- end example ---------------
>> (For more on examples I sent to the Statalist see:
>> http://www.maartenbuis.nl/example_faq )
>>
>> Hope this helps,
>> Maarten
>>
>> On Tue, Aug 30, 2011 at 8:43 PM, Nick Cox <njcoxstata@gmail.com> wrote:
>>> -gammafit- (SSC) is also to be attributed to Stephen Jenkins.
>>>
>>> I think the short answer is that nothing is canned and public, but
>>> existing code like -gammafit- would get you most of the way. Fitting a
>>> more general distribution has the merit that it tells you something of
>>> what ways the distribution departs from the specific case.
>>>
>>> See also official -pchi- and -qchi-.
>>>
>>> Nick
>>>
>>> On Tue, Aug 30, 2011 at 7:30 PM, Laurie Molina <molinalaurie@gmail.com> wrote:
>>>> Hi,
>>>> I would like to fit a chi2 probability distribution to my data, in the
>>>> same way as the gammafit command (by Nick Cox) does it.
>>>> Is there any way to perform such a task?
>>>>

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index