jmbejara / comp-econ-sp19

Main Course Repository for Computational Methods in Economics (Econ 21410, Spring 2019)
48 stars 26 forks source link

Replicate Bresnahan Reiss-1991 Solutions Question #71

Open richard-archer opened 5 years ago

richard-archer commented 5 years ago

The solutions for Q7 mentioned that:

"These constraints puts constraints on the parameter values. You will need to write a separate constraint function for each equality in each particular hypothesis to implement these constraints. This constraint function will be passed on to the optimizer."

Since each s_i is itself a function of N and S_i, which is itself a function of theta, how would we go about writing a log likelihood function that enforces a given constraint?

jmbejara commented 5 years ago

Hi @richard-archer . I wouldn't so much write a log-likelihood function that enforces the constraint (though you could do that) as write a separate constraint to feed into the optimizer.

When you say, write a log-likelihood function that enforces the constraint, I think you mean substituting the constraint into the log-likelihood function. This seems difficult in this case. Instead, you can write a function for s_n and then write function that represents sn - s{n+1}. The function for sn - s{n+1} should be equal to zero if the constraint holds. Feed this into the optimizer: https://docs.scipy.org/doc/scipy/reference/tutorial/optimize.html#constrained-minimization-of-multivariate-scalar-functions-minimize