Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hello ! Problems in setting up Maximum Likelihood Estimation of Fixed Effects Linear Regression Model via Optimize routine on Mata

    Hello,

    I have a bit of a silly problem in setting up Maximum Likelihood Estimation of Fixed Effects Linear Regression Model via Optimize routine on Mata, with the corresponding (Gaussian) log-likelihood being (in a simplified setting):

    L = - NT / 2 * ln(sigma) - (1/sigma)*( y_h - x_h*beta' )'*( y_h - x_h*beta')

    Where y_h and x_h are within-transformed variables from individual and time Fixed Effects inclusion and sigma is variance of IID disturbance term. However running estimating the above specification via the following routine on Mata:

    mata

    // UnConcentrated Log Likelihood Gaussian with Fixed and Time Effects

    void spml_1_UN(todo, b, lnf,g,H)
    {
    external ya, xa, id
    paninfo = panelsetup(id,1)
    npanels = rows(paninfo)
    t = mean(paninfo[,2]-paninfo[,1]:+1)
    sigma = b[1]
    beta = b[2..cols(xa)+1]
    // Fixed Effects Within transformation Operator
    i = J(t,1,1)
    M0 = I(t) - (1/(t))*i*i'
    //End
    //Time Effects Within Transformation Operator
    T = I(npanels) - (1/npanels)*(J(npanels,1,1)*J(npanels,1,1)')
    //End
    ya1 = colshape(colshape(ya,t)*M0,1)
    xa1 = J(npanels*(t),cols(xa),0)
    for (k = 1; k <= cols(xa); k++) {
    xa1[,k] = colshape(colshape(xa[,k],t)*M0,1)
    }
    ya2 = colshape(T*colshape(ya1,t),1)
    xa2 = J(npanels*t),cols(xa1),0)
    for (k = 1; k <= cols(xa); k++) {
    xa2[,k] = colshape(T*colshape(xa1[,k],t),1)
    }
    lnf = - (npanels*t)/2*ln(sigma) - 1/(2*sigma)*(ya2 - xa2*beta')'*(ya2 - xa2*beta')
    }

    real function rho1_1_UN(xa){
    S = optimize_init( )
    optimize_init_evaluator(S, &spml_1_UN())
    optimize_init_which(S,"max")
    optimize_init_evaluatortype( S, "gf0")
    optimize_init_params(S, (J(1,1+cols(xa),0)) )
    optimize_init_singularHmethod(S, "hybrid")
    optimize_init_conv_maxiter(S, 100)
    optimize_init_technique(S, "nr")
    //optimize_init_tracelevel(S, "none")
    //optimize_init_conv_warning(S, "off")
    a = optimize(S)
    return(a)
    }

    end

    Unfortunately the above routine consistently gives me the following message : initial values not feasible. Any help would be most welcome. While yes there are closed form estimators for the paramters above, however I would like to successfuly estimate the full unconcentrated log-likelihood.
Working...
X