Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: formatting and exporting ttest results


From   "Ina Ganguli" <ina.ksg@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Re: formatting and exporting ttest results
Date   Sat, 22 Apr 2006 22:49:29 -0400

Dear Statalist,

I wanted to follow up on my previous posting and say thank you to
everyone who responded.  Sorry I had missed the earlier thread on
this, but in case anyone wants to do something similar -- Roger's
suggestion of -regress- with -parmby- and -metaparm-, and then
Akihito's suggestion of -file write- works perfectly with a few loops.

Thanks again!
Ina

On 4/14/06, Akihito Tokuhara <akitoku4@hotmail.com> wrote:
> Dear Ina,
>
> As others have given advice on commands for t-test, my reply here is about
> how to export or
> write out to a text *.txt file with user-made formats suitable for different
> objective, which I don't
> know if that is what Ina's question is about. You can use the command --
> file write -- like this:
>
> -----------------
> file open anyname using myresult.txt, write text append/replace;
> file write anyname  _newline  _col(18)  " <**>> stuffs here <<**> "
> _newline;
> file write anyname  _newline  _col(4)  " ** others ** "   _newline;
> file close anyname;
> ----------------
>
> The command -- file write -- is like -- display --, and you have to test the
> output text file until you
> get the format you want. I often have to use this to get the format I need
> for converting to
> different forms of tables. Sometimes you may need to create temporary
> variables to save the
> results for the writing out to text file. I am not sure if this is what Ina
> asked about. HTMH.
>
> Akihito
>
> -------------------------
> >From: "Newson, Roger B" <r.newson@imperial.ac.uk>
> >Reply-To: statalist@hsphsun2.harvard.edu
> >To: <statalist@hsphsun2.harvard.edu>
> >Subject: st: RE: Rép. : st: RE: formatting and exporting ttest results
> >Date: Wed, 12 Apr 2006 16:36:11 +0100
> >
> >Another possibility for saving t-test results (although not a short one) is
> >to use -regress- together with -parmby- and -metaparm-. This has the
> >advantage that -metaparm- uses the Satterthwaite corrected degrees of
> >freedom, so the confidence limits will be robust to heteroskedasticity
> >between the two groups compared.
> >
> >For instance:
> >
> >sysuse auto, clear
> >parmby "regress weight, robust", by(foreign) norestore
> >tempfile tf1
> >metaparm [iweight=!foreign-foreign], saving(`tf1', replace)
> >append using `tf1'
> >list
> >
> >will produce and display a dataset in memory (overwriting the original
> >-auto- data), with 1 observation for each of 3 parameters (mean US car
> >weight, mean non-US car weight, and their difference). These results will
> >be essentially the same as those produced by the shorter program
> >
> >sysuse auto, clear
> >ttest weight, by(foreign) unequal
> >
> >However, the results produced by -parmby- and -metaparm- can be tabulated
> >and/or plotted as the user desires. This is an example of the resultsset
> >approach to plotting and tabulating results, and more references on this
> >can be found in the online help for the -parmest- package (which includes
> >-parmby-). Both -parmby- and -metaparm- can be downloaded from SSC using
> >the -ssc- command in Stata.
> >
> >I hope this helps.
> >
> >Roger
> >
> >
> >Roger Newson
> >Lecturer in Medical Statistics
> >POSTAL ADDRESS:
> >Respiratory Epidemiology and Public Health Group
> >National Heart and Lung Institute at Imperial College London
> >St Mary's Campus
> >Norfolk Place
> >London W2 1PG
> >STREET ADDRESS:
> >Respiratory Epidemiology and Public Health Group
> >National Heart and Lung Institute at Imperial College London
> >47 Praed Street
> >Paddington
> >London W1 1NR
> >TELEPHONE: (+44) 020 7594 0939
> >FAX: (+44) 020 7594 0942
> >EMAIL: r.newson@imperial.ac.uk
> >WEBSITE: http://www.imperial.ac.uk/nhli/r.newson/
> >Opinions expressed are those of the author, not of the institution.
> >
> >
> >-----Original Message-----
> >From: owner-statalist@hsphsun2.harvard.edu
> >[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Herve STOLOWY
> >Sent: 12 April 2006 16:02
> >To: statalist@hsphsun2.harvard.edu
> >Subject: Rép. : st: RE: formatting and exporting ttest results
> >
> >Dear Ina:
> >
> >Sorry, I did not see your first posting. I just discovered Nick's reply.
> >Some time ago, I raised the same issue and received several replies which
> >helped to find a solution. But this solution, as Nick said, is not a "short
> >answer".
> >
> >If you make a ttest with a groupvar, you can use -statsmat- and
> >-makematrix- (downloadable from ssc)(with -ttest-) followed by -mat2txt-
> >(downloadable from ssc) to get a .txt file.
> >
> >Here is an example I used for one research project:
> >
> >statsmat size1, s(N mean sd) by(format_bs) mat(mat1)
> >makematrix mat2, from(r(t) r(p)) label : ttest size1, by(format_bs)
> >matrix mat3=mat2' //Transposition of the matrix
> >matrix mat4 = mat1, mat3 // Grouping of the two matrices
> >matrix colnames mat4 = "Number of observations" Mean "Standard deviation"
> >"Student t-test"
> >mat2txt, matrix(mat4) saving(univariate_bs) replace
> >
> >If you want to compare two variables with a ttest, here is another example
> >and solution:
> >
> >makematrix T5A1, from(r(N) r(mean) r(sd) r(min) r(p50) r(max)) label :
> >univar MAPE_direct_scal MAPE_indirect_scal if outlier_cfo_scal!=1
> >&outlier_MAPE!=1
> >ttest MAPE_direct_scal = MAPE_indirect_scal if outlier_cfo_scal!=1
> >&outlier_MAPE!=1
> >mat T5A2 = r(p) \ r(t)
> >mat T5A3 = T5A1, T5A2
> >matrix colnames T5A3 = N "Mean" "Std Dev" "Min" "Median"  "Max" "T/p-value"
> >mat2txt, matrix(T5A3) saving(stat_MAPE_table5A)  replace
> >
> >The syntax might not the most effective but I know these commands work.
> >
> >I hope this helps.
> >
> >Best regards
> >
> >Hervé Stolowy
> >***********************************************************
> >Professeur/Professor
> >Coordinateur du Département/Head of Department
> >HEC Paris
> >Département Comptabilité Contrôle de gestion / Dept of Accounting and
> >Management Control
> >1, rue de la Liberation
> >78351 - Jouy-en-Josas
> >France
> >Tel: +33 1 39 67 94 42 - Fax: +33 1 39 67 70 86
> >stolowy@hec.fr
> >http://studies.hec.fr/web/stolowy
> > >>> n.j.cox@durham.ac.uk 12/04/06 13:50 >>>
> >The short answer is: Evidently not.
> >
> >However, as a t-test comparing two group means
> >is really a regression in disguise, you
> >should be able to use your favourite post-regression
> >program for this purpose.
> >
> >Nick
> >n.j.cox@durham.ac.uk
> >
> >Ina Ganguli
> >
> > > I was wondering whether there is a command (like -outreg-) I can use
> > > to format and export multiple -ttest- results to a .txt file for
> > > easier conversion to tables?
> > >
> > > I would like to have results in the following format:
> > >
> > >                     Group1     Group2     Difference
> > > variable1       mean       mean        mean*
> > >                       (se)          (se)          (se)
> > > variable2       mean       mean        mean*
> > >                       (se)          (se)          (se)
> > > etc.
> > >
> > > I've seen references to commands that may perhaps be what I need
> > > (-tabexport-, -parmby-?), but I wanted to check whether there is a
> > > program/command out there that would work well for this.
> >
> >*
> >*   For searches and help try:
> >*   http://www.stata.com/support/faqs/res/findit.html
> >*   http://www.stata.com/support/statalist/faq
> >*   http://www.ats.ucla.edu/stat/stata/
> >
> >
> >*
> >*   For searches and help try:
> >*   http://www.stata.com/support/faqs/res/findit.html
> >*   http://www.stata.com/support/statalist/faq
> >*   http://www.ats.ucla.edu/stat/stata/
> >
> >*
> >*   For searches and help try:
> >*   http://www.stata.com/support/faqs/res/findit.html
> >*   http://www.stata.com/support/statalist/faq
> >*   http://www.ats.ucla.edu/stat/stata/
>
> _________________________________________________________________
> Express yourself instantly with MSN Messenger! Download today - it's FREE!
> http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>
>

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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   |   What's new   |   Site index