A General Panel Model for Unobserved Time Heterogeneity with Application to the Politics of Mass Incarceration

Panel data analysis is common in the social sciences. Fixed effects models are a favorite among sociologists because they control for unobserved heterogeneity (unexplained variation) among cross-sectional units, but estimates are biased when there is unobserved heterogeneity in the underlying time trends. Two-way fixed effects models adjust for unobserved time heterogeneity but are inefficient, cannot include unit-invariant variables, and eliminate common trends: the portion of variance in a time-varying variable that is invariant across cross-sectional units. This article introduces a general panel model that can include unit-invariant variables, corrects for unobserved time heterogeneity, and provides the effect of common trends while also allowing for unobserved unit heterogeneity, time-varying coefficients, and time-invariant variables. One-way and two-way fixed effects models are shown to be restrictive forms of this general model. Other restrictive forms are also derived that offer all the usual advantages of one-way and two-way fixed effects models but account for unobserved time heterogeneity. The author uses the models to examine the increase in state incarceration rates between 1970 and 2015.

However, fixed effects models assume that there is no unobserved heterogeneity between time periods. Unobserved time heterogeneity can be produced by an unmeasured period effect or because of an unmeasured interaction with time (Bruderl and Ludwig 2015). Two-way fixed effects models that allow for covariance with unmeasured period effects are the dominant approach for addressing time heterogeneity (Imai and Kim forthcoming;Wooldridge 2010), but two-way fixed effects models eliminate common trends: the portion of variance in a time-varying variable that is invariant across cross-sectional units. This is useful in quasi-experimental research designs in which treatment effects cannot produce a common trend (e.g., Angrist and Pischke 2009;Baltagi 2013;Bertrand, Duflo, and Mullainathan 2004), but observational studies often analyze data for which common trends are substantively informative. Common trends typically manifest when cohort effects are sizable (e.g., Yang, Fu, and Land 2004). If there is a universal shift toward for-profit health care in a country, health outcomes are likely to decline in the population at large (Zheng and George 2018). If people tend to consume more crime news media over time, public support for tough crime policies is likely to increase (Enns 2016). In these cases, models that eliminate common trends might misrepresent the sociological relationship of interest.
In this article, I introduce a general panel model that provides the effect of common trends while allowing for covariance with unmeasured period effects. Prior studies have proposed panel models that allow for unobserved unit heterogeneity (Allison 2009;Arellano 1993;Baltagi 2006;Bollen and Brand 2010;Mundlak 1978;Neuhaus and Kalbfleisch 1998), but these models do not address unobserved time heterogeneity. The model introduced here offers a number of important utilities unavailable in other panel models. First, the model provides the effect of common trends, which is not provided by other panel models. Second, the model can include unit-invariant and timeinvariant variables, which cannot be included in other models that allow for covariance with unmeasured period effects, such as the two-way fixed effects model. Third, the model allows for time-varying coefficients. Fourth, the two-way fixed effects coefficient is provided by the general model, so the relative advantages of the model come without losing any of the utility of the two-way fixed effects model in terms of causal inference. The model can also be estimated in a multilevel framework and therefore should be familiar to most sociologists and easy to implement in current software.
I begin by introducing terminology and the problem of unobserved time heterogeneity. I then introduce the general model and discusses its relationship to alternative panel models. I derive restrictive forms and discuss estimation and model selection. I next provide an empirical example using state incarceration rates, which shows that substantive conclusions are often affected by model selection. I provide an open-source R package to implement the models.

MODELING PANEL DATA
Overview and Terminology Table 1 is a reference table for all notation used in this article. Panel data are represented by repeated observations of cross-sectional units. The pooled panel model is

