Statalist The Stata Listserver


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

st: RE: mata error - subexp


From   Jesper Kj�r Hansen <[email protected]>
To   <[email protected]>
Subject   st: RE: mata error - subexp
Date   Fri, 2 Jun 2006 15:40:53 +0200

> 
> This is an excerpt from a mata program:
> 
> 	for (i=k; i<=n; i++) {
> 		if (c[i,i] > ep) {
> 			cii = sqrt(max(c[i,i],0))
> 			if (i > 1) {
> 				s = [|i,1\k-1|]*y[|1\k-1|]
> 			}
> 			ai = (a[i] - s)/cii
> 			bi = (b[i]-s)/cii
> 			de = normal(bi) - normal(ai)
> 			if (de <= dem ) {
> 				ckk = cii; dem = de; am = ai; 
> bm = bi; im = i;
> 			}
> 		}
> 	}
> 
> When I run it though I get the following error:
> 
> nothing found where subexp expected
> 
> Does anyone know what this means and where the error may lie?
> 

I think it might be your use of square brackets in the line

    s = [|i,1\k-1|]*y[|1\k-1|]

Maybe it should have been

    s = s[|i,1\k-1|]*y[|1\k-1|]

or something like that. 

Otherwise, I don't think square brackets are allowed to be used to separate elements
of a mathematical expression... use normal brackets instead.

: x = 1,2,3,4

: x
       1   2   3   4
    +-----------------+
  1 |  1   2   3   4  |
    +-----------------+

: s = [x:*2]
nothing found where subexp expected
r(3000);

: s = (x:*2)

: s
       1   2   3   4
    +-----------------+
  1 |  2   4   6   8  |
    +-----------------+

: 

- Jesper K. Hansen

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