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


From   David Scharff <[email protected]>
To   [email protected]
Subject   Re: st: Collecting ttest results using parmby, factext, metaparm
Date   Wed, 14 Sep 2011 10:11:45 +0200

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 <[email protected]>:
> 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: [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 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!!
>> 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/


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