Comments (7)
Thank you! That solves my issue with unstable identification/inability to identify.
from comp-econ-sp19.
Ah I see what I did wrong now, thank you!
from comp-econ-sp19.
Also stuck on Q1. My approach:
def foc(l_i_t):
return (.7 * np.exp(gamma_i + rho*w_i_tminus1 + .7*l_i_t + .3 * k_i_t + .5 * sigma2epsilon) - np.exp(l_i_t + w_i_t))
l_star = scipy.optimize.fsolve(foc,np.ndarray([1]))[0]
(also tried l_star = scipy.optimize.fsolve(foc,8)[0])
but the estimates I'm getting are unstable - every time I run the code, even with the same initial guess, I'm getting different answers. Is this an issue with the way I've set up the call of scipy.optimize.fsolve?
from comp-econ-sp19.
Hi @erineidschun . Your error means that your variables is not a number, but a sequence
. That is, it's maybe a list, tuple, numpy.ndarray
, etc.
Another issue, is that your first-order condition is not right. The equation that you have coded is the analytical solution for labor. The first-order condition is the one that starts looks like this:
[βππ‘:].7exp(πΎπ+πππ,π‘β1+.7βππ‘+.3πππ‘+12π2π)βexp(βππ‘+π€ππ‘)=0.
from comp-econ-sp19.
@richard-archer . This is a good point to bring up. Because of the shape of the FOC, the default algorithm for fsolve
has trouble when the initial value is too low. We can maybe see this by exploring the shape of the FOC. Here's some code to do it:
import ipywidgets
def plot_foc(gamma_i = 1.0, L_omega_it = -1.0, k_it = 1.0, w_it = -1.):
'''
Produce a plot of the foc and the zero line.
'''
f = lambda l: .7 * np.exp(gamma_i + rho * L_omega_it + .7 * l + .3 * k_it + .5 * (sigma2epsilon)) - np.exp(l + w_it)
vf = np.vectorize(f)
labor = np.linspace(-2,10,100)
plt.plot(labor, vf(labor))
plt.plot(labor, 0*labor)
plt.ylim([-1,3])
plt.xlabel('labor')
plt.ylabel('foc(labor) = 0');
ipywidgets.interact(plot_foc);
It produces something that looks like this:
My suggestion is to just use a very large value for the initial labor value. I use 50.0.
from comp-econ-sp19.
On another note, I am having a problem with the fixed effects model in Q8:
df2 = df.dropna()
reg_fixedeff = linearmodels.PanelOLS.from_formula("y ~ a + l + k + w + EntityEffects + TimeEffects", data=df2)
reg_fitted = reg_fixedeff.fit()
reg_fitted
my regression summary indicates that l and k are 100% accurately estimated (had the exact coefficients), so I think I may have done something wrong in gathering df, where
df = create_DF(all_data) <--- your given code.
from comp-econ-sp19.
Ok. Don't include a
. This is meant to be unobserved. Check the rest of your regressors too. I have limited connectivity, so I can't check this out for sure.
from comp-econ-sp19.
Related Issues (20)
- mle_args HOT 1
- Dealing with NaN Values HOT 3
- Correct Queries, Consistent Issues Running Database HOT 1
- Optimizer not working but generating correct log-likelihood values HOT 1
- Kaggle Not Running HOT 1
- wrong value for Q1 HOT 3
- Ari's monday office hours HOT 1
- Difference between value function and policy function HOT 1
- McCall Wage Values HOT 2
- Typo in HW 7
- HW7 eatCake graphs & output HOT 1
- McCall Modification HOT 1
- EatCake Problem 1 HOT 3
- Replicate Bresnahan Reiss-1991 Solutions Question HOT 1
- issue with HW7 Q5 HOT 1
- Final Review HOT 1
- Using opt.minimize on discrete data HOT 3
- Questions for Bresnahan HW HOT 1
- office hours today HOT 1
- MLE for Bernoulli distribution HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from comp-econ-sp19.