Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Weights in a functional evaluator NLLS estimation


From   "KLAUS VONDRA" <[email protected]>
To   <[email protected]>
Subject   st: Weights in a functional evaluator NLLS estimation
Date   Tue, 6 Jun 2006 17:56:58 +0200

Sorry for abusing your thread for my posting, but I have been trying to post this message for hours, but as this repeatedly did not work, I am sending my question as a reply in this thread; here is my question:


Dear List,

I have problems to include a weight matrix into a nl type LS estimation, where I am using the functional evaluator form. Relying on the Stata Manual Volume 2 (K-Q) for nl, in the subchapter "methods and formulas", I do want to change the matrix D (in my explainations of the model DELTA) from being an Identy matrix.

Here is a more comprehensive problem statement:

The program I have written is running if I ommit any commands on weights in the code. Acutally the results should be the same with a code where I include an Identity matrix as weighting matrix explicitely (see Manual). But in a second step I also need to specifiy the model using a seperately derived weighting matrix.
I have included iweights in the program and the nl estimation (as described in the help file), as I think iweights should be the type of weight I should use, however I am also not totally sure at this point. Using the matrix as a weight gives me the error message "type mismatch". This is somehow clear as I do not understand weights as stata does .. in matrix form. Hence I have included the matrix into my variable list (using svmat), but then it is of course splitted into the first and second colum of the matrix. Using both, initialweight1 and initialweight2 as weight specification of iw, gives "invalid syntax". Using only initialweight1 as weight specification gives "iweight not allowed". However both do not seem to make sense.
It would be great, if someone has some better reference in hand or can have a look on the code and give me a hint, what I have to change.

Best,
Klaus


For more concretness:


I want to estimate the following model:

(1) gamma - GAMMA*alpha = v,

where gamma is a 2 times one vector,
GAMMA is a 2 times 2 matrix,
alpha is a 2 times 1 vector of regression coefficients and
v are the vector residuals.

I now want to estimate alpha with a weighted nonlinear least squares estimator based on (1). This estimator is theoretically based on :

(2) argmin (gamma - GAMMA*alpha)' * DELTA * (gamma - GAMMA*alpha)

where DELTA is a 2 times 2 symmetrixc positive definite moments weighting matrix.

The relevant parts of the code look as follows:

program define nlequ
[iw]
if "`1'"== "?" {
global S_1 " alpha "
global alpha=1
exit
}
replace `1'=v1*$alpha + v2*$alpha^2
end

where v1 (v2) is the first (second) column of GAMMA and the estimation command is as follows:

nl equ gamma [iw=initialweight] , init(alpha=0.7)
where initialweight is my predefined 2 times 2 weighting matrix.

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index