Dear all,
I HAVE THE FOLLOWING VECTORS..WHICH I COMBINE IN A MATRIX:
mkmat Z0 Z1 Z2 Z3 Z4 Z5 Z6 Z7 Z8 Z9 Z10 Z11 Z12 Z13 Z14 Z15 Z16 Z17 Z18 Z19 Z20 Z21 Z22 Z23 Z24 Z25 Z26 Z27 Z28 Z29 Z30 Z31 Z32 Z33, matrix(M);
NEXT I FORMULATE A PROGRAM FOR NONLINEAR ESTIMATION (see below):
I DEFINE THE PARAMETER TO BE ESTIMATED AND GIVE THEM INITIAL VALUES
AT THE "replace" I HAVE DEFINED THE NON-LINEAR FUNCTION.
AT "mat def" I DEFINE A NEW MATRIX WHICH IS A FUNCTION OF THE PARAMETER OF INTEREST "C". THEN I MULTIPLY MATRICES N AND M TO GET MATRIX P; WHICH I THEN TRANSFORM IT INTO A VECTOR IN ORDER TO BE READABLE IN THE NON-LINEAR FUNCTION.
I HAVE ALSO IMPOSED A CONSTRAINT ON THE COEFFICIENTS OF "LL AND k".
FINALLY FOLLOWING "nl.." I ESTIMATE THE MODEL.
ALL THESE LOOK CORRECT. BUT WHEN I DO THE ACTUAL ESTIMATION THE COEFFICIENT "C" IS JUST A CONSTANT TERM, WHICH EQUALS 0.03 (NO STANDARD ERRORS etc), I.E. IT EQUALS THE INITIAL VALUE!
I.E....SOMETHING IS WRONG WITH "mat def N, mat def P and svmat P"...because they are not used in the estimation..at the begining the initial value 0.03 is substituted for C ...and that's it......N, P and k are calculated.
But this is not correct. Do u know how I should program it better??? Something is missing from the program and i cannot use the matrix N in the estimation.
Thank you
thanasis
program nlb6;
version 8.0;
if "`1'" == "?" {;
global S_1 "A B C D E";
mat def N=(1, 1-$C, (1-$C)^2, (1-$C)^3, (1-$C)^4, (1-$C)^5, (1-$C)^6, (1-$C)^7, (1-$C)^8, (1-$C)^9, (1-$C)^10, (1-$C)^11, (1-$C)^12, (1-$C)^13, (1-$C)^14, (1-$C)^15, (1-$C)^16, (1-$C)^17, (1-$C)^18, (1-$C)^19, (1-$C)^20, (1-$C)^21, (1-$C)^22, (1-$C)^23, (1-$C)^24, (1-$C)^25, (1-$C)^26, (1-$C)^27, (1-$C)^28, (1-$C)^29, (1-$C)^30, (1-$C)^31, (1-$C)^32, (1-$C)^33);
mat def P=M*N';
svmat P, name(k);
global A = 3;
global B = 0.7;
global C = 0.03;
global E = 0.3;
global D = 0.01;
exit ;
};
replace `1'=$A+$B*LL+$E*k+$D*time;
constraint def 1 LL=1-k;
end;
nl b6 LY, constraint (1) if time=>34;
*
* 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/