1
$\begingroup$

I have a dateset that includes information on U.S. states in 1987, 1990 and 1993 and describes the relationship between murder rate and the death penalty. mrdrte is the number of murders per 100,000 population, exec is the number of total executions in past 3 years, and unem is an unemployment rate. We model: $$mrdrte_{it} = \beta_0 + \beta_1 exec_{it} + \beta_2 unem_{it}+a_i+u_{it}$$

Below I have labelled my question in bold and big font. I do not know how to proceed with my analysis without answering them.

Descriptives

. xtsum mrdrte exec unem

Variable         |      Mean   Std. Dev.       Min        Max |    Observations
-----------------+--------------------------------------------+----------------
mrdrte   overall |  8.070588   9.192867         .8       78.5 |     N =     153
         between |             8.768838   1.333333   64.16667 |     n =      51
         within  |              2.93735  -19.89608   22.40392 |     T =       3
                 |                                            |
exec     overall |  1.228758   3.791432          0         34 |     N =     153
         between |             3.440601          0   22.33333 |     n =      51
         within  |             1.641031  -10.10458   12.89542 |     T =       3
                 |                                            |
unem     overall |  5.973203   1.680617        2.2         12 |     N =     153
         between |             1.316781   3.233333   9.966667 |     n =      51
         within  |             1.055167   3.573203   9.439869 |     T =       3

Question: max and min look strange, how can the be like that?

Is overall - between - within = 0 ? We check using R.

> 1.680617^2-1.316781^2-1.055167^2
[1] -0.0228161
> 3.791432^2-3.440601^2-1.641031^2
[1] -0.1557614
> 9.192867^2-8.768838^2-2.93735^2
[1] -1.011741

No. Why not?

Question: The sum is not 0. Is this a sign of an error?

Between is between different id's (i.e. we fix $t$ and move $i$). We have $n=51$ different id's, so $i$ go from 1 to 51. For example between different id's the Std.Dev. for $mrdrte$ (murder rate) is $8.768838$. Between different id's the exec Std.Dev. is $3.791432$.

Within is within the same id, over time (i.e. we fix $i$ and move $t$). We have $T=4$ time periods, so $t$ go from 1 to 4. For example within $mrdrte$ Std.Dev is $2.93735 < 8.768838$ so apparently between different id's. varies mor than within individuals over time. We can conclude that $mrdrte$ varies more between different id's than within the same one. So adding another $n$ gives, loosely speaking, more information than adding another time period $T$ and this is good for our analysis since in this dataset $n>T$.

Question: How can we have zero variation in the table? What is the reason here?

By looking at these numbers, we can conclude there is a large portion of between variation in the data. This will be important later on when choosing FE or RE.

Should we use FE or RE?

In practice you could run them both and see if they differ, and if not - we need not worry about the choice. We run them both and report the output below. I set $i$ to be id and $t$ to be year.

. xtset id year

. xtreg mrdrte exec unem, fe

Fixed-effects (within) regression               Number of obs      =       153
Group variable: id                              Number of groups   =        51

R-sq:  within  = 0.0047                         Obs per group: min =         3
       between = 0.0007                                        avg =       3.0
       overall = 0.0002                                        max =         3

                                                F(2,100)           =      0.24
corr(u_i, Xb)  = -0.0635                        Prob > F           =    0.7909

------------------------------------------------------------------------------
      mrdrte |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        exec |  -.1140743   .1800836    -0.63   0.528    -.4713551    .2432065
        unem |    .095914   .2800721     0.34   0.733    -.4597411    .6515692
       _cons |   7.637844   1.684436     4.53   0.000     4.295971    10.97972
-------------+----------------------------------------------------------------
     sigma_u |   8.788124
     sigma_e |   3.612922
   rho |  .85542114   (fraction of variance due to u_i)
------------------------------------------------------------------------------
F test that all u_i=0:     F(50, 100) =    16.46             Prob > F = 0.0000

. xtreg mrdrte exec unem, re

Random-effects GLS regression                   Number of obs      =       153
Group variable: id                              Number of groups   =        51

R-sq:  within  = 0.0015                         Obs per group: min =         3
       between = 0.0732                                        avg =       3.0
       overall = 0.0433                                        max =         3

                                                Wald chi2(2)       =      0.90
corr(u_i, X)   = 0 (assumed)                    Prob > chi2        =    0.6369

------------------------------------------------------------------------------
      mrdrte |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        exec |  -.0351956   .1619968    -0.22   0.828    -.3527036    .2823124
        unem |   .2560543   .2708762     0.95   0.345    -.2748532    .7869619
       _cons |   6.584371   2.001338     3.29   0.001     2.661819    10.50692
