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: how to program an equivalent of "egen mean" for an equation
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: how to program an equivalent of "egen mean" for an equation
Date
Tue, 30 Apr 2013 14:41:37 +0100
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
[email protected]
On 30 April 2013 14:15, Francesca Colantuoni <[email protected]> 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/