Within-transformed variablesX
The deviations from the cross-sectional means, f X it = X À X i: Common trends X The time period means of the within variation, X :t = P tX N t Idiosyncratic transformed variables XˇT he deviations from the common trends, The effect of X on y Within coefficient b W The effect of X controlling for all timeinvariant variation (the effect ofX oñ y) Between effect b B The effect of X controlling for all temporal variation (the effect of X i: on y i: ) Idiosyncratic effect b I The effect of X controlling for all unitinvariant variation and all timeinvariant variation simultaneously (the effect of Xˇon y) Homogenous-within effect b HW The effect of common trends (the effect of X on y) Unit fixed effects d The coefficients for each unit-specific dummy variable when Z is specified as a matrix of unit-indicator variables where y is a continuous response variable, X is a data matrix of time-varying variables, b is a k vector of coefficients, e is the error, and it is the time-varying observation of cross-sectional unit i at time t for all i = 1, 2, . . ., N and t = 1, 2, . . ., T. We may, for instance, be interested in academic achievement among students. The characteristics of each student are measured repeatedly over time and used to predict their school performance. The coefficients in the pooled model thus represent a blend of the effect of student-level differences, within-student changes, and common trends among students. Panel data are distinct from exchangeable data in that there are three sources of variation in the error term: where a i: is the unmeasured between effect, e :t is the unmeasured period effect, and u it is the idiosyncratic error that varies across both time and units. Each component of the error is assumed to have a normal sampling distribution with zero means and normal variance. The unmeasured between effect, for instance, may contain an unmeasured time-invariant student characteristic, such as gender, that influences students' school performance. The unmeasured period effect e :t represents the effect of unmeasured unit-invariant variables. For instance, the performance of all students within a school district may decrease over time because of districtwide budget cuts. The pooled model in equation (1) assumes no unobserved unit heterogeneity. We can relax this assumption using a random effects model: The random effects model allows for an unmeasured between effect but assumes the unmeasured between effect does not correlate with the time-varying variables. For instance, we may assume there are between-student differences in parental education but that these differences in parental education are uncorrelated with the time-varying variables of interest, such as students' study habits. When the unmeasured between effect correlates with the time-varying variables, the random effects coefficients are biased and inconsistent (Arellano 1993;Hausman 1978). The most common correction is to control for unmeasured time-invariant Notation Explanation Idiosyncratic error u The random error after removing unmeasured between effects and unmeasured period effects, u it = e it À a i: À e :t Within error c The error after removing unmeasured between effects, c it = e it À e :t characteristics using one-way fixed effects. One-way fixed effects models allow for covariance with unmeasured between effects by controlling for unit-level differences: Z 0 i: is a matrix of time-invariant variables, here specified as N -1 indicator variables for each cross-sectional unit, d is the N -1 vector of coefficients representing the effect of each unit, and c it is the within-unit error term (c it = u it + e :t ). b W is the within effect representing the within-unit change in y associated with a within-unit change in X. The inclusion of Z as a matrix of dummy variables absorbs the unmeasured between effect into the unit fixed effect coefficients (d). Because the within coefficients use only within variation, the model can be reexpressed without the vector of indicator variables by using the within transformation that centers all variables on their crosssectional means (ỹ it = y it À y i: ):ỹ Fixed effects is unbiased and consistent when X correlates with an unmeasured between effect, but the model is inefficient because it eliminates all time-invariant variation. We could not, for instance, use one-way fixed effects to evaluate how gender influences students' school performance. Mundlak (1978) introduced a model that allows for time-invariant variables while also allowing for covariance with unmeasured between effects. We can stack the model in equation (5) with a model for the between effects, y i: = X 0 i: b B + a i: , where X i: are the cross-sectional means for X and b B is the between effect of X i: on y i: Combining equation (5) with the model for the between effects gives the between-within model (Arellano 1993;Baltagi 2006): In balanced panel data, the within effects are equivalent to the estimates obtained from one-way fixed effects. But the model also provides the between effects and can include time-invariant variables. Using the model in equation (6), we could examine the effects of time-invariant variables like gender, as well as the within effect of time-varying variables, such as the effect of within-student changes in study habits on within-student changes in school performance.

Dealing with Time Heterogeneity
The one-way fixed effects model and the between-within model allow for covariance with unmeasured between effects, but both models assume there is no unobserved time heterogeneity (Halaby 2004:532-35;Morgan and Winship 2007:262-71;Wooldridge 2010:269). 2 This assumption is violated when an unmeasured period effect influences time trends for all units. In our example of school performance, for instance, if districtwide budget cuts decreased students' school performance but were not included in our model, the within coefficients from our one-way fixed effects model of students' school performance would be biased and inconsistent.
Two-way fixed effects models are the most widely used model for addressing unobserved time heterogeneity. They allow for covariance with unmeasured period effects by including indicator variables for both cross-sectional units and time periods. Let C be a matrix containing unit-invariant variables, here specified to be indicator variables for each time period, and g be the "fixed effect" coefficients for each time period. We write the two-way fixed effects model as a function of the within-transformed variables 3 :ỹ b I replaces b W because all unit-invariant and time-invariant variation is controlled (i.e., e :t = 0 and a i: = 0). Because the coefficient only uses the idiosyncratic variation, I refer to b I as the "idiosyncratic" effect. The inclusion of the time indicator variables means that the model is unbiased and consistent even when there is an unmeasured period effect. However, the model is inefficient and cannot include time-invariant or unit-invariant variables. We could not use two-way fixed effects to evaluate the effect of districtwide budget cuts on students' school performance.

Sources of Time Heterogeneity and Problems with Corrections
In addition to the inability to include unit-invariant variables, there are two primary issues with the two-way fixed effects correction for unobserved time heterogeneity. First, two-way fixed effects models eliminate common trending. Common trending is informative when all units shift in a similar direction over time. We may want to know, for instance, whether the decrease in the national crime rate during the 1990s was driven partly by an increase in antiviolence organizations in major cities (Sharkey, Torrats-Espinosa, and Takyar 2017). Because a national decline in crime is plausible only if we expect that there was a strong over-time shift toward anticrime organizations in most major cities, this explanation is one of common trends. In this example and similar ones in which we expect that the common trend has a sizable effect, the two-way fixed effects model can provide misleading results. To see this, let b HW be the homogenous-within effect of a common trend. Common trends are invariant across units, representing the average within-variation at each time period. Let X 0 :t denote the common trend of X obtained by calculating the average value ofX at each time period and y :t be the common trend for y. The model for the common trends is Because the common trend represents a portion of the within variation, we can regard the model in equation (8) as an implied component of the one-way fixed effects model. In two-way fixed effects, however, we aim to set the unmeasured period effect to 0 by replacing e :t with C 0 :t g. As a result, two-way fixed effects overidentifies the model in equation (8).
The second issue is that two-way fixed effects coefficients are biased if there is an unmeasured interaction with time. To correct this, researchers often include interactions between a variable of interest and the time period. This approach, however, grows increasingly inefficient as the number of time periods increases, because each interaction decreases degrees of freedom. Interpretation can also easily become complicated as the number of time periods increases (e.g., Tian et al. 2014). And including many interactions, as is the case in large-T studies, without adjustment produces downwardly biased standard errors (Green and Kern 2012).
Depending on how much variation exists in the common trends, the coefficients provided by two-way fixed effects models may be misleading. If we have a quasiexperimental design in which the primary goal is identification, two-way fixed effects is appropriate because a treatment cannot produce common trends among treated and untreated groups (Angrist and Pischke 2009;Bertrand et al. 2004). However, in many observational studies, common trending is produced by a social process that influences all observations equally. In these cases, common trends are not a nuisance to be eliminated, but an important component of the analysis.

