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]

From |
Francesca Colantuoni <f.colantuoni9@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: how to program an equivalent of "egen mean" for an equation |

Date |
Wed, 1 May 2013 09:06:35 -0400 |

Oh OK. So, that's not the way to go. Thanks a lot Nick, Francesca On Tue, Apr 30, 2013 at 7:28 PM, Nick Cox <njcoxstata@gmail.com> wrote: > -egen- does not allow a -replace- option. > Nick > njcoxstata@gmail.com > > > On 30 April 2013 22:59, Francesca Colantuoni <f.colantuoni9@gmail.com> wrote: >> Thank you so much Nick! By placing a space between -egen- and `y' it >> does not give me that error. It gives me other errors >> (specifically: "option replace not allowed nlh_n6 refused query, >> rc=198"), but I'll keep on working. >> Francesca >> >> >> On Tue, Apr 30, 2013 at 9:41 AM, Nick Cox <njcoxstata@gmail.com> wrote: >>> The specific error here is that you need a space between -egen- and >>> `y'. Stata is thinking that you are referring to a program or command >>> >>> egen__00000F >>> >>> and naturally it doesn't exist. (Temporary variable names created by >>> Stata are all 8 characters long and begin with a double underscore.) >>> >>> I haven't look at the rest of your code. >>> >>> Nick >>> njcoxstata@gmail.com >>> >>> >>> On 30 April 2013 14:15, Francesca Colantuoni <f.colantuoni9@gmail.com> wrote: >>>> I am trying to program a non linear least square function using panel >>>> data. I have to create a sort of "within estimator" by having the >>>> estimation routine compute the average of the function for each value >>>> of the parameters, and such average needs to be plugged back in the >>>> original function in the following fashion: x_st-(mean)x_st=f(beta, >>>> gamma) - value_f((mean)beta,(mean)gamma) >>>> where s=market, t=time. >>>> While x_st-(mean)x_st is observed and I can compute it, I don't know >>>> how to implement the mean of the function in the routine, because I >>>> need to compute it for each estimated value of the parameters, but >>>> also for each individual (market) of the dataset, over time. I have >>>> tried this way, but obviously it does not work: >>>> >>>> program nlfrncs >>>> version 12.1 >>>> >>>> if "`1'" == "?" { >>>> global S_1 "w b_ns b_s g2_ns g2_s g3_ns g3_s" >>>> global w=0 >>>> global b_ns=-1 >>>> global b_s=-2 >>>> global g2_ns=0.5 >>>> global g2_s=0.5 >>>> global g3_ns=0.5 >>>> global g3_s=0.5 >>>> >>>> tempvar Y >>>> quietly { >>>> by market, sort: >>>> egen`Y'=mean(ln($w*exp($b_ns*price1+$g2_ns*price2+$g3_ns*price3)+(1-$w)*(y*exp($b_s*price1+$g2_s*price2+$g3_s*price3)+i*exp($b_s*price1+$g2_s*f_price2+$g3_s*f_price3)))) >>>> , replace >>>> } >>>> exit >>>> >>>> } >>>> replace `1'=ln($w*exp($b_ns*price1+$g2_ns*price2+$g3_ns*price3)+(1-$w)*(y*exp($b_s*price1+$g2_s*price2+$g3_s*price3)+i*exp($b_s*price1+$g2_s*f_price2+$g3_s*f_price3)))-`Y' >>>> end >>>> >>>> I get the error: unrecognized command: egen__00000F >>>> Any suggestion or direction will be greatly appreciated. >>>> Francesca >>>> * >>>> * 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/

**Follow-Ups**:**Re: st: how to program an equivalent of "egen mean" for an equation***From:*Nick Cox <njcoxstata@gmail.com>

- Prev by Date:
**Re: st: How to count occurrences of specific value** - Next by Date:
**st: marginal effects with interaction term gologit2** - Previous by thread:
**st: Multicollinearity/VIF using -xtlogit,re- models** - Next by thread:
**Re: st: how to program an equivalent of "egen mean" for an equation** - Index(es):