Bookmark and Share

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, is already up and running.

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

st: does the

From   Wu Zhang <>
Subject   st: does the
Date   Wed, 6 Mar 2013 21:16:44 -0800 (PST)

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 


*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index