A GENERAL PANEL MODEL FOR UNOBSERVED TIME HETEROGENEITY
I now introduce a panel model for unobserved time heterogeneity that provides the homogenous-within effect of common trends, the between effect of unit differences, and the idiosyncratic effect usually provided by two-way fixed effects models. The model can also include time-invariant and unit-invariant variables and allows for covariance with unmeasured period effects and unmeasured between effects. I begin by introducing the most general case of the model. The second subsection recasts the model as a multilevel model that allows for time-varying coefficients. The third subsection regards the model as an extension to Bollen and Brand's (2010) general panel model. The fourth subsection discusses restrictive forms. The remaining subsections are dedicated to estimation, model selection, and exploratory analysis. Table 2 provides the details for each model and hypothetical applications.

The Between-Within-Idiosyncratic Model
Consider the model in the following equation: Common trends are included via the time averages of the within variation X :t . Between-unit differences in the time-varying variables are represented with the crosssection averages X i: . Xˇi t is the idiosyncratic variation of X obtained from the idiosyncratic transformation, Xˇi t = X it À X :t À X i: : The model provides the between effect, homogenous-within effect, and idiosyncratic effect for each time-varying variable. Like two-way fixed effects models, the model allows for covariance with unmeasured between effects and with unmeasured period effects. Unlike two-way fixed effects

Models that allow for covariance with unmeasured period effects and covariance with unmeasured between effects
Between-within-idiosyncratic Idiosyncratic variation and idiosyncratic effect; time means of the within variation and homogenouswithin effect; cross-section means and between effects; unmeasured between effects; unmeasured period effects; random error In an analysis of crime rates in major cities, we could examine betweencity differences in levels of crime (b B ), common trends whereby crime rates increase across all cities over time (b HW ), and specific-city change whereby crime rates in some cities increase more rapidly than others (b I ).
Random effects within- Idiosyncratic variation and idiosyncratic effect; time means of within variation and homogenous-within effect; unmeasured period effect; random error In an analysis of crime rates in major cities, we could examine common trends whereby crime rates increase across all cities over time (b HW ) and specific-city change whereby crime rates in some cities increase more rapidly than others (b I ), but we could not examine between effects.
Two-way fixed effectsỹ Idiosyncratic variation and idiosyncratic effect; timeperiod dummy variables and fixed effects for each time period; random error In an analysis of crime rates in major cities, we could examine the specific-city change whereby crime rates in some cities increase more rapidly than others (b I ), but we could not examine between effects or homogenous-within effects.

Models that allow for covariance with unmeasured between effects only
Cross-classified betweenwithin model Within-transformed variables and within effect; crosssection means and between effects; unmeasured between effect; unmeasured period effect; random error In an analysis of students' academic performance, we could examine the determinants of within-student change (b W ) and between-student differences (b B ) while allowing for unmeasured time heterogeneity, assuming the unmeasured period effect does not correlate with X.
(continued) In an analysis of students' performance, we could examine the determinants of within-student change (b W ) allowing for unmeasured time heterogeneity, assuming the unmeasured period effect does not correlate with X, but we could not examine betweenstudent differences (b B ).
Between-within model Within-transformed variables and within effects crosssection means and between effects; unmeasured between effects; random error In an analysis of students' performance, we could examine the determinants of within-student change (b W ) and between-student differences (b B ), but it does not allow for unmeasured time heterogeneity.
One-way fixed effectsỹ

