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]

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


From   Francesca Colantuoni <[email protected]>
To   [email protected]
Subject   st: how to program an equivalent of "egen mean" for an equation
Date   Tue, 30 Apr 2013 09:15:26 -0400

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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index