|
123456
Administrator
|
On Wed, Feb 3, 2010 at 3:03 PM, < [hidden email]> wrote:
> Marcello Pagano wrote:
> New subscribers will have to go through a screening process that will add time, hopefully less than a day, before they can subscribe. The screening process is designed to keep some, hopefully very few, people out.
>
> I'm a frequent reader of the Statalist archive but an unfrequent writer. I can't handle all this mails on my work account so I only subscribe temporarily to ask or contribute something.
>
> I don't want to cause any trouble or work with this behaviour. It would be nice to have quick subscription for people already known to majordomo if possible.
>
That seems unnecessarily complicated, why not just subscribe to the
daily digest version, one email a day that you can even choose to
filter directly to your trash if you don't want to read it.
When you ask a question you can then use one of the various archives
if you are desperate to see if someone has replied before the next
digest is due.
Or I'm sure you could temporarily change your subscription options
from digest to individual emails for the period you wish to wait for
answers to your post, then switch back to the digest afterwards.
Just a thought,
Neil
--
"... no scientific worker has a fixed level of significance at which
from year to year, and in all circumstances, he rejects hypotheses; he
rather gives his mind to each particular case in the light of his
evidence and his ideas." - Sir Ronald A. Fisher (1956)
Email - [hidden email]
Website - http://slack.ser.man.ac.uk/Photos - http://www.flickr.com/photos/slackline/*
* 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/
|
|
Dear Statalisters,
I'm just curious why running macros in forval or foreach
disappear after the loop has finished.
Example:
foreach x in 0 1 {
di "value: `x'"
}
di "value: `x'"
Following Stata 11 help for foreach and forvalues,
both commands set local macros to given values.
According to the manual locals are available
during the execution of the program or do-file
unless they are deleted or overwritten.
So it should be there, shouldn't it?
With dynamic value lists or "continue" there is some
sense in preserving the last processed value.
***
Yes, I know workarounds... ;-))
Best wishes
Stefan
*
* 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/
|
|
<>
You can put the list of values into a -local- beforehand, though, and this -local- will stick around:
*************
local mynumbers 0 1
foreach x of local mynumbers{
di "value: `x'"
}
token `mynumbers'
di `1' " " `2'
*************
If Stata did make it through the loop, the max of these values must be the endpoint, i.e. the value that was last assumed by `x'...
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [hidden email] [mailto: [hidden email]] Im Auftrag von [hidden email]
Gesendet: Mittwoch, 24. Februar 2010 15:28
An: [hidden email]
Betreff: st: Macro dissapears after forval or foreach
Dear Statalisters,
I'm just curious why running macros in forval or foreach
disappear after the loop has finished.
Example:
foreach x in 0 1 {
di "value: `x'"
}
di "value: `x'"
Following Stata 11 help for foreach and forvalues,
both commands set local macros to given values.
According to the manual locals are available
during the execution of the program or do-file
unless they are deleted or overwritten.
So it should be there, shouldn't it?
With dynamic value lists or "continue" there is some
sense in preserving the last processed value.
***
Yes, I know workarounds... ;-))
Best wishes
Stefan
*
* 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/
|
|
> Is it possible to get a map only with the districts?
that the coordinates file includes the coordinates
for the municipalities (i.e. at a more disaggregated level than districts).
District shapefiles should be available for many countries,
perhaps even for free.
They can be converted via shp2dta.
Otherwise I see no direct way to tell which parts
of municipality polygons belong to district borders.
District borders may be "irregular" (holes, islands).
Also coordinates of municipalities might not be exact
so analysis of the polygon net might be difficult.
It's not impossible but I don't see a quick solution for this
Stefan Gawrich
*
* 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/
|
|
Stefan's good question remains unanswered. It's true that the index of a -forval- or -foreach- loop disappears when the loop ends.
The rationale for ending it is, presumably, that its rationale has ended.
I would agree with any suggestion that this should be (better) documented, as on the face of it this feature is an exception to the general rules about locals, or at least an extra detail not obviously explicit.
In practice, at least in my experience, it is rare that one has any use for the index outside the loop, so this feature has not (often?) been flagged before.
The general implication -- for the exceptions to that -- is that one must save a copy within the loop, as was presumably clear to Stefan. Something like Martin's procedure would often work except that
1. it would often require more effort to get at the last of any list
2. the -continue, break- command could be used to exit legally from a loop prematurely, and that would need separate attention.
So, in general, copy any loop index you want later within the loop and just before you exit.
Nick
[hidden email]
Martin Weiss
You can put the list of values into a -local- beforehand, though, and this -local- will stick around:
*************
local mynumbers 0 1
foreach x of local mynumbers{
di "value: `x'"
}
token `mynumbers'
di `1' " " `2'
*************
If Stata did make it through the loop, the max of these values must be the endpoint, i.e. the value that was last assumed by `x'...
[hidden email]
I'm just curious why running macros in forval or foreach
disappear after the loop has finished.
Example:
foreach x in 0 1 {
di "value: `x'"
}
di "value: `x'"
Following Stata 11 help for foreach and forvalues,
both commands set local macros to given values.
According to the manual locals are available
during the execution of the program or do-file
unless they are deleted or overwritten.
So it should be there, shouldn't it?
With dynamic value lists or "continue" there is some
sense in preserving the last processed value.
***
Yes, I know workarounds... ;-))
*
* 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/
|
|
Martins solution is perfectly right.
I want to add a very basic solution.
What you need for that task is
- a macro with all vars to cycle through and
- an index to decide if the actual var should be altered or not.
ds (resp. ds2 or ds3) is great to list vars based on different attributes but not necessary here because you can use "*" or "_all".
foreach var of varlist * {
local i = `i' + 1
if mod(`i'-1,3)== 0 rename `var' yes__`var'
}
Local i counts the loops/variables processed.
mod(`i',3) is 0 for i = 0,3,6,9,...
=> mod(`i'-1,3) is 0 for `i' = 1,4,7,...
Stefan Gawrich
*
* 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/
|
|
<>
" ds (resp. ds2 or ds3) is great to list vars based on different attributes but not necessary here because you can use "*" or "_all"."
That depends on the kind of transformation you have in mind. If it applies to all vars without exception, then this is a viable strategy. Most of the time, you want separate things done to strings and numeric vars, though...
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [hidden email] [mailto: [hidden email]] Im Auftrag von [hidden email]
Gesendet: Mittwoch, 3. März 2010 10:40
An: [hidden email]
Betreff: st: AW: Reference column without knowing variable name?
Martins solution is perfectly right.
I want to add a very basic solution.
What you need for that task is
- a macro with all vars to cycle through and
- an index to decide if the actual var should be altered or not.
ds (resp. ds2 or ds3) is great to list vars based on different attributes but not necessary here because you can use "*" or "_all".
foreach var of varlist * {
local i = `i' + 1
if mod(`i'-1,3)== 0 rename `var' yes__`var'
}
Local i counts the loops/variables processed.
mod(`i',3) is 0 for i = 0,3,6,9,...
=> mod(`i'-1,3) is 0 for `i' = 1,4,7,...
Stefan Gawrich
*
* 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/
|
|
Hi Statalisters,
Friedhelm Huebler wrote:
-line price price- is easy but depending on the resolution of the
display the line will not appear entirely straight. The appearance
also depends on how the data are sorted. -function- with the option
n(2) yields a cleaner graph. The setting of the range can be
automated.
. sysuse auto, clear
. sum price, meanonly
. local xmin = r(min)
. local xmax = r(max)
. twoway (scatter weight price) (function y=x, range(`xmin' `xmax')
n(2)), aspect(1)
****
I think, - twoway lfit - is best in this case:
// Line from min to max:
. twoway scatter weight price || lfit price price, aspect(1) range(. .) n(2)
// Line from 0 to max:
. twoway scatter weight price || lfit price price, aspect(1) range(0 .) n(2)
The "range" option of - lfit - is more versatile.
Friedhelm Hueblers "n(2)" trick works with - lfit -
Regards
Stefan Gawrich
HLPUG
Dillenburg
Germany
*
* 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/
|
|
Friedrich's point about sorting is correct but was precisely the reason I spelled out use of the -sort- option too in my original post. That got dropped some way along the thread.
I don't know about Stefan's proposal. One reaction is that you don't need Stata to do a regression to get a line y = x. On the other hand, Stata is very fast at regression, and it wouldn't surprise me vastly if this were faster. After all, my guess is that -twoway function- doesn't necessarily include any machinery to recognise simple functions and draw them directly. And -line- through the data is looking at all the data.
However, there is yet another way to do it:
. sysuse auto
. scatter weight price || scatteri 0 0 15000 15000, recast(line)
Nick
[hidden email]
Stefan Gawrich [edited]
I think - twoway lfit - is best in this case:
// Line from min to max:
. twoway scatter weight price || lfit price price, aspect(1) range(. .) n(2)
// Line from 0 to max:
. twoway scatter weight price || lfit price price, aspect(1) range(0 .) n(2)
The "range" option of - lfit - is more versatile.
Friedrich's n(2)" trick works with - lfit -
Friedrich Huebler
-line price price- is easy but depending on the resolution of the
display the line will not appear entirely straight. The appearance
also depends on how the data are sorted. -function- with the option
n(2) yields a cleaner graph. The setting of the range can be
automated.
. sysuse auto, clear
. sum price, meanonly
. local xmin = r(min)
. local xmax = r(max)
. twoway (scatter weight price) (function y=x, range(`xmin' `xmax')
n(2)), aspect(1)
*
* 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/
|
|
Nick's proposal can be modified to avoid having to specify the precise
coordinates of the line, an issue addressed by Dave earlier in this
thread. I assume that the line always start at the origin.
. sysuse auto
. sum weight, meanonly
. local max = r(max)
. sum price, meanonly
. if r(max) > `max' {
local max = r(max)
}
. scatter weight price || scatteri 0 0 `max' `max', recast(line) name(a)
. scatter price weight || scatteri 0 0 `max' `max', recast(line) name(b)
Friedrich
On Mon, Mar 15, 2010 at 8:06 AM, Nick Cox < [hidden email]> wrote:
> [...]
>
> However, there is yet another way to do it:
>
> . sysuse auto
>
> . scatter weight price || scatteri 0 0 15000 15000, recast(line)
*
* 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/
|
|
Those paid by the reciprocal of the number of code lines written will be
interested in this shortened version.
. sysuse auto
. sum weight, meanonly
. local max = r(max)
. sum price, meanonly
. local max = max(`max', r(max))
. scatter weight price || scatteri 0 0 `max' `max', recast(line) name(a)
. scatter price weight || scatteri 0 0 `max' `max', recast(line) name(b)
It could be shortened further, but inelegance starts to escalate.
Nick
[hidden email]
Friedrich Huebler
Nick's proposal can be modified to avoid having to specify the precise
coordinates of the line, an issue addressed by Dave earlier in this
thread. I assume that the line always start at the origin.
. sysuse auto
. sum weight, meanonly
. local max = r(max)
. sum price, meanonly
. if r(max) > `max' {
local max = r(max)
}
. scatter weight price || scatteri 0 0 `max' `max', recast(line) name(a)
. scatter price weight || scatteri 0 0 `max' `max', recast(line) name(b)
On Mon, Mar 15, 2010 at 8:06 AM, Nick Cox < [hidden email]> wrote:
> [...]
>
> However, there is yet another way to do it:
>
> . sysuse auto
>
> . scatter weight price || scatteri 0 0 15000 15000, recast(line)
*
* 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/
|
|
The best way to apologise is to give it.... Still tua culpa, if not tua
maxima culpa.
Nick
[hidden email]
Ricardo Ovaldia
Thank you Nick.
I am sorry for not providing the full reference. mea culpa.
-- On Mon, 3/15/10, Nick Cox < [hidden email]> wrote:
> From: Nick Cox < [hidden email]>
> Subject: st: RE: Post-Hoc test for Kruskal Wallis
> To: [hidden email]
> Date: Monday, March 15, 2010, 11:22 AM
> . findit Kruskal
>
> turns up what there is. -findit- is a variant on -search-,
> recommended
> to you in the last thread you started.
>
> Minimal name (year) references are deprecated on this list.
> But the
> procedure recommended in that book is almost certainly
> highly
> programmable.
Ricardo Ovaldia
> Is there a Post-Hoc test for Kruskal Wallis in Stata?
> Something like the one proposed by Sokal and Rohlf (1995).
*
* 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/
|
|
Mea maxima culpa. Here it is:
Sokal, R. R. and F. J. Rohlf. 1995. Biometry: the principles and practice of statistics in biological research. 3rd edition. W. H. Freeman and Co.: New York.
Ricardo
Ricardo Ovaldia, MS
Statistician
Oklahoma City, OK
--- On Mon, 3/15/10, Nick Cox < [hidden email]> wrote:
> From: Nick Cox < [hidden email]>
> Subject: RE: st: RE: Post-Hoc test for Kruskal Wallis
> To: [hidden email]
> Date: Monday, March 15, 2010, 11:31 AM
> The best way to apologise is to give
> it.... Still tua culpa, if not tua
> maxima culpa.
>
> Nick
> [hidden email]
>
>
> Ricardo Ovaldia
>
> Thank you Nick.
> I am sorry for not providing the full reference. mea
> culpa.
>
> -- On Mon, 3/15/10, Nick Cox < [hidden email]>
> wrote:
>
> > From: Nick Cox < [hidden email]>
> > Subject: st: RE: Post-Hoc test for Kruskal Wallis
> > To: [hidden email]
> > Date: Monday, March 15, 2010, 11:22 AM
> > . findit Kruskal
> >
> > turns up what there is. -findit- is a variant on
> -search-,
> > recommended
> > to you in the last thread you started.
> >
> > Minimal name (year) references are deprecated on this
> list.
> > But the
> > procedure recommended in that book is almost
> certainly
> > highly
> > programmable.
>
> Ricardo Ovaldia
>
> > Is there a Post-Hoc test for Kruskal Wallis in Stata?
> > Something like the one proposed by Sokal and Rohlf
> (1995).
>
> *
> * 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/
|
123456
|