Hello -
I'm trying to write a program that will use clustering on a variable by
default, but also give the user the option to turn it off or to cluster on
a different variable. The problem is that including both "cluster(varname)"
and "nocluster" in the syntax definition results in the cluster option not
being stored.
For example:
program define regress2
syntax varlist [if] [in] [aw fw iw/] [, cluster(passthru) nocluster ]
...
if "`cluster'"=="nocluster" {
reg yvar xvars
}
else if "`cluster'"=="" {
reg yvar xvars, cluster(foriegn)
}
else {
reg yvar xvars, `cluster'
}
end
This will default to cluster(foreign) regardless of whether a
cluster(varname) option is passed:
webuse auto, clear
regress2 price mpg rep78 --> program clusters on foreign
regress2 price mpg rep78, cluster(make) --> program clusters on foreign
regress2 price mpg rep78, nocluster --> no clustering is used
the second command should cluster on make instead of on foreign.
Any thoughts or recommendations? I could change nocluster to clusteroff or
something, but that wouldn't be in keeping with stata syntax convention.
Thanks,
Nick
~nap
*
* 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/