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: testing coefficients using parmby command


From   "Roger B. Newson" <[email protected]>
To   [email protected]
Subject   Re: st: testing coefficients using parmby command
Date   Fri, 27 Jul 2012 13:59:17 +0100

There are a large numbers of assorted -parmest- examples in the on-line help for -parmest-, and in the various references cited there. However, in your case, the trick is probably to use -levelsof- to get a list of levels of -id-, and to loop over those, storing the temporary filenames in a global macro. The resultssets can then be concatenated, and the -idstr()- option can be used for storing information specific to each resultsset on one or more resultsset-specific quantities. The -split- command can be usefful, if we have multiple resultsset-specific variables. As in:

#delim ;
global tflist "";
levelsof id, lo(ids);
foreach ID of num `ids' {;
  regr y x1 ,robust;
  test (_cons=0) (x1=1);
  scal stestp=r(p);
  tempfile tfcur;
  parmest, label idstr(`ID'&`=stestp')
    saving(`"`tfcur'"', replace) flis(tflist);
};
clear;
append using $tflist;
split idstr, parse(&) gene(S_);
destring S_1, gene(id);
destring S_2, gene(testp);
drop idstr S_*;
sort id, stable;

This will create an output dataset (or resultsset) in the memory, with 1 observation per fitted parameter and 2 extra variables -id- and -testp-, containing the appropriate value of -id- and the test P-value, respectively.

Many variations on this theme are possible. For instance, if -id- has value labels and/or a variable label orand/or a format, then we might use the SSC package -descsave-, with the -dofile()- option, to re-create these in the concatenated resultsset.

I hope this helps.

Best wishes

Roger


Roger B Newson BSc MSc DPhil
Lecturer in Medical Statistics
Respiratory Epidemiology and Public Health Group
National Heart and Lung Institute
Imperial College London
Royal Brompton Campus
Room 33, Emmanuel Kaye Building
1B Manresa Road
London SW3 6LR
UNITED KINGDOM
Tel: +44 (0)20 7352 8121 ext 3381
Fax: +44 (0)20 7351 8322
Email: [email protected]
Web page: http://www.imperial.ac.uk/nhli/r.newson/
Departmental Web page:
http://www1.imperial.ac.uk/medicine/about/divisions/nhli/respiration/popgenetics/reph/

Opinions expressed are those of the author, not of the institution.

On 27/07/2012 13:14, David Ashcraft wrote:
Thanks Roger. Do you have any example that I can follow? What you have said makes complete sense but it is a little overwhelming for me to implement.
Regards

David


----- Original Message -----
From: Roger B. Newson <[email protected]>
To: [email protected]
Cc:
Sent: Friday, July 27, 2012 1:22:38 PM
Subject: Re: st: testing coefficients using  parmby command

To do this, you have to use -parmest- inside a loop, instead of using
-parmby-. You need to loop over the values of -id-. In each iteration of
the loop, you nee to execute your command for the current -id- group,
use -test- to extract the test statistics for the current -id- group,
and then use -parmest- for each -id- group, storing the test statistics
in the -idnum()- or -idstr)_- options of -parmest-, and storing the
results for the current -id- group in a -tempfile-. After doung this,
you can concatenate the resultssets created, using -append- or maybe
-dsconcat-, and then you will have a combined resultsset in memory,
complete with test statistics.

I hope this helps.

Best wishes

Roger


Roger B Newson BSc MSc DPhil
Lecturer in Medical Statistics
Respiratory Epidemiology and Public Health Group
National Heart and Lung Institute
Imperial College London
Royal Brompton Campus
Room 33, Emmanuel Kaye Building
1B Manresa Road
London SW3 6LR
UNITED KINGDOM
Tel: +44 (0)20 7352 8121 ext 3381
Fax: +44 (0)20 7351 8322
Email: [email protected]
Web page: http://www.imperial.ac.uk/nhli/r.newson/
Departmental Web page:
http://www1.imperial.ac.uk/medicine/about/divisions/nhli/respiration/popgenetics/reph/

Opinions expressed are those of the author, not of the institution.

On 26/07/2012 12:34, David Ashcraft wrote:
I am using parmby command to regress a number of equations by id as per below:

parmby "regr y x1 ,robust",by(id) label saving(myparms3,replace)

Now I want to test for each id:


test _cons=0
test X1=1
test (_cons=0)(X1=1)


and store these results on myparms3 file.

At the moment when I run the last three commands, it simply give me the result of last regression.
Any help will be highly appreciated.
Regards


David

*
*   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/

*
*   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/


*
*   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/

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