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 on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: re: st: Package -r2c- now available in SSC


From   Joseph Luchman <jluchman@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   RE: re: st: Package -r2c- now available in SSC
Date   Wed, 6 Feb 2013 08:19:54 -0500

Hello Nick and Maarten,

  I agree with Simon - thank you for the suggestions.

  I realize that such variable names are likely to appeal to the users
of count data models (no doubt for the same reason they appealed to me
as names).

  I can assure (potential) users of -r2c- that a safeguard is built
into the program however to avoid overwriting variables (the data are
preserved before dropping and generating, then subsequently restored
before the program terminates).

  The program generates a variable in the dataset to refer to it in
different programs within the command so that it will not be dropped
at the generating command's termination, which is also why global
macros are dispersed throughout instead of local ones (I originally
wanted to use tempvars and, in fact, do within any one program when it
makes sense to do so).  The approach is a little "clunky" and
inelegant; this issue is something I plan to fix in future renditions
of the command.

  I'll admit that I'm mainly familiar with the capabilities of Stata
12 (the version I mainly learned Stata on).  I added the version 12
requirement so that I could be sure all the facilities I take for
granted in 12 will work, and so it's not a good answer as to why it's
only useful for 12 at current - mostly a function of my ignorance of
the capabilities of versions 11, 10, and earlier and how they overlap
with version 12.  In the end, I would like to make the command
backwards compatible and I intend to do so as soon as I can for
interested users as I anticipate that it does not use many (or perhaps
any) facilities that are new to version 12.

  Please do forward on any other problems discovered or suggestions
for the -r2c- command and I appreciate the dialog regarding the
command.

- joe

Joseph Nicholas Luchman, M.A.
----
Senior Research Associate | Fors Marsh Group
Desk: 571 858 3770
Email: jluchman@forsmarshgroup.com
forsmarshgroup.com
----
Doctoral Candidate
Industrial Organizational Psychology
George Mason University
http://sites.google.com/site/jluchman/


Thanks  Nick and Maarten for your insights on the -r2c-. Very good
comments and suggestions.

Simon


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Maarten
Buis
Sent: den 5 februari 2013 20:38
To: statalist@hsphsun2.harvard.edu
Subject: Re: re: st: Package -r2c- now available in SSC

On Tue, Feb 5, 2013 at 7:46 PM, Nick Cox wrote:
> I note in passing that -r2c- evidently feels free to use the variable
> names
>
> mu mumean wt _est_full counts alpha
>
> so that it will -drop- any previous instances and then overwrite them
> with new ones. This is not documented so far as I can see. Correct me
> if I am wrong, such practices are widely regarded as dangerous Stata
> programming style. Some of these names look highly likely to appeal to
> people fitting count models.

To add to this: the typical way in which this is circumvented is to
use temporary variables. So you would do something like:

tempvar mu mumean wt _est_full counts alpha gen `mu' = ...
egen `mumean' = ...
etc.

the variables `mu' , `mumean', etc. (notice the -`- and the -'-, they
are necesary) will have unique names that do not exist in your data,
they will exist as long as the program runs and will be deleated when
the program ends. That way you do not change the data (unless the user
explicitly asks for it), which is typically considerd good practice in
this community.

-- Maarten

---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany
--------------------------------
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index