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

From |
Dirk Enzmann <dirk.enzmann@uni-hamburg.de> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: RE: unexpected "ambiguous abbreviation" |

Date |
Wed, 27 Feb 2008 11:58:11 +0100 |

Thanks a lot, your answer has been to the point and very helpful, indeed! Dirk

Date: Tue, 26 Feb 2008 18:43:05 -0000

From: "Nick Cox" <n.j.cox@durham.ac.uk>

Subject: st: RE: unexpected "ambiguous abbreviation"

Scalars and variable names share the same name space. That is in the

manual [P] and discussed at length within

SJ-6-2 dm0019 . Stata tip 31: Scalar or variable? Problem of ambiguous

names

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . G. I.

Kolev

Q2/06 SJ 6(2):279--280 (no

commands)

tips for avoiding abbreviation conflicts with variables

when naming scalars

What you want is

tempname mu scalar `mu' = <whatever>

Similarly, it is good practice to use tempnames for all scalars within

programs, unless you have a very good reason to the contrary.

If you go

tempname mu scalar mu = <whatever>

then that is legal, but makes no use of the tempname.

If you use tempnames for all your scalars, there will be no clash

between scalar names and existing variable names, and no need to fiddle with whether variable abbreviation is on or off. In any case, note that if you have a scalar

mu and a variable name mu, then there is a clash regardless of whether

variable names can be abbreviated. In fact, I don't think you should mess with

variable abbreviation in most programs.

Nick n.j.cox@durham.ac.uk

Dirk Enzmann

Does somebody have an idea why I receive the error message "mu ambiguous

abbreviation" if the data contain variable starting with mu...? Below the result of trying to run my program "fitnb" with - set trace on - and - set tracedepth 1 -.

I thought that using "tempvar mu" followed by "scalar mu = something" would result in mu being a temporary scalar (no macro!) existing only within the call of the program fitnb.

BTW, is there a possibility to check quietly the setting of varabbrev? So that I could use "set varabbrev off" at the beginning of the program and "set varabbrev on" at the end only if it has been "on" before (so that a call to the program will never change the setting "varabbrev" outside the program)? Because to use "set varabbrev off" is an effective

workaround.

Thanks in advance,

Dirk

=====================================================================

fitnb rbinz99

- ----------------------------------------------------- begin fitnb ---

- - version 9

- - syntax [varlist] [, maxval(integer 0)]

- - tokenize `varlist'

= tokenize rbinz99

- - args x

- - tempvar x_max size mu N prob i nbdat maxfit pmisfit

- - if `maxval'==0 {

= if 0==0 {

- - local selection "if `x'<."

= local selection "if rbinz99<."

- - }

- - else {

local selection "if `x'<. & `x'<=`maxval'"

}

- - sum `x' `selection'

= sum rbinz99 if rbinz99<.

Variable | Obs Mean Std. Dev. Min Max

- -------------+--------------------------------------------------------

rbinz99 | 9081 .2542672 2.124223 0 150

- - scalar x_max = r(max)

- - quietly nbreg(`x') `selection'

= quietly nbreg(rbinz99) if rbinz99<.

- - scalar size = 1/exp(_b[/lnalpha])

- - scalar mu = exp(_b[_cons])

- - scalar N = e(N)

- - scalar prob = size/(size+mu)

mu ambiguous abbreviation

- ------------------------------------------------------- end fitnb ---

r(111);

=====================================================================

--

*************************************************

Dr. Dirk Enzmann

Institute of Criminal Sciences

Dept. of Criminology

Schlueterstr. 28

D-20146 Hamburg

Germany

phone: +49-(0)40-42838.7498 (office)

+49-(0)40-42838.4591 (Mrs Billon)

fax: +49-(0)40-42838.2344

email: dirk.enzmann@uni-hamburg.de

www: http://www2.jura.uni-hamburg.de/instkrim/kriminologie/Mitarbeiter/Enzmann/Enzmann.html

*************************************************

*

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

- Prev by Date:
**Re: st: Poisson model with interaction term** - Next by Date:
**st: RE: unexpected "ambiguous abbreviation"** - Previous by thread:
**st: xtlogit with a fractional response** - Next by thread:
**st: problem selecting results with mouse** - Index(es):

© Copyright 1996–2015 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |