calling another .do file?

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

calling another .do file?

Costello, Michael (Contractor)
Statalist,

Is it possible to have a command inside a .do file that allows you to call and execute a different .do file, then go back to the original and finish processing?

-Michael

--
Michael Costello
Intern, Education Policy and Systems
RTI International     


*
*   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/
Reply | Threaded
Open this post in threaded view
|

Re: calling another .do file?

nshephard
Administrator
On Mon, Jul 19, 2010 at 3:21 PM, Costello, Michael (Contractor)
<mcostello/[hidden email]> wrote:
> Statalist,
>
> Is it possible to have a command inside a .do file that allows you to call and execute a different .do file, then go back to the original and finish processing?
>

Yes (although a quick experiment of actually trying it out could have
answered this for you ;-).


<---Start test1.do--->
do test2.do
<---End test1.do--->

<---Start test2.do--->
di "Hello you've successfully called me from test1.do"
<---End test1.do--->

do test1



In fact you can do this multiple times and -man limits- shows you that
you can have upto 64 nested do-files.

See also [U] 16 Do-Files chapter of the Users Guide for the most
comprehensive over-view of writing do-files

Neil


--
"... no scientific worker has a fixed level of significance at which
from year to year, and in all circumstances, he rejects hypotheses; he
rather gives his mind to each particular case in the light of his
evidence and his ideas." - Sir Ronald A. Fisher (1956)

Email - [hidden email]
Website - http://slack.ser.man.ac.uk/
Photos - http://www.flickr.com/photos/slackline/
*
*   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/
Reply | Threaded
Open this post in threaded view
|

Re: calling another .do file?

Maarten buis
In reply to this post by Costello, Michael (Contractor)
--- On Mon, 19/7/10, Costello, Michael wrote:
> Is it possible to have a command inside a .do file that
> allows you to call and execute a different .do file, then go
> back to the original and finish processing?

Yes, there are two ways: -do- will execute the commands in the
.do file and displays the output, while -run- executes the
commands but suppresses the output. See -help do-.

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


     

*
*   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/
Reply | Threaded
Open this post in threaded view
|

Multicollinearity in slogit

Abdul Salam Lodhi
In reply to this post by Costello, Michael (Contractor)
Good evening to every one,
 
any one if know how to check for multicollinearity in
slogit model.

best regards
Abdul

On Mon, 19 Jul 2010 11:21:02 -0400
  "Costello, Michael (Contractor)"
<mcostello/[hidden email]> wrote:

> Statalist,
>
> Is it possible to have a command inside a .do file that
>allows you to call and execute a different .do file, then
>go back to the original and finish processing?
>
> -Michael
>
> --
> Michael Costello
> Intern, Education Policy and Systems
> RTI International     
>
>
> *
> *   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/

___________________________________________________________
Abdul Salam Lodhi
Junior Researcher, ZEF b
Center for Development Research
University of Bonn

  ZEF b
Walter-Flex Strasse 3
  53113, Bonn, Germany.
 
*
*   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/
Reply | Threaded
Open this post in threaded view
|

Re: Multicollinearity in slogit

Maarten buis
--- On Mon, 19/7/10, Abdul Salam Lodhi wrote:
>  any one if know how to check for multicollinearity in
> slogit model.

Just use -corr- to look at the correlations between the
explanatory variables. Remember that multicollinearity
is never a problem. See, e.g.
<http://www.stata.com/statalist/archive/2010-02/msg00290.html>
or
<http://www.stata.com/statalist/archive/2010-07/msg00675.html>

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


     

*
*   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/
Reply | Threaded
Open this post in threaded view
|

Re: Multicollinearity in slogit

SR Millis
The issue of collinearity concerns the relationships among the covariates (or independent variables).  Thus, the functional form of the model for the response variable is irrelevant to the estimation of collinearity.  In your model, you can assess the degree of collinearity by the standard diagnostics: condition indexes, variance decomposition proportions, and VIFs.

Scott Millis



--- On Mon, 7/19/10, Maarten buis <[hidden email]> wrote:

