Non-linear least squares in Stata, how to model summation over variables / sets?

I would like to evaluate the following function using non-linear least squares using Stata:

The nonlinear function i would like to estimate

I am testing the results of another papper and would like to use Stata as it is the same software / solver as they are used in the document that I am replicating and because it should be easier than using GAMS, for example.

My problem is that I can’t find a way to write the total part of the equation above. In my data, all I have is one observation with values ​​for j in separate variables. I could write the whole expression as follows (for three observations / i):

nl (ln_wage = {alpha0} + {alpha0}*log( ((S_over_H_1)^{alpha2})*exp({alpha3}*distance_1) + ((S_over_H_2)^{alpha2})*exp({alpha3}*distance_2) + ((S_over_H_1)^{alpha2})*exp({alpha3}*distance_1) )) 

Is there an easy way to tell Stata about summing expressions / variables for a given set of numbers, like in GAMS, where you can write:

 lnwage(i) = alpha0 + alpha1*ln(sum((j), power(S_over_H(i,j),alpha2) * exp(alpha3 * distance(i,j)))) 
+4
source share
1 answer

There is no direct equivalent in Stata that you quote, but you can do it

 forval j = 1/3 { local call `call' S_over_H_`j'^({alpha2}) * exp({alpha3} * distance_`j') } nl (ln_wage = {alpha0} + {alpha1} * ln(`call') 

PS please explain what is GAMS.

+5
source

Source: https://habr.com/ru/post/1502253/


All Articles