Statalist


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

st: RE: RE: Updating user-supplied code / mca example


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: Updating user-supplied code / mca example
Date   Tue, 7 Oct 2008 17:18:35 +0200

Further complication that came to light at the London UGM: You could have
different -version- statements for mata and Stata code within one ado
file...


HTH
Martin


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
Sent: Tuesday, October 07, 2008 5:11 PM
To: statalist@hsphsun2.harvard.edu
Subject: st: RE: Updating user-supplied code / mca example

Allan's bemusement is probably shared by several. I'll comment here
under two headings. 

The -version- command

-mca-  

The -version- command
=====================

The -version #- command is often misunderstood. Quite why is not
completely clear, but perhaps one initial summary in the on-line help 

"Set command interpreter to version #" 

creates false impressions. The other summary for -version #: <command>- 

"Execute command under version #"

is closer in flavour to what -version- does. 

Here's my take, in style more relaxed and, therefore, potentially less
accurate than the official documentation. 

First off, focus on a negative statement: 

-version- is _not_ a time machine. 

Suppose you have Stata 10. Then setting -version 9- or -version 8- does
not re-create in totality a virtual Stata 9 or Stata 8 within Stata 10.
There is only one way to re-create Stata 9 or Stata 8 in totality and
that is to fire up a copy of Stata 9 or Stata 8. The same goes for any
other version.   

What then does -version- do? 

-version- signals to those commands that care what version they are
executing under that  they may want to behave differently. 

That is, _some_ commands in Stata -- emphatically not all -- have
internal switches. The switch asks "What version am I being called
under?" and the command behaves differently depending on the answer.
(That does not always mean different output.) 

There are many reasons for this kind of switch, but all come under the
heading of making life easier for the user, principally by breaking old
code as little as possible. (The user here may well be, and often is, a
programmer or developer writing fresh code.) 
In particular, suppose StataCorp change the syntax of some command. Then
unless you have a way of signalling that you want the old-style syntax,
your code may be broken by StataCorp's change. Stata's ideal is that
this happens as rarely as possible. 

Suppose you are using Stata 9. If you are not, the principle is the
same; you just need to change the examples. Keep this supposition in
mind for the next three questions. 

1. Can you declare 

version 10 

in your programs to make use of commands written for Stata 10? 

No. 

That's the complete answer. (Some people do ask this, or logically
equivalent questions. Perhaps they have been absorbing too much sci-fi.
The people at StataCorp are very smart, but if they had mastered time
travel do you think they would still be selling statistical software?) 

2. What happens precisely if you declare 

version 9  

Nothing. 

Stata looks around and says, Well, this is Stata 9, so no difference
there. It's as if you were travelling in Britain, and someone says,
"This is Britain", and your attitude is that you knew that already. If
someone says, "This is France", or "Nous sommes en France", something
has happened, and you might want to change your behaviour, say by using
Euros not sterling. 

So, is this useless or redundant? No. Putting -version 9- in your
programs or do files is good practice for using later versions of Stata
when you upgrade, so that your tacit assumptions about syntax stability
are honoured. 

(Programs lacking a -version- statement are likely to have been written
in a hurry or by inexperienced programmers, so beware on either count.) 

3. What happens precisely if you declare 

version 8 

We've had this already. 

-version 8- signals to those commands that care whether it is version 9
(this is still the example being used) or version 8 precisely how they
should behave. This may or may not make a difference to what happens.
Even if a -version- statement is irrelevant, it does no harm. 

In principle, this difference in behaviour should be documented
somewhere, if only in old and new documentation. 

-mca-
=====

-mca- is an official command as of Stata 10. I guess Allan is using
Stata 8 or Stata 9. 
(People using out-of-date versions of Stata are asked to make that clear
in their postings.) 

In Stata 10, -search mca- yields this

[MV]    mca . . . . . . . . . . . . Multiple and joint correspondence
analysis
        (help mca)

[MV]    mca postestimation  . . . . . . . . . . . Postestimation tools
for mca
        (help mca postestimation)

Example . . . . . . . . Seminar: What's new in Stata 10: Multivariate
analysis
        . . . . . . . . . . . . . . . . . .  UCLA Academic Technology
Services
        10/07   discusses new and improved features for
                multivariate procedures
                http://www.ats.ucla.edu/stat/stata/seminars/stata10/
                multivariate.htm

STB-42  sg78  . . . . . . Simple and multiple correspondence analysis in
Stata
        (help coranal, mca if installed)  . . . . . . . . . . . .  P.
van Kerm
        3/98    pp.32--37; STB Reprints Vol 7, pp.210--217
        produces numerical results and graphical representations for
        simple and multiple correspondence analysis

This clarifies that users of Stata < 10 can read about Stata's -mca-
command on the UCLA website, and that Allan, as said, is talking about
Philippe van Kerm's -mca- command, which although it has the same name
is not the same! 

Incidentally, people changing other people's code do so entirely at
their discretion, meaning peril, as no doubt Allan would acknowledge
freely, fully and frankly. 

Nick 
n.j.cox@durham.ac.uk 
 
Allan Reese (Cefas)

I found out recently that I've been misunderstanding the version
command.  It's used in ADO files "to ensure your do-file will continue
to work with different versions of Stata", and undoes changes to
commands made in later versions.  But it doesn't prevent the use of
commands added in later versions.

The example to hand is that I'm using mca.ado: 
*! version 1.3.1 Philippe VAN KERM, February 1998  STB-42 sg78 
and wanted to update the graph plotting.  It was possible simply to
change the graph command to "twoway scatter" leaving the program to run
as "version 5".

Philippe's code:
			while `n2'<=`d' {
                               graph FDim`n2' FDim`n1', s([Flab]) /*
                                  */ b1("Multiple Correspondence
Analysis") /*
                                  */ b2("Axis `n1'") l1(" ") /*
                                  */ l2("Axis `n2'") xla yla xline(0) /*
                                  */ yline(0)  border 
				loc n2 = `n2' + 1

becomes:
			while `n2'<=`d' {
                                twoway scatter FDim`n2' FDim`n1',
msym(i) mlab(Flab) mlabpos(c) /*
                                  */ b1("Multiple Correspondence
Analysis") /*
                                  */ xti("Axis `n1'") yti("Axis `n2'")
/*
                                  */ xline(0) yline(0) `scatopt' 
				loc n2 = `n2' + 1 

The new option scatopt is a string to allow any other twoway options to
be passed through the command.  It is declared at the start of the
program:

Philippe:
loc options "d(integer 0) q(real 0) Notrans"
parse "`*'"

becomes:
* Option scatopt added Sept 2008. RAR.
loc options "d(integer 0) q(real 0) Notrans scatopt(string)"
parse "`*'"

Incidentally, are there any other mca users, and any further
developments of the code?


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/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/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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