> From: Maarten buis <[hidden email]>
> Subject: Re: st: Multicollinearity in slogit
> To: [hidden email]
> Date: Monday, July 19, 2010, 11:48 AM
> --- On Mon, 19/7/10, Abdul Salam
> Lodhi wrote:
> >  any one if know how to check for
> multicollinearity in
> > slogit model.
>
> Just use -corr- to look at the correlations between the
> explanatory variables. Remember that multicollinearity
> is never a problem. See, e.g.
> <http://www.stata.com/statalist/archive/2010-02/msg00290.html>
> or
> <http://www.stata.com/statalist/archive/2010-07/msg00675.html>
>
> Hope this helps,
> Maarten
>
> --------------------------
> Maarten L. Buis
> Institut fuer Soziologie
> Universitaet Tuebingen
> Wilhelmstrasse 36
> 72074 Tuebingen
> Germany
>
> http://www.maartenbuis.nl
> --------------------------
>
>
>      
>
> *
> *   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/
Reply | Threaded
Open this post in threaded view
|

Re: Multicollinearity in slogit

Abdul Salam Lodhi
In reply to this post by Maarten buis
ya thanks !
now i am more confident in interprepting my results
Best regards
Abdul
On Mon, 19 Jul 2010 15:48:35 +0000 (GMT)
  Maarten buis <[hidden email]> wrote:

> --- On Mon, 19/7/10, Abdul Salam Lodhi wrote:
>>  any one if know how to check for multicollinearity in
>> slogit model.
>
> Just use -corr- to look at the correlations between the
> explanatory variables. Remember that multicollinearity
> is never a problem. See, e.g.
> <http://www.stata.com/statalist/archive/2010-02/msg00290.html>
> or
> <http://www.stata.com/statalist/archive/2010-07/msg00675.html>
>
> Hope this helps,
> Maarten
>
> --------------------------
> Maarten L. Buis
> Institut fuer Soziologie
> Universitaet Tuebingen
> Wilhelmstrasse 36
> 72074 Tuebingen
> Germany
>
> http://www.maartenbuis.nl
> --------------------------
>
>
>      
>
> *
> *   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/

___________________________________________________________
Abdul Salam Lodhi
Junior Researcher, ZEF b
Center for Development Research
University of Bonn

  ZEF b
Walter-Flex Strasse 3
  53113, Bonn, Germany.
 
*
*   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/
Reply | Threaded
Open this post in threaded view
|

Re: calling another .do file?

Jeph Herrin-4
In reply to this post by Maarten buis
Three ways actually, because you can also -include-
a .do file, which will excute the commands and display
the output, while retaining local macros when control
returns to the file which -include-ed it.

cheers,
Jeph

>
> Yes, there are two ways: -do- will execute the commands in the
> .do file and displays the output, while -run- executes the
> commands but suppresses the output. See -help do-.
>
> Hope this helps,
> Maarten
>
> --------------------------
> Maarten L. Buis
> Institut fuer Soziologie
> Universitaet Tuebingen
> Wilhelmstrasse 36
> 72074 Tuebingen
> Germany
>
> http://www.maartenbuis.nl
> --------------------------
>
>
>
>
> *
> *   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/
Reply | Threaded
Open this post in threaded view
|

Re: Multicollinearity in slogit

Clive Nicholas
In reply to this post by Abdul Salam Lodhi
Abdul Salam Lodhi replied to Maarten Buis:

> ya thanks !
> now i am more confident in interprepting my results

Naturally, we're all delighted that you've found a solution to your
problem. However, you can implement the advice given by Maarten and
Scott by using Phil Ender's excellent -collin- command, downloadable
from SSC. Try it if you're not aware of it!

--
Clive Nicholas

[Please DO NOT mail me personally here, but at
<[hidden email]>. Please respond to contributions I make in
a list thread here. Thanks!]

"My colleagues in the social sciences talk a great deal about
methodology. I prefer to call it style." -- Freeman J. Dyson.
*
*   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/
Reply | Threaded
Open this post in threaded view
|

Re: Multicollinearity in slogit

