Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Nick Cox <njcoxstata@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: does the |

Date |
Thu, 7 Mar 2013 10:47:08 +0000 |

I don't understand your guess, nor the comment that -sum- does not work here. But there is no need to guess: use set trace on set traced 1 so see where your program fails. This is illegal: forvalues i=1(1)n { Stata won't evaluate your scalar -n- is that context. This should work forval i = 1/`=n' { There may be other problems too. Nick On Thu, Mar 7, 2013 at 5:16 AM, Wu Zhang <wuzhang50@yahoo.com> wrote: > Hi folks, > > I encounter this error message : invalid syntax r(198); > My guess is that 'tabstat' with option 'save' does not work since the matrix xstat is null, but I cannot fix it; any thoughts? thanks! > > > My code is as follows: > > program ape_total, rclass > version 8 > syntax varlist(numeric) > gettoken y x : varlist /*nice way to split y and x! from Maarten*/ > > > > tabstat `x', statistics( mean p25 p50 p75 p95 ) save /*'sum' does not work here!*/ > > mat xstat=r(StatTotal) > scalar n=rowsof(xstat) > scalar m=colsof(xstat) > regress `varlist' > predict ehat, residual > mat paraest=e(b) > > > > forvalues i=1(1)n { > mat meanvalue=(xstat[i, 1...],1)*paraest' > scalar meanvalues=meanvalue[1,1] > forvalues j=1(1)m{ > scalar alpha`j'=paraest[1,j] > gen apet`i'`j'=alpha`j'*exp(meanvalues+ehat)/(1+exp(meanvalues+ehat))^2 > sum apet`i'`j' > return scalar ape`i'`j'=r(mean) > > > } > } > > drop apet* ehat > > end * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**References**:**st: does the***From:*Wu Zhang <wuzhang50@yahoo.com>

- Prev by Date:
**st: Formatting months error** - Next by Date:
**Re: st: Formatting months error** - Previous by thread:
**st: does the** - Next by thread:
**st: A layman question on model building** - Index(es):