Why is there no output or error message?

TomD

New Member
#1
I'm running regressions on agricultural panel data for two different zones. I get full results for a fixed effects regression in zone 1:

if aez_abeo==1 xtreg income pppct sdtype vprodmz vprodcnpul vprodveg vprodfrut vprodind totacres kgs_per_acre_mz localnum improvednum fertuse grpmem credrecv kmtroad kmpwater totval, fe

...but no output or error message when I run the same for zone 2:

if aez_abeo==2 xtreg income pppct sdtype vprodmz vprodcnpul vprodveg vprodfrut vprodind totacres kgs_per_acre_mz localnum improvednum fertuse grpmem credrecv kmtroad kmpwater totval, fe

Zone 2 is substantially smaller, but still has 650 observations and over 160 groups. Why won't Stata give me a result OR tell me what mistake I've made?
 
#2
Does Stata do anything at all? Does it just freeze whilst its "thinking" (is the timer thing still going in the corner)? Or does Stata seem to think it has given you something?

I've seen this when a group has no observations in, but sound slike that isnt the issue here.

Maybe you can post some sample data and I can have a go at running it?
 
Last edited:

bukharin

RoboStataRaptor
#3
There is a huge difference between the -if- command and the "if" qualifier.

You're using the -if- command which is almost certainly not doing what you think it is. The -if- command goes before another command (such as -xtreg-) and determines whether or not the command is run at all. In your second example it's returning false, so the command isn't run - hence no error message. You should not be using the -if- command unless you're programming.

If you want to run your regression - or do just about anything else - with a subset of observations you should be using the "if" qualifier, which goes after the command and before the options.

See -help if- for more details.

So your code should be:
xtreg income pppct sdtype vprodmz vprodcnpul vprodveg vprodfrut vprodind totacres kgs_per_acre_mz localnum improvednum fertuse grpmem credrecv kmtroad kmpwater totval if aez_abeo==1, fe

xtreg income pppct sdtype vprodmz vprodcnpul vprodveg vprodfrut vprodind totacres kgs_per_acre_mz localnum improvednum fertuse grpmem credrecv kmtroad kmpwater totval if aez_abeo==2, fe

As a side issue, are you sure it's valid to use a fixed effects model with such small clusters (in zone 2 at least)?
 
#4
There is a huge difference between the -if- command and the "if" qualifier.

You're using the -if- command which is almost certainly not doing what you think it is. The -if- command goes before another command (such as -xtreg-) and determines whether or not the command is run at all. In your second example it's returning false, so the command isn't run - hence no error message. You should not be using the -if- command unless you're programming.
I never knew that, thats really interesting. I've never tried to put an if statement in front of a command so when I saw this I just assumed it was the same as putting it after!
 

TomD

New Member
#5
Thanks to you both. Using IF after the command and before the options was the trick.

The small cluster in zone two has been a problem on many levels. Would you recommend something else?
 

bukharin

RoboStataRaptor
#6
I guess it depends on what inferences you want to make. I don't know know much about agricultural data (actually I don't know anything, I'm more of a biostatistics person) but I would probably go for a random effects model. In a RE model you can have clusters of 1 with no problems; in a FE model you can as well, but your estimates of the fixed effects will be unreliable.