Bookmark and Share

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   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Overwritten?
Date   Sat, 4 Jan 2014 18:17:24 +0000

<>

As Steve underlines, there is really no doubt about this. The claim in
the help file is quite explicit but -sroot- in practice does not
honour the claim. This was all established in an earlier thread.

I wouldn't wait for anything to happen w.r.t. the Stata Journal. SJ
14(1) won't be out before late March, which is the next possible date
for an update.

Nick
[email protected]


On 4 January 2014 16:38, Steve Samuels <[email protected]> wrote:
> Well, I am sure that -sroot- purports to support -if-, because the -help- document
> says that the syntax is:
>
> "sroot varname [if] [in] [, options]"
>
>
>
> Steve
>
>
> On Jan 4, 2014, at 11:20 AM, Francis, Richard N wrote:
>
> Nick,
>
> Thank you for your insight and patience.
>
> I'm not sure that -sroot- "purports to support -if-" .... however, it may well do so.
>
> Just wanted to offer some pause before you contact the author of -sroot- .
>
> Thanks again for your patience.
>
> Rick Francis
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
> Sent: Saturday, January 04, 2014 2:50 AM
> To: [email protected]
> Subject: Re: st: Overwritten?
>
> <>
>
> For anyone lost but trying to follow, the problems here arise partly because -sroot- (SJ) purports to support -if-, but does not. As an Editor of the Stata Journal, I will write to the author myself and request a bug fix, but private correspondence with the author will necessarily remain private.
>
> Otherwise this post is very puzzling. Steve Samuels took your problem and, in essence,  solved it. You thanked him for his contribution. His solution was in the same direction as my suggestion, but much better in giving a code sketch and in showing that multiple -save-s are not necessary.
>
> His post
>
> http://www.stata.com/statalist/archive/2013-12/msg00939.html
>
> remains what you should be working with.
>
> His approach can be extended to saving scalars from each regression as you were also doing.
>
> Putting together some of his code and some of yours
>
> clear
> save dhold, emptyok replace
>
> forval i = 1/`limit' {
>
>        display "Iteration of `i' of `limit"
>        use yourdata if id ==`i', clear
>        sroot fcf , residuals(res)
>        gen which = "`: label (id) `i''"
>        foreach v in Z14 Z24 Z34 Z4t Z3t Z2t Z1t {
>                  gen `v' = r(`v')
>        }
>        append using dhold
>        save dhold, replace
> }
>
> This remains a sketch. The combined dataset will repeat the -Z*- scalars but that is soluble (e.g. with -collapse-).
>
> Nick
> [email protected]
>
> On 4 January 2014 03:01, Francis, Richard N <[email protected]> wrote:
>> Nick,
>>
>> I asked the author of the user-written program -sroot- to kindly make a revision to his program, but he declined.
>>
>> Previously, you suggested that I "would need to -save- the dataset you create each time and then -append- them all."
>>
>> I included your previous message in part below to help refresh your memory:
>>
>>> 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.
>>
>> My question is this: within the loop below, how would I go about saving the datasets each time?
>>
>> forval i = 1/`limit' {
>>         display "Iteration of `i' of `limit"
>>         replace which = "`: label (id) `i''" in `i'
>>         srootfix fcf if id == `i' , residuals(rez)
>>         qui foreach v in Z14 Z24 Z34 Z4t Z3t Z2t Z1t {
>>                replace `v' = r(`v') in `i'
>>         }
>> }
>>
>> I think I can merge the resulting datasets, just no clue how to save them within a loop.
>>
>> Grateful for any direction you may suggest.
>>
>> Thank  you,
>>
>> Rick
>>
>> *
>> *   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/

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index