Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Roger Newson <r.newson@imperial.ac.uk> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: Collecting ttest results using parmby, factext, metaparm |
Date | Wed, 14 Sep 2011 10:11:54 +0100 |
#delim looks very confusing to me. The normal usage is either #delim ; followed by commands terminated by semicolons, or #delim crfollowed by commands terminated by carriage returns. In the latter case, multi-line commands need to have the internal carriage returns commented out, eg by adding the string
\\\ to the end of every line except the last in every multi-line command.And are you sure that you have installed all the required packages (descsave, parmest, eclplot, sencode, fvregen, and keyby)?
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:58, Tim Evans 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!! 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/ _DISCLAIMER: This email and any attachments hereto contains proprietary information, some or all of which may be confidential or legally privileged. It is for the exclusive use of the intended recipient(s) only. If an addressing or transmission error has misdirected this e-mail and you are not the intended recipient(s), please notify the author by replying to this e-mail. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this e-mail or any attachments, as this may be unlawful. * * 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/ _DISCLAIMER: This email and any attachments hereto contains proprietary information, some or all of which may be confidential or legally privileged. It is for the exclusive use of the intended recipient(s) only. If an addressing or transmission error has misdirected this e-mail and you are not the intended recipient(s), please notify the author by replying to this e-mail. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this e-mail or any attachments, as this may be unlawful. * * 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/