Question

I would like to estimate the following function by nonlinear 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 since it is the same software/solver as they used in the paper I am replicating and because it should be easier to do than using GAMS, for example.

My problem is that I cannot find any way to write out the sum part of the equation above. In my data all i's have are a single observation with the values for the j's in separate variables. I could write out the whole expression in the following manner (for three observations/i's):

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 a simple way to tell Stata to sum over an expression/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))))
Was it helpful?

Solution

There is no direct equivalent in Stata of the GAMS notation you cite, but you could do this

forval j = 1/3 {
    local call `call' S_over_H_`j'^({alpha2}) * exp({alpha3} * distance_`j')
}

nl (ln_wage = {alpha0} + {alpha1} * ln(`call')

P.S. please explain what GAMS is.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top