Within-transformed variables and within effect; random error
In an analysis of students' performance, we could examine the determinants of within-student change (b W ), but it does not allow for time heterogeneity and we could not examine between-student differences (b B ).
(continued) Pooled model Variables and pooled coefficients; random error In an analysis of unemployment rates in counties, we could examine the factors that influence unemployment rates in each county in each year, but this does not allow for unmeasured county-level heterogeneity. models, the model can include unit-invariant and time-invariant variables. Because of its similarity to the between-within model (equation 6), I refer to the model in equation (9) as the "between-within-idiosyncratic" (BWI) model. At the heart of the BWI model is a data transformation. By decomposing X it into Xˇi t , X :t , and X i: , we ensure that e :t and Xˇi t are uncorrelated. To see this, we momentarily set aside the between variation. Next, we center the within variation on time using the idiosyncratic transformation. This gives us two orthogonal equations (see Appendix for proof), one for the common trends and one for the idiosyncratic variation: and The reader will recognize equation (11) from earlier: it is the model for common trends. We can see from the above equations that e :t cannot correlate with Xˇi t , because the equations are orthogonal. In fact, the model in equation (10) is a two-way fixed effects model, so it is impossible for unmeasured period effects to correlate with Xˇi t . To see this, we write the traditional two-way fixed effects estimator as follows (Imai and Kim forthcoming): The expression is simplified by centering all variables on cross-sectional units: We can simplify again by centering on time to eliminate period effects: which is the ordinary least squares estimate of equation (10). A technical derivation of the models in equations (10) and (11) using system estimation is provided in the Appendix.
Becauseỹ it = yˇi t + y :t , combining equations (10) and (11) produces a simultaneous equation of the two-way fixed effects model and the model for common trends: Because the within and between variation are orthogonal, we obtain the general BWI model by stacking equation (15) with the equation for the between model, which gives Thus, we can regard the equation for the BWI model as a simultaneous equation for three uncorrelated models: the two-way fixed effects model (equation 10), the model for common trends (equation 11), and the between model presented earlier.
There are four primary benefits of the BWI model. First, it provides the homogenous-within effect of common trends, which is not provided in any other model. Second, the model allows for covariance with unmeasured period effects and unmeasured between effects. Third, in contrast to two-way fixed effects models, the model can include time-invariant and unit-invariant variables. Fourth, the model offers these benefits at little cost, as it provides the same idiosyncratic effect as the two-way fixed effects model, and thus it can be used for causal inference in the same way as two-way fixed effects.
Returning to our example of decreasing crime rates in major cities, the BWI model would allow us to evaluate several processes for the decline. b HW would tell us whether a common trend toward antiviolence organization mobilization in major cities contributed to a mean reduction in crime across major cities. b I would tell us whether within-specific-city changes in community organization mobilization contributed to within-specific-city changes in crime rates. b B would tell us whether cities that have, on average, more anticrime community organizations have, on average, lower crime rates. By focusing explicitly on b HW , we would be able to determine whether a common trend toward anticrime organization mobilization had an effect on crime rates in most major cities, producing the national decline in crime during the 1990s.

From a Multilevel Perspective
As mentioned earlier, the BWI model can be regarded as a single equation for three stacked models. We can show this more explicitly by regarding the BWI model as a cross-classified multilevel model. Each it observation is "nested in" cross-sections and time periods. The level 1 equation is is a random intercept that varies across units and time. We write the level 2 equation to account for both the unmeasured between effect and the unmeasured period effect: Here, we obtain the grand intercept (b 0 ), the random variation across units (a i: ), and the random variation across time (e :t ). As before, we assume that a i: and e :t have zero means and normal variances. Plugging the level 2 equation into the level 1 equation yields the BWI model presented above.
An advantage of the multilevel framework is the ability to include random slopes. Including a random slope is equivalent to including a vector of interactions, but random slopes are more efficient (Gelman and Hill 2011:282-83;Heisig, Schaeffer, and Giesecke 2017). This means we can obtain time-varying coefficients without having to rely on interaction coefficients, as in two-way fixed effects models. This reduces the complexity of interpreting time-varying slopes in the BWI model, increases efficiency relative to the interaction-coefficient approach, and helps minimize the risk for type I error. An extended discussion of random slopes is not possible here, but readers can find details on random slope models in Gelman andHill (2011), Heisig et al. (2017), and Raudenbush and Bryk (2002).

Relation to Bollen and Brand's Model
It can be shown that the BWI model extends the general panel model introduced by Bollen and Brand (2010). Bollen and Brand's model is X is a matrix of time-varying variables, which may include within-transformed variables. Z is a matrix of time-invariant variables, which may include cross-sectional unit means. The t subscript indicates that coefficients are allowed to vary across time periods. l t provides time-varying coefficients for a i . This is a general model in that many panel models are special cases of the general model. For instance, if we specify Z to be a matrix of unit-indicator variables and we assume that there are no time-varying coefficients, we obtain a one-way fixed effects model. Bollen and Brand's (2010) model allows for unobserved between effects, but it does not include unobserved period effects or unit-invariant variables. We can expand the model to include unit-invariant variables and unmeasured period effects: C is a matrix of unit-invariant variables, which may include common trends. We now include the unmeasured period effect, which was not present in Bollen and Brand's (2010) model, where l i is the unit-specific coefficient for the unmeasured period effect. If we specify X to include the idiosyncratic transformation of the time-varying variables, Z to include the between transformation, and C to include the common trends, the model becomes a case of the BWI model with random slopes for all coefficients and a unit-varying unmeasured period effect. If we assume the coefficients and unmeasured between effect do not vary across time, and the unmeasured period effect does not vary across units, then the model is the BWI model introduced earlier. Hence, the BWI model can be viewed as an extension to Bollen and Brand's (2010) model that allows for unit-invariant variables and unmeasured period effects.

