Home Forums ASREG : Rolling window and Fama-MacBeth Regressions Add constrained regression to asreg

Viewing 1 post (of 1 total)
  • Author
    Posts
  • George Ford
    Guest
    Post count: 118

    I found this online.

    sysuse auto, clear
    mata:
    void i_crit(todo,b,crit,g,H)
    {
    	external y,X,W
    	m=X'(y-X*b')
    	crit=(m'*W*m)
    }
    y = st_data(., "price")
    cons=J(rows(y),1,1)
    X = st_data(., "weight length"), cons
    W=cholinv(X'X)
    init=J(1,cols(X),0)
    S=optimize_init()
    // build the constraint matrix
    C = (1, 0, 0)
    c = (0)
    Cc = (C, c)
    optimize_init_constraints(S,Cc)
    optimize_init_evaluator(S, &i_crit())
    optimize_init_which(S,"min")
    optimize_init_evaluatortype(S,"d0")
    optimize_init_params(S,init)
    p=optimize(S)
    p
    end
    constraint 1 weight = 0
    cnsreg price weight length, constraints(1) 

    Would it be difficult to add constrained regression -asreg- ?

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.