Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Adding user-defined weights to a function evaluator program within the -nl- command


From   [email protected]
To   [email protected]
Subject   st: Adding user-defined weights to a function evaluator program within the -nl- command
Date   Fri, 6 Apr 2012 17:01:04 -0700 (PDT)

Hello Statalisters:

I am wondering how to add "user-defined" weights to a function evaluator program using -nl- command.

Up to this point, I have been able to incorporate user-defined weights (i.e., weights based on a variable I calculated myself) in a substitutable expression using -nl- wherein I simply specify the weight at the end of the model statement.  For example, in the model below, the relationship between teacher fixed effects [tchrFX] and a teacher's race [tchr_race] and gender [tchr_gender] are weighted by the inverse of the standard error of those fixed effects [weight=1/tchrFX_se].

nl tchrFX = tchr_race tchr_gender [weight=1/tchrFX_se], level(90) 

However, the model I am actually running is much more complicated and involves hundreds of fixed effects for schools.  Therefore, based on previous Statalist discussions and the error #130 "expression too long", I have written a function evaluator program that can handle estimating that many parameters.  However, I can't figure out how to incorporate my own weights into this program.  I do see from (from the -nl- help file) how to add "built-in" Stata weights such as the analytic [aw], frequency [fw], and importance [iw] weights.  But I can't figure how to incorporate my own user-defined weights into the function evaluator program such as in the simplified program below, for example.

program nldecay

        version 12
        syntax varlist(min=1 max=1000) if, at(name)
        local lhs   : word 1 of `varlist'
		local	x1	:	word	2	of	`varlist'
		local	x2	:	word	3	of	`varlist'

	replace `lhs' = `at'[1,1]*`x1' + `at'[1,2]*`x2' `if'
end

nl decay @ tchrFX  tchr_race tchr_gender, nparam(2) 


Any insights?


Regards,
Stephanie Liddle
[email protected]

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index