Restrictive Forms
The BWI model implies several restrictive forms that are not currently in use in the applied literature but may be useful to researchers concerned with time heterogeneity.
Case 1: The Cross-Classified Between-Within Model. A first restrictive form exists in cases in which the unmeasured period effect is uncorrelated with X. If the unmeasured period effect does not correlate with X, we can use the within transformation rather than the idiosyncratic transformation. This yields a special case of the between-within model that includes an unmeasured period effect: Sociological Methodology 51(2) This model is identical to the standard between-within model, with the sole exception that now we allow for unobserved time heterogeneity. However, unlike the BWI model, we assume the unmeasured period effect is uncorrelated with the withintransformed variables. When there is no unmeasured period effect (e :t = 0), the crossclassified between-within (ccBW) model in equation (16) and the standard betweenwithin model in equation (6) are equivalent.
Case 2: The Random Effects Within Model. A second restrictive form provides an extension to the one-way fixed effects model that allows for unobserved time heterogeneity. Imagine we are not interested in time-invariant variables but are concerned with time heterogeneity. Then we can replace X in the ccBW model with a vector of unit-indicator variables, as in a one-way fixed effects model. Because the between variation is eliminated, we can simplify this expression using the within transformation. This gives us the "within equation" for the ccBW model introduced earlier: The only difference between this model and the ccBW model is that we removed the between component. The model in equation (17) is almost identical to the standard one-way fixed effects model (see equation 5), but we now include an unobserved period effect. Hence, the model allows for unobserved time heterogeneity, whereas one-way fixed effects does not. Like ccBW, we assume that e :t is uncorrelated withX . Because the model in equation (17) is equivalent to the model in equation (5) but allows random variation across time periods, I refer to it as the "random effects within model" (REWM).
Case 3: The Random Effects Within-Idiosyncratic Model. A third restrictive form allows unmeasured period effects to correlate with the within-transformed variables. As before, consider a case in which we are interested only in the over-time variation. Then we can replace X in the BWI model with unit-indicator variables. We can regard this model as only using the "within component" of the BWI model. We can express the equation using the within transformation on y and the idiosyncratic transformation on X:ỹ We arrived at this model earlier in equation (15). It is exactly equivalent to the BWI model, minus the between variation. The model allows for covariance with unmeasured period effects, provides the effect of common trends, and can include unitinvariant variables, but it cannot include time-invariant variables. The model therefore offers all the usual benefits of the two-way fixed effects model, while also providing the homogenous-within effect of common trends. I refer to this model as the "random effects within-idiosyncratic model" (REWIM).

Estimation and Covariance Matrix
It is possible to estimate the BWI model and its restrictive forms using generalized least squares (GLS). However, estimates are generally improved with empirical Bayes estimation. Empirical Bayes estimation is more efficient than GLS for nested data structures (Snijders and Bosker 2008:58-59). Furthermore, the estimation framework introduces shrinkage, whereby coefficients are pulled toward the grand mean as a function of sample size and variability, increasing the reliability of otherwise unreliable estimates (Gelman and Hill 2011:477;Gill 2014:138;Raudenbush and Bryk 2002:39-40). The empirical Bayes estimates of random time intercepts also provide a parameter for serial correlation in repeated measurement models (Goldstein, Healy, and Rabash 1994), and so standard errors are intrinsically adjusted for serial correlation, which is not true of least squares estimates. Using generic notation, the covariance matrix of the estimator is where X is a matrix of preprocessed data, V is a block-diagonal matrix of variance components, and the empirical Bayes estimator isb = (X 0 V À1 X ) À1 X 0 V À1 y. The BWI covariance matrix is block-diagonal, where the diagonal blocks are the covariance matrices for each estimator and the off-diagonal entries are 0 matrices: In practice, empirical Bayes estimation can be implemented using standard strategies of restricted maximum likelihood estimation and Gibbs sampling (Gelman and Hill 2011:392-98;Raudenbush and Bryk 2002:44-48). Thus, the models can be implemented using existing multilevel modeling software packages such as Stata, SAS, and R. The open-source R software package rewie provides functionality to implement the models (Duxbury 2020).

Model Selection
A two-stage Hausman testing procedure can be used to aid in model selection (Arellano 1993;Hausman 1978;Wooldridge 2010). The Hausman test evaluates the equivalence of an efficient but possibly inconsistent estimator to an inefficient but consistent estimator. It is commonly used to evaluate whether a one-way fixed effects model is preferred to a random effects model, in which a significant result favors oneway fixed effects. Because one-way fixed effects is more efficient than two-way fixed effects but is inconsistent when there is an unmeasured period effect, we can use the test to adjudicate between the two models. First, we test whether one-way fixed effects is preferred to random effects. If the result is significant, we should favor models that rely on the within transformation (one-way fixed effects, REWM, ccBW). Second, we test two-way fixed effects against one-way fixed effects. If the result is significant, we should prefer models that rely on the idiosyncratic transformation (two-way fixed effects, REWIM, BWI). Hausman tests are widely used for panel model selection, but they tend to produce significant results in large sample spaces even when gains in consistency are minor. One option in these instances is to evaluate improvements in model fit. Bollen and Brand (2010:12-14) recommended several model fit criteria that can aid in model selection, the most familiar of which from a multilevel modeling perspective are the root mean squared error of approximation and Bayesian information criteria. In general, the best fitting model should be preferred. However, note that models that use different transformations of the response variable cannot be compared. For instance, if we first within transform our variables before estimating a REWM, we cannot compare the fit criteria with BWI, because BWI pools all variation in the response, whereas REWM only examines within variation.
In cases in which two competing models use different dependent variable transformations, we can use between-model comparisons of coefficients to inform model selection. When an unmeasured period effect correlates with the within-transformed variables, REWM coefficients will typically be noticeably smaller than one-way fixed effects coefficients because of shrinkage to the grand mean. If one-way fixed effects and REWM provide noticeably different estimates for the same coefficients, this is evidence that the unmeasured period effect correlates with the within-transformed variables. Hence, models that allow for correlation with unmeasured period effects should be preferred.
Intraclass correlations coefficients (ICC) can be used for exploratory analysis. The ICC gives the proportion of variance at each level (Raudenbush and Bryk 2002). If the within variation is far greater than between variation, which is often true of large-T data, then REWM and REWIM are likely appropriate. If the between variation is sizable, as in large-N data, BWI and ccBW are appealing choices. If the idiosyncratic variation is sizable, either REWIM or BWI are likely necessary.
Summary I introduced a model that provides the effect of common trends and allows for covariance with unmeasured period effects. The BWI model can include unit-invariant and time-invariant variables and time-varying coefficients, and it allows for covariance with unmeasured between effects without sacrificing any of the utility of two-way fixed effects for causal inference. Restrictive forms offer alternatives to one-way fixed effects (REWM), two-way fixed effects (REWIM), and between-within models (ccBW) by allowing for unobserved time heterogeneity. I will now illustrate use of the BWI model and its restrictive forms in an empirical analysis of state incarceration rates.