-------------+----------------------------------------------------------------
     sigma_u |  8.1923983
     sigma_e |   3.612922
         rho |  .83717807   (fraction of variance due to u_i)
------------------------------------------------------------------------------

. 

They are not similar. So which one can we take?

There are two kinds of variation in the data: within and between. FE uses only within. RE within and between and weighs them in a smart way, and the close $\hat \theta$ is to 1 the closer RE is to FE (when $\hat \theta = 1 \implies FE=RE.)$

In our case, $\hat \theta = .83717807$ (rho in stata output) and the closer it is to 1, the closer is RE to FE. %källa s34 0.83 is pretty high. So this is piece of evidence for using RE. %qq is this really the $\theta$ or is the output telling me something else?

Remember from above that a large portion of between variation in the data. This is another piece of evidence for using RE.

Recall our model. In RE we assume $Cov( exec_{it} , a_i ) = 0$ and $Cov( unem_{it} , a_i ) = 0$. This is rarely the case, but do we violate this assumption? The correlation is weak - Stata reports that $corr = -0.0635$

Question: is this large or small? but more importantly - is this the correlation I'm really interested in checking?

It is close to zero so the assumptions is almost fulfilled.

Did this choice of RE matter? Yes it did. The output is different, of course, but more importantly we know in general that if the RE assumptions are fulfilled then (a) $se(\hat \beta_{RE}) < se(\hat \beta_{FE})$ because it uses between-variation as well and (b) we are able to use time dependent variables in our model if we wish (remember that FE removes this opportunity since we average over all values of $t$ in order to remove the fixed effect $a_i$).

$\endgroup$
1
$\begingroup$

This is a long comment...

  1. The fixed effects and random effects estimates are not that different, look at the standard errors, not just the point estimates.
  2. xtsum doesn't report what you think it does, the min and max report the means after group detrending. These values don't correspond directly to variance within or between.
  3. Certain aspects of the data generation process will dictate whether random effects or fixed effects are appropriate. E.g. if there is a time invariant important omitted variable (one example in criminology is southern culture) you would prefer fixed effects.

For 2, here is demonstration of how to go from the listed standard deviations in the xtsum table to their corresponding sum of squares for a balanced panel dataset.

use http://www.stata-press.com/data/r13/gymdata, clear
*only selecting a few so it is balanced
keep if id == 1 | id == 2 | id == 4
xtset id month
anova wt id
xtsum wt

This produces the output:

. xtset id month
       panel variable:  id (strongly balanced)
        time variable:  month, 1 to 12
                delta:  1 unit

. 
. anova wt id

                           Number of obs =      36     R-squared     =  0.9725
                           Root MSE      = 7.87064     Adj R-squared =  0.9708

                  Source |  Partial SS    df       MS           F     Prob > F
              -----------+----------------------------------------------------
                   Model |  72200.0556     2  36100.0278     582.76     0.0000
                         |
                      id |  72200.0556     2  36100.0278     582.76     0.0000
                         |
                Residual |     2044.25    33  61.9469697   
              -----------+----------------------------------------------------
                   Total |  74244.3056    35  2121.26587   

. 
. xtsum wt

Variable         |      Mean   Std. Dev.       Min        Max |    Observations
-----------------+--------------------------------------------+----------------
wt       overall |  163.8611    46.0572        118        233 |     N =      36
         between |              54.8483   130.5833   227.1667 |     n =       3
         within  |             7.642457   150.0278   177.2778 |     T =      12

. 

Subsequently the total sum of squares (in the ANOVA table) is equal to the overall variance multiplied by the number of observations minus one. The weight for the between sum of squares is the number of observations per panel multiplied by the number of groups minus one. The weight for the within (residual) sum of squares is the number of observations minus one.

*Total sum of squares ~ 74244.3056 
display (46.0572^2)*(36-1)

*between sum of squares ~ 72200.0556
display (54.8483^2)*12*(3-1)

*residual sum of squares ~ 2044.25 
display (7.642457^2)*(36-1)

Again these simplified calculations only work for balanced panels. There is not enough information in the summary xtsum table to aggregate the sum of squares if the groups have unequal numbers.

