Announcement

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

  • Probit estimation using MATA Optimize 'initial values not feasible'

    Hi,

    I am quite new with MATA. I am currently working on an exercise of performing probit estimation using MATA's optimize() but I keep on getting the 'initial values not feasible' error message.I have tried searching for other discussions and applied the solution from other discussions to no avail.

    Basically, I'm simulating a binary choice model
    Click image for larger version

Name:	binary choice model.png
Views:	1
Size:	5.4 KB
ID:	1571857


    and then I have to perform logit estimation of y on x similar to standard STATA probit command:
    Code:
     probit y x
    .

    This is the code that I have come up so far.. Thank you very much in advance for your help!
    Code:
    mata
    mata clear
    
    // a. Simulate Y
    
        // generate random variables
        X = rnormal(1000,1,0,1)        // X variable
        u = rnormal(1000,1,0,1)        // error term
    
        // setting up coefficients
        alpha = J(1000,1,0)        // constants
        beta  = 2                
        
        // Simulate Y*
        Y_star = alpha + beta*X + u
        
        // Simulate Y
        Y = Y_star :> J(1000,1,0)
        
        // check if the proportion of 1's is between 0.4 and 0.6
        mean_Y = mean(Y)
        mean_Y
        
    // b. estimate probit estimator
        
        // preparing probit link function
        x  = X,J(1000,1,1)
        b  = (beta,1)
        xb = x*b'
        mu = normal(xb)
        
        // define function
        void PROBIT(todo,Y,mu,f,g,H) {
            f = Y :* ln(mu) + (1 :- Y) :* ln(1 :- mu)
        }
        
        // optimization
        p = J(1,cols(X),beta)        // initial value
        S = optimize_init()    
        optimize_init_evaluator(S,&PROBIT())
        optimize_init_evaluatortype(S,"v2")
        optimize_init_technique(S,"bfgs")
        optimize_init_argument(S,1,Y)
        optimize_init_argument(S,1,X)
        optimize_init_params(S,p)
        optimize(S)
        beta_probit = optimize_result_params(S)'
        beta_probit
    
    end
Working...
X