EMPIRICAL EXAMPLE: TIME-VARYING POLITICS OF MASS INCARCERATION
In 1972, the national incarceration rate began an upward march that would not ebb until 2008. Accounts seeking to explain this rise emphasize the national character of mass incarceration (Garland 2001;Gottschalk 2006;Simon 2007;Western 2006) and differences in state trajectories (Campbell and Schoenfeld 2013;Lynch 2009;Page 2011;Schoenfeld 2018). Although the United States at large experienced a uniform increase in incarceration, roughly 90 percent of the growth in the prison population was within state prisons and, as shown in Figure 1, there was sizable state heterogeneity in incarceration trajectories (Campbell 2018). Prior analyses focus on change within states using either one-way fixed effects models (Enns 2016;Greenberg and West 2001;Western 2006) or two-way fixed effects models (Keen and Jacobs 2009;Muller 2012). However, because neither model can simultaneously account for unmeasured period effects and the effect of common trends, it is unclear whether results from studies using one-way fixed effects analyses are biased, or whether results from studies using two-way fixed effects are misleading because they eliminate common trends.
To illustrate this point, Table 3 presents linear models predicting state incarceration rates between 1970 and 2015 including only state fixed effects, only time fixed effects, and both state and time fixed effects. The R 2 value in model 1 is .36, meaning that, despite large-T data, 36 percent of the variation is between variation. Model 2 includes only time fixed effects, showing that 51 percent of the variation influenced all states equally; that is, half the variation in state incarceration rates, and 79 percent of the within variation, can be attributed to common trending. Model 3 includes both time and state fixed effects. The R 2 value is an impressive .87, indicating that without accounting for any theoretically informative variables, we eliminated almost 90 percent of the variation in state incarceration rates. Studies using two-way fixed effects can therefore only estimate the idiosyncratic effects that explain a minority of the variation in incarceration. 4 I now examine determinants of state incarceration rates, with a focus on how attention to the level of variation affects conclusions about the politics of mass incarceration. Political accounts argue that Republican politics drove up the incarceration rate (Alexander 2010;Beckett 1997;Weaver 2007). Yet it is unclear at what level Republican politics mattered most, whether the influence of Republican politics was top down or bottom up, and whether the effects of Republican politics were consistent across the entirety of mass incarceration.
Regarding level of variation, accounts emphasizing state heterogeneity suggest that conservative alliances with penal actors in certain states contributed to state heterogeneity in the pacing and timing of mass incarceration (Campbell 2018;Campbell and Schoenfeld 2013;Lynch 2009;Page 2011;Schoenfeld 2018). Other scholars emphasize how tough-on-crime politics vaulted the Republican Party to national dominance, leading to a flurry of tough-on-crime national legislation (Beckett 1997;Simon 2007;Weaver 2007). Regarding direction of political influence, some accounts of national politics argue that public influence was largely ignorable (Beckett 1997;Simon 2007), whereas others suggest that penal actors were driven to tough-on-crime politics by highly punitive conservative constituencies that were most influential at local levels (Enns 2016). Regarding temporal variation, some scholars characterize mass incarceration as a Republican effort (Beckett 1997;Weaver 2007), yet others highlight the "purpling" of punishment in the 1990s (Gottschalk 2006;Page 2011;Simon 2007), when both Republican and Democratic political leaders began to advance tough-oncrime agendas. Note: FE = fixed effects. 1 -R 2 tells us the remaining variation to be explained after accounting for fixed effects. ***p \ .001.
The BWI model and its restrictive forms offer the ability to examine each possibility. The homogenous-within effect of Republican influence offers insight to common trends among states, and the idiosyncratic effect gives insight to state-specific overtime trajectories. Random slopes also provide a strategy to assess whether the effect of Republican influence varied over time. I examine these possibilities by constructing a data set of state incarceration rates. The dependent variable is the incarceration rate per 100,000 population. I measure Republican Party strength as the proportion of Republican seats in the state house plus the proportion of Republican seats in the state senate plus a value of 1 if the governor is Republican. I measure bottom-up Republican support as the percentage of Republican Party voters in the most recent national election. The violent crime rate, unemployment rate, black population size, and Gini coefficient are also included. Table 4 describes each variable and data source. The next step is to determine which model best represents the data. To do so, I first assess how much variation exists at each level of the response. The ICC results are equivalent to results in Table 3, but I present them here to build intuition. The ICC for states is .352, meaning that 35 percent of the variance is among states. The ICC for time is .512, and the idiosyncratic ICC is .136. Of the within variation, 79 percent is unit-invariant trending (ICC = .790), and only 21 percent is idiosyncratic (ICC = .210). Random effects, ccBW, and BWI are therefore appealing choices, as the betweenvariation is sizable. An auxiliary Hausman test (Wooldridge 2010) of random effects against one-way fixed effects is significant (x 2 = 285.63, p \ .001), meaning random effects coefficients are inconsistent. The test also returns a significant result when comparing REWM with two-way fixed effects (x 2 = 59.52, p \ .001), meaning that models that use the idiosyncratic transformation should be preferred. Thus, the BWI model is the clear choice. Table 5 presents results from panel models. Models 1 and 2 present one-way and two-way fixed effects models. The one-way model shows positive effects for percent black, Republican Party strength, the Gini coefficient, unemployment rate, and violent crime rate but an insignificant effect for percentage Republican voters. Model 2 presents the two-way fixed effects results. Here, the percentage black population, Gini coefficient, and violent crime rate are again significant, but Republican Party strength and the unemployment rate are insignificant. Furthermore, the percentage Republican voters is now positive and significant, and the coefficients for percentage black, the Gini coefficient, and violent crime rate are substantially attenuated.
How do we account for these differences? Are the effect sizes and significance in model 1 an artifact of time heterogeneity? Or are the attenuated coefficients in model 2 a result of purging common trends? Model 3 presents results from REWM. The coefficients in REWM are far smaller than the one-way fixed effects coefficients. In fact, the REWM coefficients are more similar in size to the two-way fixed effects coefficients. Percentage black, Republican strength, the Gini coefficient, and violent crime rate coefficients are positive and significant. However, the percentage of Republican voters is now positive and significant, and the unemployment rate is insignificant. Consistent with Hausman test results, shrinkage in the REWM coefficients provides additional evidence that there is covariance with an unmeasured period effect.
Model 4 allows for covariance with unmeasured period effects using REWIM. Specifying separate models for the idiosyncratic variables and common trends yields a substantial gain in model fit, whereby both the Akaike information criterion (AIC) and Bayesian information criterion (BIC) decline between models 3 and 4, and the within R 2 value increases from .47 to .81. As expected, estimates of b I are (approximately) equal in models 2 and 4. However, we now also obtain estimates of b HW . The percentage black population has a positive homogenous-within effect. A 1 percent mean increase in the percentage black population increases the mean state incarceration rate by 85 people per 100,000 population. We further see both an idiosyncratic and a homogenous-within effect of violent crime on the incarceration rate. The homogenous-within effect for the unemployment rate is negative and significant, indicating the significance of the unemployment rate in model 1 can be attributed to national, rather than idiosyncratic, declines in unemployment, which has been documented elsewhere (Garland 2001;Western 2006).
We also see a positive homogenous-within effect for Republican Party strength. This result indicates that the within effect of Republican Party strength can be attributed entirely to the dominance of conservative politics in the national political arena, as Republican Party strength has no significant idiosyncratic effect on state-specific change. Turning to bottom-up politics, the homogenous-within effect for percent Republican voters is insignificant, but the idiosyncratic effect is positive and significant. Thus, national trends in incarceration were driven by Republican leadership, but state trajectories were moved by conservative voters.
Models 5 and 6 present results from ccBW and BWI. Consistent with theoretical results, the ccBW within coefficients are close approximates of the REWM coefficients, and the idiosyncratic and homogenous-within coefficients of BWI are identical to REWIM. The between coefficients in both ccBW and BWI are equivalent.
Interpreting the between coefficients, we see that states with more income inequality (higher Gini coefficients), on average, have higher incarceration rates. States with higher mean violent crime rates also tend to have higher incarceration rates. Both Republican politics variables have insignificant between effects. This means that although Republican politics played an important role in the time-varying politics of mass incarceration, partisanship mattered little for differences in state averages.
Comparing between models, we see that BWI is the most informative, with lower AIC and BIC compared with ccBW. Although we cannot compare AIC and BIC between REWIM and BWI, because the response variables are a different transformation, we can compare the total variation explained. The inclusion of between effects in BWI increases the total R 2 value from .52 in REWIM to .65 in BWI. Furthermore, decomposing the within effect increases the within R 2 value from .7 in model 1 to .81 in models 4 and 6. Including a time intercept also dramatically improves the idiosyncratic variation explained, increasing the idiosyncratic R 2 value from .07 in two-way fixed effects to .19 in models 3 to 6. The next step is to allow for time-varying Republican Party strength coefficients using random slopes. Because the interest is in temporal variation rather than between variation, I present results only from REWIM in Table 6. The variance component for the Republican strength slope is .51, indicating that there is variance across time in the effect of Republican leadership. The AIC and BIC decline compared with model 4, meaning that information is gained by including random slopes. After accounting for time-varying coefficients, the Republican Party strength idiosyncratic coefficient is positive and significant. This means that there is temporal variation in the idiosyncratic effect of Republican leadership, which aligns with prior accounts of the "purpling" of punishment in the 1990s (Page 2011;Simon 2007).
Collectively, these results illustrate how attention to the level of variation can shape substantive conclusions. The only coefficient that yields the same conclusion regardless of modeling strategy is the crime rate. By paying attention to the level of variation, we get a more nuanced story about the politics of mass incarceration. Past research emphasizes the role of conservative politics, but results reveal that top-down conservative politics had its largest effect on common trends, and the local effect of Republican leadership varied across time. By contrast, bottom-up support for Republican politics mattered little for common trends but had a sizable effect on state-specific change. We learn that Republican leadership shaped the national character of mass incarceration, yet Republican voters contributed to the "varieties of mass incarceration" experienced across states (Campbell 2018).

CONCLUSION
This study introduced a general panel model for unobserved time heterogeneity that also allows for covariance with unmeasured between effects, can include timeinvariant and unit-invariant variables, and provides the coefficient for common trends.
The two-way fixed effects model can control for unmeasured period effects and unmeasured between effects, but it cannot include unit-invariant and time-invariant variables or be used to examine common trends. Common trends may be substantively informative in many research settings. As we saw in the case of mass incarceration, even though 90 percent of the growth in incarceration was in state prisons, 51 percent of the variance in the incarceration rate was common trending. A two-way fixed effects model would lead us to conclude that Republican voters drove state incarceration rates, yet accounting for common trends tells us that, in fact, the common trend in incarceration rates is explained by Republican leadership, not Republican constituencies.
Future work would benefit from examining common trends in panel data analysis. A great appeal of the BWI framework is that common trends can be examined while still estimating the idiosyncratic effect typically provided by two-way fixed effects models. Common trends may be especially informative in studies in which cohort effects are suspected. Student grade point averages may correlate with a trend toward "helicopter parenting," where parents increasingly enforce longer study hours and barter with teachers for better grades (Calarco 2020). National crime declines may be associated with an increase in antiviolence organizations in major cities (Sharkey et al. 2017). Increases in tenure standards may correlate with increased publishing frequency among scientists (Weisshaar 2017). All of these possibilities can be explored by examining common trends. Along with the benefits elaborated here, the BWI model offers several other utilities. First, in addition to time interactions, idiosyncratic coefficients are biased if there is an unmeasured interaction with a cross-sectional unit. The models introduced here can address this possibility in a straightforward fashion by including random slopes that vary across cross-sections rather than across time. Cross-sectional random slopes can also be included in REWIM and REWM, although there will be no random crosssection intercept because the cross-section means are zero.
Second, the BWI model allows more efficient analysis of heterogeneous treatment in studies concerned with causal inference. Analysts typically stratify two-way fixed effects models by group to account for heterogeneous treatment effects, but this strategy is inefficient because each interaction decreases degrees of freedom and is prone to false discovery (Green and Kern 2012;Tian et al. 2014). Because the BWI model provides the idiosyncratic effect in a multilevel set up, it is straightforward to specify a random slope on a treatment effect to allow it to vary randomly across a group of interest. This allows for heterogeneous treatment but is more efficient than the interactioncoefficient approach.
To be sure, there are situations in which the BWI model and its restrictive cases are not appropriate. The models rely on within-unit change, so in scenarios in which the within-transformed or idiosyncratic-transformed data are not strictly exogenous, neither the BWI model nor its restrictive forms should be applied. For instance, the models are not appropriate if the transformed data are nonstationary (see Wooldridge 2010). Nor should the models be used if there is evidence of simultaneous causality, for which instrumental variables or dynamic panel models may be necessary (e.g., Arellano and Bond 1991).
Future research might extend this framework to discrete outcomes. Although it is straightforward to preprocess the data and estimate one of the models described in Table 2 with a discrete outcome, the behaviors of such models are not well understood. Estimates from between-within models can be biased when used to model discrete outcomes (Allison 2009). Hence, there may be comparable biases in BWI models.
In summary, other panel models allow for unobserved unit heterogeneity, but few alternative models exist for unobserved time heterogeneity. The two-way fixed effects model is the most widely used model for unobserved time heterogeneity, but the model is inefficient, limited in the types of variables that can be included, and cannot be used to explore common trends. The BWI model offers all the benefits of two-way fixed effects models, but it can also include time-invariant and unit-invariant variables, and it provides the effect of common trends. The BWI model is thus a useful and relatively familiar model for panel data analysis in the presence of unobserved time heterogeneity, and it provides greater utility for the analysis of common trends than do other available models.

APPENDIX
This Appendix applies Baltagi's (2006) derivation of the Mundlak (1978) model to show that the model in equation (15) is a reexpression of the one-way fixed effects model in equation (5). Consider the following one-way fixed effects equation: The time effects are a linear function of the averages of all explanatory variables across observations: where :t and u it are independent and identically distributed, normal variables with mean zero and normal variance, :t ;N (0, s 2 ), u it ;N (0, s 2 u ), and X 0 :t is a vector of time means of the within variation for the explanatory variables.
We write the one-way fixed effects model in vector form: where P is a matrix that averages the observations for each time period, and t = A e + u, A m = I N 5l T , where I N is an identity matrix with N dimensions and l T is a vector of ones of dimension T. P is the projection matrix, P = A e (A e 0 A e ) À1 A e 0 .
Because P 2 = P and PA e = A e , premultiplying equation (A4) by P yields GLS on equation (A4) yields d b W + p = (X 0 PX ) À1X 0 Pỹ, which is the GLS estimator of b HW in equation (11). We obtain b I by premultiplying by Q, where Q = I NT À P is a matrix that obtains deviations from the time-means of the within variation: because QP = 0. GLS on equation (A6) obtains c b I = (X 0 QX ) À1X 0 Qỹ, which is the usual twoway fixed effects estimator.