Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: st: Overwritten?
From
"Francis, Richard N" <[email protected]>
To
"[email protected]" <[email protected]>
Subject
RE: st: Overwritten?
Date
Tue, 31 Dec 2013 17:28:56 +0000
Hi Steve,
Thank you for the suggestion, that might just do the trick!
Sergiy developed the work-around targeted the idea of using panel data with the -sroot- program, and did address the -residuals- issue.
The -residuals- issue arose after I began developing some proficiency with the panel data work-around developed by Sergiy.
So, if I understand what you are suggesting: 1) your code will eliminate the need for -srootfix- ; 2) your code will permit the use of panel data; and 3) your code will address the creation of the new -residuals- variable .... am I on the right track?
I am most grateful for your help.
FYI, I am a SAS user, so Stata is VERY foreign. I try to get a general sense of the code, but the syntax is pretty much out of my grasp.
Thanks again!
Rick Francis
Associate Professor
Department of Accounting
College of Business Administration
University of Texas at El Paso
500 W. University Avenue
El Paso, TX 79968
Office: 915-747-7953
FAX: 915-747-8618
Email: [email protected]
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Steve Samuels
Sent: Tuesday, December 31, 2013 10:00 AM
To: [email protected]
Subject: Re: st: Overwritten?
Your problem is easy to diagnose, I think: -sroot.ado contains a -predict residuals, res- command. This is equivalent to generating a new variable. At the second iteration, -predict- should fail because the data set already contains a variable named "res". If I am correct, the problem has nothing to do with the -if- error that Sergiy's -srootfix- is designed to work around.
In such situations, I use a -keep if-, -append-, and -save, replace- approach. Below is the outline of a do file for you to fill in. You should be able to call -sroot- directly, as -srootfix- is no longer needed.
**********CODE BEGINS****************
/* Create a data set to hold results */
clear
save dhold, emptyok replace
forval i = 1/`limit' {
use yourdata, clear
keep if id ==`i'
/* Do something that generates variables */ append using dhold save dhold, replace } **************CODE ENDS**************
Steve
Steven J Samuels
[email protected]
18 Cantine's Island
Saugerties NY 12477 USA
tel: 845-246-0774
On Dec 30, 2013, at 9:28 PM, Francis, Richard N wrote:
Nick,
Thank you for your advice.
In your experience, is there a reasonable expectation that the original author will alter the program?
Rick
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
Sent: Monday, December 30, 2013 7:06 PM
To: [email protected]
Subject: Re: st: Overwritten?
<>
Side details first:
A convention suggested for Statalist is to use notation such as -foo- to flag names of commands, variables, etc. as used in Stata. That way, for example, the word
replace
is to be understood as just ordinary English but the word
-replace-
is easy to spot as something that could be typed in Stata.
A convention is just that, but I like the Statalist convention, and have often commended it. The different convention you're introducing here of using -FOO instead does not strike me as a good one, if only for the reason that upper case is usually not idiomatic Stata, but that's a personal view.
For the record, -sroot- here is from Stata Journal 9(3) 2009.
The nub of the matter I think is this. The program -srootfix- by Sergiy Radyakin -preserve-s your original data, does some work and when it's done -restore-s the original data. Thus it's futile adding new variables to the dataset after -preserve-, as they will just disappear at the -restore-. The -restore- is not explicit in the code, but it's automatic given the -preserve-. The fact that -preserve- requires a -restore- for the fix you originally asked for is explicit in http://www.stata.com/statalist/archive/2013-11/msg00103.html
Short of fixing a clone of -sroot- properly so that you don't need a work-around, or asking the original author to do that for you, it seems that you would need to -save- the dataset you create each time and then -append- them all.
Fixing this properly is the better solution, as then your overall problem should yield to -statsby-.
Nick
[email protected]
On 30 December 2013 21:59, Francis, Richard N <[email protected]> wrote:
> Have an option within a called program -SROOTFIX which generates residuals for a regression command.
>
> However, the variable containing the residuals -RES is absent.
>
> The called program -SROOTFIX actually calls another program -SROOT.
>
> Separate execution of -SROOT retains the residuals variable -RES, which suggests that something within the -SROOTFIX pgm overwrites the residuals variable -RES.
>
> The master program is as follows:
>
> forval i = 1/`limit' {
> display "Iteration of `i' of `limit"
> replace which = "`: label (id) `i''" in `i'
> srootfix fcf if id == `i' , residuals(res)
> qui foreach v in Z14 Z24 Z34 Z4t Z3t Z2t Z1t {
> replace `v' = r(`v') in `i'
> }
> }
>
> I have executed the program with the -replace command.
>
> However, the residuals variable -RES continues to be absent.
>
> The contents of -SROOTFIX are as follows:
>
> *! By Sergiy Radyakin, 2013
> *! Fixes problem of -if- modifier [suspected] not working in public (SJ) version of -sroot-.
> ** See http://www.stata.com/statalist/archive/2013-11/msg00366.html
>
> program define srootfix
> version 9.2
> syntax varname(ts) [if] [in] ,[*]
> preserve
> marksample touse
> keep if `touse'
> sroot `varlist' , `options'
> end
>
> ** end of file **
>
> Any ideas for the absence of the residuals variable -RES are greatly appreciated.
>
*
* 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/
*
* 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/
*
* 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/
*
* 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/