David Greenberg
In reply to this post by Maarten buis
Examining zero-order correlations is an imperfect method for detecting multicollinearity. One can have all correlations among the predictors being quite reasonable and suggesting no problem with multicollinearity, but having in fact a major problem due to strong linear dependencies among a set of predictors.
  - David Greenberg, Sociology Department, New York University

----- Original Message -----
From: Maarten buis <[hidden email]>
Date: Monday, July 19, 2010 11:50 am
Subject: Re: st: Multicollinearity in slogit
To: [hidden email]


> --- On Mon, 19/7/10, Abdul Salam Lodhi wrote:
> >  any one if know how to check for multicollinearity in
> > slogit model.
>
> Just use -corr- to look at the correlations between the
> explanatory variables. Remember that multicollinearity
> is never a problem. See, e.g.
> <
> or
> <
>
> Hope this helps,
> Maarten
>
> --------------------------
> Maarten L. Buis
> Institut fuer Soziologie
> Universitaet Tuebingen
> Wilhelmstrasse 36
> 72074 Tuebingen
> Germany
>
> http://www.maartenbuis.nl
> --------------------------
>
>
>      
>
> *
> *   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/
Reply | Threaded
Open this post in threaded view
|

summary statistics with mi multiple imputation

Alan Acock
In reply to this post by Maarten buis
When imputing 20 datasets and dong a logistic regression, I still need some descriptive statistics on background/demographic variables to describe the sample.
a. Should I report the demographic means/sd's for each variable using the original dataset and N for each variable?
b. Should I report the grand mean treating the 20 datasets as one big dataset?
c. What is the best practice? Is there a way to get confidence intervals that around the means that take the multiple imputation into account?

Perhaps I'm missing something that is quite obvious.

--Alan Acock

*
*   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/
Reply | Threaded
Open this post in threaded view
|

Re: summary statistics with mi multiple imputation

Maarten buis
--- On Mon, 19/7/10, Alan Acock wrote:

> I still need some descriptive
> statistics on background/demographic variables to describe
> the sample.
> a. Should I report the demographic means/sd's for each
> variable using the original dataset and N for each
> variable?
> b. Should I report the grand mean treating the 20 datasets
> as one big dataset?
> c. What is the best practice? Is there a way to get
> confidence intervals that around the means that take the
> multiple imputation into account?

It can be informative to report both the means in your
original sample and the average of the means in each
imputed sample (the latter is the point estimate in multiple
imputated datasets). If you only want the means and
their standard errors / confidence intervals you can
use the -mean- command, which can easily be combined
with -mim-. The example below requires both -ice- and
-mim-, which can be downloaded by typing in Stata
-ssc install ice- and -ssc install mim-, respectively.

*----------------- begin example ------------------
sysuse nlsw88, clear
ice union grade tenure race south, m(5) clear
mean union grade tenure south if _mj == 0
mim: mean union grade tenure south
*------------------- end example ------------------
(For more on examples I sent to the Statalist see:
http://www.maartenbuis.nl/example_faq )

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


     

*
*   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/
Reply | Threaded
Open this post in threaded view
|

Re: summary statistics with mi multiple imputation

David Bell-3
In reply to this post by Alan Acock
--
Alan,

One imagines that you do not have much missing data for your demographic variables.  I would in general be inclined to give descriptive statistics on non-missing data only.  This avoids any question from readers (and reviewers) about whether the imputation method introduced any biases.  The non-missing data are are, of course, the sample from which imputations are to be made.  If you include Ns, then readers can see how much data were imputed.

Dave
====================================
David C. Bell
Professor of Sociology
Indiana University Purdue University Indianapolis (IUPUI)
(317) 278-1336
====================================




On Jul 19, 2010, at 5:35 PM, Alan Acock wrote:

> When imputing 20 datasets and dong a logistic regression, I still need some descriptive statistics on background/demographic variables to describe the sample.
> a. Should I report the demographic means/sd's for each variable using the original dataset and N for each variable?
> b. Should I report the grand mean treating the 20 datasets as one big dataset?
> c. What is the best practice? Is there a way to get confidence intervals that around the means that take the multiple imputation into account?
>
> Perhaps I'm missing something that is quite obvious.
>
> --Alan Acock
>
> *
> *   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/
Reply | Threaded
Open this post in threaded view
|

executing do file in current namespace [was calling another .do file?]

Nick Winter
In reply to this post by Jeph Herrin-4
Very cool - I had never realized that you can use -include-
interactively, which executes a .do file in the interactive namespace --
so locals set in the interactive session are visible to it, and those
set in the do file persist after it finishes.

Not sure exactly how this would be useful, but seems like it might be in
some context...

Nick Winter

On 7/19/2010 12:23 PM, Jeph Herrin wrote:

> Three ways actually, because you can also -include-
> a .do file, which will excute the commands and display
> the output, while retaining local macros when control
> returns to the file which -include-ed it.
>
> cheers,
> Jeph
>
>>
>> Yes, there are two ways: -do- will execute the commands in the
>> .do file and displays the output, while -run- executes the
>> commands but suppresses the output. See -help do-.
>>
>> Hope this helps,
>> Maarten
>>
>> --------------------------
>> Maarten L. Buis
>> Institut fuer Soziologie
>> Universitaet Tuebingen
>> Wilhelmstrasse 36
>> 72074 Tuebingen
>> Germany
>>
>> http://www.maartenbuis.nl
>> --------------------------
>>
>>
>>
>>
>> *
>> * 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/

--
--------------------------------------------------------------
Nicholas Winter                                 434.924.6994 t
Assistant Professor                             434.924.3359 f
Department of Politics                  [hidden email] e
University of Virginia          faculty.virginia.edu/nwinter w
S385 Gibson Hall, South Lawn
*
*   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/
Reply | Threaded
Open this post in threaded view
|

Re: summary statistics with mi multiple imputation

Maarten buis
In reply to this post by David Bell-3
--- On Tue, 20/7/10, David Bell wrote:
> One imagines that you do not have much missing data for
> your demographic variables.  I would in general be
> inclined to give descriptive statistics on non-missing data
> only.  This avoids any question from readers (and
> reviewers) about whether the imputation method introduced
> any biases.  The non-missing data are are, of course,
> the sample from which imputations are to be made.  If
> you include Ns, then readers can see how much data were
> imputed.

The purpose of showing describtive statistics is to give
the reader an idea of what the data is that is being used
in your analysis. Since what you use in your analysis is
the imputed dataset, it would make sense to describe that.
On the other hand the empricial information comes from
your raw/unimputed data.

So I would present both, as it also gives a bit of insight
how the imputation process changes your data. If there are
some big differences then you will need to justify it, but
that is in those extreme cases usually quite easy (e.g.
the missing values are mostely young people who...). This
way you can try to avoid that the reader regards the
imputation as some form of white/black magic.

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


     

*
*   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/
Reply | Threaded
Open this post in threaded view
|

RE: summary statistics with mi multiple imputation

Lachenbruch, Peter
In reply to this post by Alan Acock
Alan,

I assume you mean 20 imputations and not 20 data sets being imputed individually.  I also assume that some of the background/demographic variables have missing values and you want to get good estimates of these.  So...

Within the mi estimate command, you can use means for these and if you want percentiles, you can use qreg.  I have a Stata Tip coming out in vol 10 #3 on this.

Tony

Peter A. Lachenbruch
Department of Public Health
Oregon State University
Corvallis, OR 97330
Phone: 541-737-3832
FAX: 541-737-4001


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Alan Acock
Sent: Monday, July 19, 2010 2:35 PM
To: [hidden email]
Subject: st: summary statistics with mi multiple imputation

When imputing 20 datasets and dong a logistic regression, I still need some descriptive statistics on background/demographic variables to describe the sample.
a. Should I report the demographic means/sd's for each variable using the original dataset and N for each variable?
b. Should I report the grand mean treating the 20 datasets as one big dataset?
c. What is the best practice? Is there a way to get confidence intervals that around the means that take the multiple imputation into account?

Perhaps I'm missing something that is quite obvious.

--Alan Acock

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