Statalist


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

st: Question about the syntax command


From   L S <lts40301@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Question about the syntax command
Date   Sun, 6 Sep 2009 13:27:14 -0700

Dear Stata List,

I am having difficulty using the Stata syntax command (I am new to
writing Stata programs.)  Before trying to use the syntax command with
a more complicated program I am creating, I have been trying to create
a toy version of ‘regress’ that allows for the user to specify a
variable on which to cluster (for cluster robust standard errors).
Here is some data to play with:

clear
set obs 100
set seed 1234
gen y = uniform()
gen x = uniform()
gen z = uniform()
gen clus = (z>.5)

Here is my attempt at implementing the program:

capture program drop toyreg
program toyreg
	syntax varlist , CLUSTER(varname)
	gettoken y xvars : varlist
	reg `y' `xvars', `CLUSTER'
end

toyreg y x, cluster(clus)

However, as can be seen, the standard errors here are not clustered
(the output is different from reg y x, cluster(clus)).  One particular
issue of confusion here is the capitalization.  In the help file for
syntax, all of the examples found under “Option descriptor optional
varlist” have at least the first letter capitalized (the help file
indicates that one uses capitalization to allow for acceptable
abbreviations)—capitalizing an entire option name should theoretically
be equivalent to not capitalizing at all, but the results with toyreg
differ depending on what you do.

I also have problems with a toy version of tobit:

capture program drop toytobit
program toytobit
	syntax varlist , LL(real 0)
	gettoken y xvars : varlist
	tobit `y' `xvars', `LL'
end
toytobit y x, ll(0)

My question is: Why won’t Stata cluster the SEs in toyreg?  What am I
doing wrong in toytobit?

Thank you very much.

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