Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: error in custom lincom program


From   [email protected]
To   [email protected]
Subject   st: error in custom lincom program
Date   Fri, 3 Oct 2003 22:17:55 -0400





Dear Statalisters,

I am trying to make linear combinations of variables after a regression.  I
need
to save the estimated linear combs and the variance matrix for later
hypothesis testing,
so I can't just use lincom - it doesn't save results in enough detail.

I don't understand what is wrong with this code:

/* program snippet for manual lincom */
#delimit ;
capture program drop coefdiff;
program define coefdiff;
  args prefix yst yend;

  constraint drop _all;
  local count=0;
  for each 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;

Here's my log:

. coefdiff bach 1985 1990
invalid syntax
r(198);

. set trace on

. coefdiff bach 1985 1990
- args prefix yst yend
- constraint drop _all
- local count=0
- for each y of numlist `yst' / `yend' {
- if _caller()<6 {
  for5_0 `0'
  exit
  }
- version 6.0
- gettoken piece cmd: 0, parse(" :") quotes
- while `"`piece'"' != ":" & `"`piece'"' != "" {
- local for `"`for' `piece'"'
- gettoken piece cmd: cmd, parse(" :") quotes
- }
- while `"`piece'"' != ":" & `"`piece'"' != "" {
- local for `"`for' `piece'"'
- gettoken piece cmd: cmd, parse(" :") quotes
- }
- while `"`piece'"' != ":" & `"`piece'"' != "" {
- local for `"`for' `piece'"'
- gettoken piece cmd: cmd, parse(" :") quotes
- }
- while `"`piece'"' != ":" & `"`piece'"' != "" {
- local for `"`for' `piece'"'
- gettoken piece cmd: cmd, parse(" :") quotes
- }
- while `"`piece'"' != ":" & `"`piece'"' != "" {
- local for `"`for' `piece'"'
- gettoken piece cmd: cmd, parse(" :") quotes
- }
- while `"`piece'"' != ":" & `"`piece'"' != "" {
- local for `"`for' `piece'"'
- gettoken piece cmd: cmd, parse(" :") quotes
- }
- while `"`piece'"' != ":" & `"`piece'"' != "" {
- local for `"`for' `piece'"'
- gettoken piece cmd: cmd, parse(" :") quotes
- }
- while `"`piece'"' != ":" & `"`piece'"' != "" {
- local for `"`for' `piece'"'
- gettoken piece cmd: cmd, parse(" :") quotes
- }
- while `"`piece'"' != ":" & `"`piece'"' != "" {
  local for `"`for' `piece'"'
  gettoken piece cmd: cmd, parse(" :") quotes
  }
- if `"`piece'"' != ":" {
- error 198
invalid syntax
  }
r(198);

.

Thanks in advance!

--Alex Cavallo
Lexecon

*
*   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