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