$\endgroup$
  • $\begingroup$ Between variation is variation that occurs between indivudals, over time. So we have taken the data and on each variable $B_{it}$ we calculate $\frac1T \sum_{t=1}^T B_{it}.$ If a variable is not dependent on time, for example "id" in our dataset, it will have within variation of zero. Likewise, within variation is variation that occurs between time, over indivudlas. Total variation is calculated as if we have $N=nT$ individuals in one time period. How come $$overall = 0 \text{ for } exec_{it}$$ since it has index it? $\endgroup$ – user1603548 Oct 20 '15 at 18:29
  • $\begingroup$ Furthermore, how can exec have negative within variation? $\endgroup$ – user1603548 Oct 20 '15 at 18:33
  • $\begingroup$ NEW: Between variation is variation that occurs between indivudals, over time. So we have taken the data and taken a standard deviation over time, just as the mean over time for a variable $B_{it}$ is $\frac1T \sum_{t=1}^T B_{it}.$ If a variable is not dependent on time, for example "id" in our dataset, it will have within variation of zero. Likewise, within variation is variation that occurs between time, over indivudlas. Total variation is calculated as if we have $N=nT$ individuals in one time period. How come $$overall = 0 \text{ for } exec_{it}$$ since it has index it? $\endgroup$ – user1603548 Oct 20 '15 at 18:37
  • 1
    $\begingroup$ Exec does not have 0 "variation", its within standard deviation is 1.641031. In the xtsum output min and max refer to the group detrended means. So calculate the mean per id, and subtract that. Min and max then report the range on those values. So an id that has a mean of 10, if the minimum value in the series is 0 it will be -10 on the lower range. $\endgroup$ – Andy W Oct 20 '15 at 18:50
  • $\begingroup$ Thanks! I get rho = 0.8 which is large, so this is an argument for using FE-model. $\endgroup$ – user1603548 Oct 21 '15 at 7:50
0
$\begingroup$

Let's look at the data first. You say you have data for three time points. Did you throw those all together into the 153 observations? If so, why? (One would expect there to be a time dimension, a general national trend up or down.) Either way, why are there 153 observations? I can only surmise that this might be 3 observations for each of the 50 states plus the District of Columbia? Puerto Rico?, but other configurations are of course possible. Are there figures in there for individual cities?

According to data I found here, the minimum of 0.8 does not look out of line (look at New Hampshire and North Dakota). The maximum is a bit unusual and looks like an outlier (unless the aggregation is not truly per state). I would advise on doing some graphing before you even formulate the regression model.

$\endgroup$
  • $\begingroup$ This is panel data. n=51 as in 51 states. T=3 as in 3 time periods. 51*3=153. So in my model $mrdrte_{it}$ we have $i$ from 1 to 51 and $t$ from 1 to 3. $\endgroup$ – user1603548 Oct 17 '15 at 21:11
  • $\begingroup$ It is aggregated per state. $\endgroup$ – user1603548 Oct 17 '15 at 21:15
0
$\begingroup$

Inspired by @andy-w here is an answer: xtsum measures the standard deviation within and between, just as anova measures the sum of squares within and between.

R code below.

> library(foreign) #to read dta files
> #dataset is at https://www.dropbox.com/s/e7suemnmgxu3eib/MURDER.DTA?dl=1
> dfa<-read.dta("murder.dta")
> names(dfa)
 [1] "id"      "state"   "year"    "mrdrte"  "exec"    "unem"    "d90"
 [8] "d93"     "cmrdrte" "cexec"   "cunem"   "cexec_1" "cunem_1"

From xtsum (included in the code for the question) we expect the SS to be greatest for 1 mrtdrte 2 exec 3 unem

> anova(lm(id ~ mrdrte + exec + unem, dfa))
Analysis of Variance Table

Response: id
           Df  Sum Sq Mean Sq F value   Pr(>F)
mrdrte      1  1670.1 1670.07  8.0123 0.005288 **
exec        1   380.9  380.85  1.8272 0.178509
unem        1    41.9   41.86  0.2008 0.654715
Residuals 149 31057.2  208.44
---

This is correct

> anova(lm(year ~ mrdrte + exec + unem, dfa))
Analysis of Variance Table

Response: year
           Df Sum Sq Mean Sq F value Pr(>F)
mrdrte      1   5.17  5.1699  0.8451 0.3594
exec        1   0.98  0.9840  0.1609 0.6889
unem        1   0.37  0.3672  0.0600 0.8068
Residuals 149 911.48  6.1173

This is correct

> anova(lm(state ~ mrdrte + exec + unem, dfa))
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
  NA/NaN/Inf in 'y'
In addition: Warning message:
In model.response(mf, "numeric") : NAs introduced by coercion

Something went wrong.

Let's make mrdrte the dependent variable for fun,

> fit <- lm(mrdrte ~ year + id + exec + unem, dfa)
> anova(fit)
Analysis of Variance Table

Response: mrdrte
           Df  Sum Sq Mean Sq F value   Pr(>F)
year        1    72.3   72.34  0.9400 0.333856
id          1   647.1  647.14  8.4090 0.004303 **
exec        1   180.6  180.62  2.3471 0.127654
unem        1   555.5  555.50  7.2182 0.008042 **
Residuals 148 11389.7   76.96
---

I do not know how to interpret this.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.