Announcement

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

  • Using an external dataset in nl function evaluator program

    Hi,

    I am using function evaluator program for an nl command, and would like to call in an external dataset in the function evaulator program by merge command. However, whenever I put in merge command inside the function evaluator program, I get the error message

    nlauto_extdta2 returned 110
    starting values invalid or some RHS variables have missing values
    r(480);

    Here's the code I used:
    program nlauto_extdta2

    syntax varlist(min=4 max=4) [aw fw iw] if, at(name)
    local price: word 1 of `varlist'
    local cons: word 2 of `varlist'
    local x: word 3 of `varlist'
    local id: word 4 of `varlist'

    *parameters
    forvalues i = 1(1)2{
    tempname b`i'
    scalar `b`i'' = `at'[1,`i']
    }


    merge 1:1 id using autodata.dta
    assert _merge==3

    replace `x' = x `if'


    replace `price' = `b1'*`cons' + `b2'*`x' `if'


    end
    where I execute this program with the following commands:
    sysuse auto, clear

    gen id=_n
    gen x=uniform()
    keep id x
    save autodata.dta, replace

    sysuse auto, clear
    gen cons = 1
    gen id=_n
    gen x=uniform()

    matrix ivals = J(1,2,1)

    do nlauto_extdta2.do

    nl auto_extdta2 @ price cons x id, nparameters(2) initial(ivals)

    If I do not include the boldface part in the function evaluator program, the nl command would work and give me estimates, but once I include those commands, the error message appears. I would appreciate any ideas and suggestions. Thank you.

    Sincerely,
    Soo

  • #2
    Duplicate question. Please go to http://www.statalist.org/forums/foru...luator-program for discussion.

    Comment

    Working...
    X