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: Collecting ttest results using parmby, factext, metaparm


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Collecting ttest results using parmby, factext, metaparm
Date   Wed, 14 Sep 2011 10:06:30 +0100

#delim should not be issued by itself. The consequences of doing so
might be curious. Just delete that line if end-of-lines delimit
commands (except where comments continue them).

As I read this, a single -parmby- command is wrapped across three lines.

Nick

On Wed, Sep 14, 2011 at 9:58 AM, Tim Evans <Tim.Evans@wmciu.nhs.uk> wrote:
> I tried pasting this in and changing the version, but I do not get any output at the finish - i.e. a graph - I tried the -eclplot- example in the help page and it works ok:
>
> **BEGIN EXAMPLE**
>
> #delim
> version 11.2
>  sysuse auto, clear
>  global tflist ""
>  global modseq=0
>  tempfile temp1
>  descsave foreign, do(`"`temp1'"', replace)
>  foreach X of var weight length {
>  local Xlab: var lab `X'
>  global modseq=$modseq+1
>  tempfile tf$modseq
>  ttest `X', by(foreign)
>  parmby "regress `X' ibn.foreign, noconst",
>  format(estimate min* max* %8.2f p %-8.2g) idstr("`Xlab'")
>  saving(`"`tf$modseq'"',replace) flist(tflist)
>  }
>  clear
>  append using $tflist
>  sencode idstr, gene(outcome)
>  lab var outcome "Outcome"
>  fvregen, do(`"`temp1'"')
>  drop idstr
>  keyby outcome foreign
>  desc
>  list, abbr(32) noobs sepby(outcome)
>  metaparm [iwei=!foreign-foreign], dfcombine(constant) by(outcome) norestore
>  list, abbr(32) sepby(outcome)
>  eclplot estimate min* max* outcome, hori
>  estopts(msize(4)) ciopts(msize(5))
>  yscale(range(0 3)) ylab(1 2) xline(0) xtitle("Difference (95% CI)")
>
> **END EXAMPLE
>
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Roger Newson
> Sent: 14 September 2011 09:50
> To: statalist@hsphsun2.harvard.edu
> Subject: Re: st: Collecting ttest results using parmby, factext, metaparm
>
> Yes, the example with CI plots works if converted to Stata 11.2, or even
> to Stata 11.0 (the version in which factor varlists were introduced).
> With Stata 10 or below, you have to use -xi:- and -factext-.
>
> 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: r.newson@imperial.ac.uk
> 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 14/09/2011 09:37, Tim Evans wrote:
>> Dear Roger,
>>
>> Does the example with CI plots paste easily into Stata 11.2?
>>
>> Best wishes
>> Tim
>>
>> -----Original Message-----
>> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of David Scharff
>> Sent: 14 September 2011 09:12
>> To: statalist@hsphsun2.harvard.edu
>> Subject: Re: st: Collecting ttest results using parmby, factext, metaparm
>>
>> Dear Roger
>>
>> Many, many thanks for your support! Your code works like a charm, and
>> is exactly what I needed.
>> There have been some earlier queries regarding the
>> ttest-parmby-metaparm task and I think you provided us with a perfect
>> solution.
>> I can now Eclplot all my test results with p-values as labels, great!
>> Again, thank you for your help!
>> Best wishes
>> David
>>
>> 2011/9/13 Roger Newson<r.newson@imperial.ac.uk>:
>>> PS a version of David's -auto- program which also produces CI plots for the
>>> differences between US and non-US cars is as follows:
>>>
>>> **** BEGINNING OF EXAMPLE - CUT HERE
>>> #delim ;
>>> version 12.0;
>>> sysuse auto, clear;
>>> global tflist "";
>>> global modseq=0;
>>> tempfile temp1;
>>> descsave foreign, do(`"`temp1'"', replace);
>>> foreach X of var weight length {;
>>> local Xlab: var lab `X';
>>> global modseq=$modseq+1;
>>> tempfile tf$modseq;
>>> ttest `X', by(foreign);
>>> parmby "regress `X' ibn.foreign, noconst",
>>> format(estimate min* max* %8.2f p %-8.2g) idstr("`Xlab'")
>>> saving(`"`tf$modseq'"',replace) flist(tflist);
>>> };
>>> clear;
>>> append using $tflist;
>>> sencode idstr, gene(outcome);
>>> lab var outcome "Outcome";
>>> fvregen, do(`"`temp1'"');
>>> drop idstr;
>>> keyby outcome foreign;
>>> desc;
>>> list, abbr(32) noobs sepby(outcome);
>>> metaparm [iwei=!foreign-foreign], dfcombine(constant) by(outcome) norestore;
>>> list, abbr(32) sepby(outcome);
>>> eclplot estimate min* max* outcome, hori
>>>   estopts(msize(4)) ciopts(msize(5))
>>>   yscale(range(0 3)) ylab(1 2) xline(0) xtitle("Difference (95% CI)");
>>> **** END OF EXAMPLE - CUT HERE
>>>
>>> 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: r.newson@imperial.ac.uk
>>> 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 13/09/2011 09:46, David Scharff wrote:
>>>>
>>>> Dear all
>>>>
>>>> I need to collect the results of a series of ttests (equal variances),
>>>> store them in a file together with their p-values. In a second step, I
>>>> want to plot the means of the variables with CI's using ECLplot. I'm
>>>> using Roger Newson's parmby, factext and metaparm commands. This is my
>>>> code. I cannot manage to get factext working it seems, but I do not
>>>> figure out where my mistake is. As is obvious, I'm not very
>>>> experienced in programming Stata. (I use Stata 12 if this is
>>>> relevant).
>>>>
>>>> global tflist ""
>>>> global modseq=0
>>>> foreach X of var sem_a sem_b {
>>>> global modseq=$modseq+1
>>>> tempfile tf$modseq temp1
>>>> descsave, do(`temp1', replace)
>>>> ttest `X', by(case)
>>>> parmby "xi, noomit: regress `X' i.case, noconst", label
>>>> format(estimate min* max* %8.2f p %-8.2g) idn($modseq)
>>>> saving(`tf$modseq',replace) flist(tflist)
>>>> factext, do(`temp1')
>>>> metaparm [iwei=!case-case], dfcombine(constant)
>>>> saving(`tf$modseq',replace)
>>>> }
>>>> dsconcat $tflist
>>>>
>>>> The same, adapted to the auto data for easier inspection:
>>>> sysuse auto, clear
>>>> global tflist ""
>>>> global modseq=0
>>>> foreach X of var weight length {
>>>> global modseq=$modseq+1
>>>> tempfile tf$modseq temp1
>>>> descsave, do(`temp1', replace)
>>>> ttest `X', by(foreign)
>>>> parmby "xi, noomit: regress `X' i.foreign, noconst", label
>>>> format(estimate min* max* %8.2f p %-8.2g) idn($modseq)
>>>> saving(`tf$modseq',replace) flist(tflist)
>>>> factext, do(`temp1')
>>>> metaparm [iwei=!foreign-foreign], dfcombine(constant)
>>>> saving(`tf$modseq',replace)
>>>> }
>>>> dsconcat $tflist
>>>>
>>>> Any help is greatly appreciated - I have spent hours finding my mistake
>>>> now...
>>>> Many thanks in advance!!

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