Announcement

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

  • function evaluator program for nlsur

    Hi all,

    I am writing a function evaluator program to estimate an AIDS model with nlsur in Stata. I have several questions with -nlsur- and function evaluator program in general after I read the help file. I will use the example in the nlsur help file to state my question. The function evaluator program goes like this
    HTML Code:
                program nlsursur
    
                    version 14.2
                    syntax varlist(min=5 max=5) [if], at(name)
                    local y1: word 1 of `varlist'
                    local y2: word 2 of `varlist'
                    local x1: word 3 of `varlist'
                    local x2: word 4 of `varlist'
                    local x3: word 5 of `varlist'
    
                    // Retrieve parameters out of `at'
                    tempname b0 b1 b2 c0 c1 c2
                    scalar `b0' = `at'[1,1]
                    scalar `b1' = `at'[1,2]
                    scalar `b2' = `at'[1,3]
                    scalar `c0' = `at'[1,4]
                    scalar `c1' = `at'[1,5]
                    scalar `c2' = `at'[1,6]
    
                    // Fill in dependent variables
                    quietly replace `y1' = `b0' + `b1'*`x1' + `b2'*`x2' `if'
                    quietly replace `y2' = `c0' + `c1'*`x2' + `c2'*`x3' `if'
    
                end
    And the nlsur command to call this program is
    HTML Code:
    nlsur sur @ y1 y2 x1 x2 x3, parameters(b0 b1 b2 c0 c1 c2) initial(b0 10 c0 10)
                          nequations(2) hasconstant(b0 c0)
    First, I am wondering how the evaluator program knows which are parameters. Sure, the parameters() option tells the evaluator b0 b1 b2 c0 c1 c2 are parameters, but in the evaluator, temporary names are used for the parameter names, that is to say, `b0' in the evaluator is not necessarily b0 in the parameter() option in -nlsur-. Or does the order matter? `b0' holds the first element of the `at' matrix, and it must correspond to the first parameter specified in the parameter() option, no matter whether it is called b0 in the parameter() option. Is this understanding correct?

    Second, hasconstant(b0 c0) option specify b0 and c0 are intercpets, but they should also change during the maximization. That is, b0 and c0 change during each of the iteration, and they are just like any other parameters. So, what is the point of specifying hasconstant()?

    Thanks!
Working...
X