Dear Statalisters,
I am trying to use the constraint command to define constraints for linear
combinations of coefficients in a linear regression model. I want to do
some matrix algebra to compute tests of equality on these combinations. I
am having trouble with makeCns. I wrote a program that imposes my
constraints using constraint define, but when I issue the makeCns command,
I get the message: r(301) Last estimates not found. [check this]
Here's my code:
#delimit ;
capture program drop hsddiff;
program define hsddiff;
args prefix yst yend;
local count=0;
foreach y of numlist `yst' / `yend' {;
local count = `count' + 1;
if `y' == 1984 {;
constraint define `count' `prefix'__`y' ;
};
else {;
constraint define `count' `prefix'__`y' - hsd__`y' ;
};
};
constraint li;
matrix makeCns 1-`count';
matrix r=get(Cns);
scalar cols=colsof(r)-1;
scalar rows=rowsof(r);
matrix R=r[.,1..cols];
scalar cols=cols+1;
matrix q=r[1..rows,cols];
matrix v=e(V);
matrix b=e(b)';
matrix coefdiff=R*b;
matrix coefvar=R*v*R';
matrix matrix vv=vecdiag(coefvar);
end;
reg lnw black__* other__* female__* blackfem__* otherfem__*
age__* agesq__*
divsepwid__* married__* fnumper__* foklt18__*
inmsa__* hmetrodum__*
dropout__*
$hsd
somecoll__* bach__* grad__*
[pweight=wgt] , robust;
parmest, saving(wtall,replace);
hsddiff bach 1980 1989;
here's my log:
. reg lnw black__* other__* female__* blackfem__* otherfem__*
> age__* agesq__*
> divsepwid__* married__* fnumper__* foklt18__*
> inmsa__* hmetrodum__*
> dropout__*
> $hsd
> somecoll__* bach__* grad__*
> [pweight=wgt] , robust;
(sum of wgt is 1.0516e+09)
Regression with robust standard errors Number of obs =
697670
F(178,697491) =
1756.36
Prob > F =
0.0000
R-squared =
0.3450
Root MSE =
.63906
------------------------------------------------------------------------------
| Robust
lnw | Coef. Std. Err. t P>|t| [95% Conf.
Interval]
-------------+----------------------------------------------------------------
black__1980 | -.2187249 .0124757 -17.53 0.000 -.243177
-.1942729
output omitted
grad__1989 | .385969 .0492801 7.83 0.000 .2893815
.4825564
_cons | 3.805371 .0322174 118.12 0.000 3.742226
3.868516
------------------------------------------------------------------------------
. parmest, saving(wtall,replace);
file wtall.dta saved
. hsddiff bach 1980 1989;
1: bach__1980 - hsd__1980
2: bach__1981 - hsd__1981
3: bach__1982 - hsd__1982
4: bach__1983 - hsd__1983
5: bach__1984
6: bach__1985 - hsd__1985
7: bach__1986 - hsd__1986
8: bach__1987 - hsd__1987
9: bach__1988 - hsd__1988
10: bach__1989 - hsd__1989
last estimates not found
r(301);
end of do-file
r(301);
Thanks in advance!!
--Alex Cavallo
Lexecon
(312) 322-0208 voice
(312) 322-0218 fax
*
* 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/