Giter VIP home page Giter VIP logo

Comments (7)

richard-archer avatar richard-archer commented on July 18, 2024 1

Thank you! That solves my issue with unstable identification/inability to identify.

from comp-econ-sp19.

erineidschun avatar erineidschun commented on July 18, 2024 1

Ah I see what I did wrong now, thank you!

from comp-econ-sp19.

richard-archer avatar richard-archer commented on July 18, 2024

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.

jmbejara avatar jmbejara commented on July 18, 2024

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.

jmbejara avatar jmbejara commented on July 18, 2024

@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:

image

My suggestion is to just use a very large value for the initial labor value. I use 50.0.

from comp-econ-sp19.

erineidschun avatar erineidschun commented on July 18, 2024

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.

jmbejara avatar jmbejara commented on July 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.