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
Nick Cox <email@example.com>
Re: re: st: Package -r2c- now available in SSC
Wed, 6 Feb 2013 14:30:58 +0000
This answer will no doubt reassure many actual or potential users of
your program. I am not clear that it rules out all possibility either
of misunderstanding or of clashes of role. I would certainly advise
documenting what you do under this heading so that users or readers of
the program don't jump to the same conclusion.
In general, the answer is just to pass the names of temporary
variables from one program to another. Using globals doesn't usually
bite, largely because other programmers don't use them, largely
because they know they can bite.
A small refinement in your program would be to use -summarize,
meanonly- whenever all you want is r(sum). The option -meanonly- is
poorly named, because it yields more than the mean, including the sum.
Also, there is a small potential loss of precision in passing (e.g.)
`r(sum)' rather than r(sum) or in using locals rather than scalars,
unless you know that the numbers involved can be captured accurately
On Wed, Feb 6, 2013 at 1:19 PM, Joseph Luchman <firstname.lastname@example.org> wrote:
> 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
> - joe
> Joseph Nicholas Luchman, M.A.
> Senior Research Associate | Fors Marsh Group
> Desk: 571 858 3770
> Email: email@example.com
> Doctoral Candidate
> Industrial Organizational Psychology
> George Mason University
> Thanks Nick and Maarten for your insights on the -r2c-. Very good
> comments and suggestions.
> -----Original Message-----
> From: firstname.lastname@example.org
> [mailto:email@example.com] On Behalf Of Maarten
> Sent: den 5 februari 2013 20:38
> To: firstname.lastname@example.org
> 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
>> 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' = ...
> 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.
* For searches and help try: