Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: STATA won't read command


From   Sergiy Radyakin <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: STATA won't read command
Date   Thu, 6 Mar 2014 21:19:24 -0500

Patrick, the answer to your question is 'yes':

clear all

sysuse nlsw88
rename south region

generate meanwage = .
by region, sort: gen pid = _n

summarize pid

quietly forvalues i = 1/`r(max)' {
         generate include = 1 if pid != `i'
         egen work = mean(wage*include), by(region)
         replace meanwage = work if pid == `i'
         drop include work
}

Just use the correct closing quotes. Stata 13 will indicate that with
syntax highlighting.

Best regards, Sergiy Radyakin

PS: not sure how your question relates to the earlier posting. Start a
new thread if not related.


On Thu, Mar 6, 2014 at 8:53 PM, Mason, Patrick <[email protected]> wrote:
> I use STATA/SE 13.1 for Windows (64 bit x86-64)
>
> The code appended below works fine on a small hypothetical sample. I manually enter the data, then copy the code from a Microsoft Word .doc file and past the commands directly into STATA's command window. The commands execute without a problem.
>
> I place these same commands inside a .do file. I call the do file in STATA and the commands do not work!
>
> I get the following message.
>
> quietly forvalues i = 1/`r(max)' {
> invalid syntax
> r(198);
>
> Is there a way to save the .do so that the forvalues command will execute?
>
> thanks, plmason
>
> generate meanwage = .
>
> by region, sort: gen pid = _n
>
> summarize pid
>
> quietly forvalues i = 1/`r(max)' {
>          generate include = 1 if pid != `i'
>          egen work = mean(wage*include), by(region)
>          replace meanwage = work if pid == `i'
>          drop include work
> }
>
>
> ________________________________________
> From: [email protected] [[email protected]] on behalf of Z. Liu [[email protected]]
> Sent: Thursday, March 06, 2014 8:45 PM
> To: [email protected]
> Subject: st: Fwd: -cmp- not concave
>
> Dear all,
>
> I've been trying to fit a bivariate tobit model using the user-written
> command -cmp-. The model looks like this:
>
> cmp (equation1: y1 = X1) (equation2: y2 = y1 + X2), indicators(2 2)
> robust
>
> This model doesn't work out. Stata keeps showing 'log pseudolikelihood =
> 0 (not concave)'. I tried to start with minimum regressors (1-2
> explanatory variables) in each equation, but the problem remains. I also
> tried alternative ml options such as - tech(dfp)- and -difficult- but
> still can't fix it. However, the two tobit equations can be estimated
> separately, although the Pseudo R2 is quite small (around 5%). As well,
> the system model
> can be estimated if I change the two tobit equations into linear
> equations. Some descriptive statistics of the two dependent variables
> are as follows:
>
> y1: Percentiles: 1% (0), 25% (0), 50% (23.57), 99% (6127.14); mean
> (365.00); SD (1186.90); Skewness (7.14); Kurtosis (71.23)
>
> y2: Percentiles: 1% (0), 50% (0), 75% (0), 90% (78.10), 99% (1128.53);
> mean (61.29); SD (401.82); Skewness (13.27); Kurtosis (217.49)
>
> Anybody out there knows what might be the problem? Any advice or
> suggestions
> would be appreciated. Thanks a lot in advance.
>
>
> Best Regards,
>
>
> Leo
>
>
> *
> *   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/
>
> *
> *   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/
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index