4
$\begingroup$

From Nick Huntington-Klein, The Effect:

Fixed effects is a method of controlling for all variables, whether they’re observed or not, as long as they stay constant within some larger category. How can we do that? Simple! We just control for the larger category, and in doing so we control for everything that is constant within that category.11 If you prefer, we’re controlling for a variable higher up on the hierarchy of our hierarchical data.

What does it mean for a variable to be “constant within some larger category?” For example, let’s say we’re looking at the effect of rural towns getting electricity on their productivity. An obvious back door is geography. Rural towns up in the mountainous hillside will be more difficult to electrify, and also might be different in their productivity for other reasons.

Suppose that I have a dataset where I have fixed effects that come in both multiplicatively and additively.

e.g. Let's say I'm trying to see the relationship between apples consumed and income. I observe household apples, and I suspect that Bob MIS-reports his consumed apples. The value is always 0.5x true apples. While, on the other hand, Alice's survey data is always accurate with no measurement error. This is multiplicatively constant across the category "individual".

In addition to this, for the years after 2000, a new survey came out, and I suspect that now all of the household survey apples measures had 0.3 added to each measure. This is additively constant across the category "year".

If I knew these numbers (+0.3 and 0.5x), then I could subtract them off my data. But, let's say I don't know these numbers, and only have a suspicion that some of my data has both multiplicative and additive effects that potentially confound any estimation.

Moreover, let's say that the true relationship between income and apples consumed is given by

$$\log(\text{income}) = 0.3 \log(\text{apples})$$

How do I estimate the true relationship, given I observe $$\text{observed apples} = \left(\text{apples} + 0.3 * \text{I}(\text{year}>=2000)\right)*\begin{cases}0.5 & ID = Bob\\1 & ID \ne Bob\end{cases}$$

If the effect was multiplicative, then I could just use a typical fixed effect regression. If the fixed effect was additive, then I could just de-mean the observations and run the regression that way. But since this has both, if I use a log-log model with fixed effects, then the additively constant effect is no longer constant within time.

Here is the code I've used. Thanks a bunch in advance!

library(data.table)
library(fixest)
library(modelsummary)

DT <- CJ(ID = c("Bob", "Alice"),
         year = 1992:2020)

# make observations
DT[, truth := runif(nrow(DT))]

# create fixed effects
DT[, ID_FE := ifelse(ID == "Bob", 0.5, 1)]
DT[, year_FE := ifelse(year >= 2000, 0.3, 0)]

# create observed variable:
DT[, observed := (truth + year_FE) * ID_FE]

# create additive means
DT[, ID_mean := mean(observed), by = .(ID)]
DT[, year_mean := mean(observed), by = .(year)]

# create multiplicative means
DT[, ID_log_mean := mean(log(observed)), by = .(ID)]
DT[, year_log_mean := mean(log(observed)), by = .(year)]
DT[, ln_observed := log(observed)]

# create differences for manual FE estimation
DT[, diff_ln_observed := ln_observed - ID_log_mean - year_log_mean]
DT[, diff_observed := observed - ID_mean - year_mean]

# get actual Y
DT[, Y := truth ^ 0.3]
DT[, ln_Y := log(Y)]

# run regression
true_relationship <- lm(ln_Y~log(truth),data = DT)
m1 <- lm(ln_Y ~ diff_ln_observed, data = DT)
twfe <-feols(ln_Y ~ log(observed) |as.factor(ID) + as.factor(year),data = DT)
msummary(list(true_relationship, m1, twfe))
$\endgroup$
2
  • $\begingroup$ In your code, the line: DT[, year_FE := ifelse(year >= 2000, 0.3, 1)] does not correspond to your equation: $$0.3 * \text{I}(\text{year}>=2000)$$ unless you change it to: $$ 1 - 0.7 * \text{I}(\text{year}>=2000)$$ $\endgroup$
    – Bertrand
    Feb 11, 2022 at 19:50
  • $\begingroup$ My bad. Changed the code to DT[, year_FE := ifelse(year >= 2000, 0.3, 0)] $\endgroup$
    – Daycent
    Feb 14, 2022 at 17:04

1 Answer 1

3
$\begingroup$

Without random term, this exercise is closer to nonlinear equations solving than to econometrics. If the true relationship between income and apples is: $$ \log( y_{nt} ) = \gamma \log( x_{nt}),$$ but instead of observing ${x_{nt}}$, the econometrician actually observes $$x^*_{nt}= \delta_n (x_{nt} + u_t), $$ then, using observed variables, we have $$ \log( y_{nt} ) = \gamma \log( \beta_{0t} + \beta_{1n} x^*_{nt} )$$ with $$ \beta_{0t} := - u_t $$ $$ \beta_{1n} := \frac{1}{\delta_n}. $$

If there are more observations than parameters: $NT>N+T+1,$ which is the case in your example, all the parameters can be computed exactly, using a nonlinear solver minimizing (for instance): $$ \left( \log( y ) - f(\gamma,\{\beta_{0t}\}_{t=1}^T,\{\beta_{1n}\}_{n=1}^N; x^* \right)^T\left( \log( y ) - f(\gamma,\{\beta_{0t}\}_{t=1}^T,\{\beta_{1n}\}_{n=1}^N; x^* \right) $$ in $(\gamma, \{\beta_{0t}\}_{t=1}^T,\{\beta_{1n}\}_{n=1}^N ).$

Note that it a bit is strange that apples (consumption ?) determine income, usually it is the other way round. With this specification, individuals have an incentive to buy apples in order to increase their income,... indefinitely if apples are cheap enough: endogeneity occurs, but it is not a problem here, as there is no random term.

Here is a R-code illustrating the claim:

# -------------------------
library(optimx)

dat_dum_T = rbind(1,1) %x% matrix( c( rep( 0, 8 ), rep( 1, 21 )), ncol=1 ) 
dat_dum_N = diag(1,nrow=2) %x% rep( 1, 29 )

colnames( dat_dum_N ) <- c( paste0("dum_N_", 1:2 ) )

#
# This function computes the sum of squared residuals for different 
# parameter values
#
SSR_f = function( param, Data=DT ){
  
  gamma = param[1]
  par_dum_N = matrix( param[2:3], ncol=1 )
  par_dum_T = param[4]

  rownames( par_dum_N ) = paste0( "beta_N_", seq(1:2))

  ln_y = Data[,"ln_Y"]
  x_obs = Data[,"observed"]

  dum_N = par_dum_N[1]*dat_dum_N[,1] + par_dum_N[2]*dat_dum_N[,2] 
  dum_T = par_dum_T*dat_dum_T
    
  # The observed and true x are related by 
  # x_nt = x_obs_nt/dum_n + par_dum_t

  SSR = as.numeric( sum( ( ln_y - gamma*( log( x_obs/dum_N - dum_T ) ) )^2 ) )
  return( SSR )
}

true_val = c( 0.3, 1, 0.5, 0.3 )
SSR_f( true_val, DT )

par_0 = c( 0.5, 0.5, 1, 0 )
names(par_0) = c( "gamma","dum_N_1","dum_N_2", "dum_T" )

# check if starting values are admissible (and cause no numerical problem)
SSR_f( par_0, DT )

# The nonlinear numerical minimization procedure
optimx( par=par_0, fn=SSR_f, method="Nelder-Mead", control = list( trace=4, maxit=1000 ) )
$\endgroup$
3
  • $\begingroup$ Hi @Bertrand, thanks for replying. I did not think of doing it this way, and tbh I'm not too familiar with nonlinear solvers, but what this is saying is that if I try to minimize the distance between observed and predicted log income (under a specific form for the predicted log income), then I can estimate the parameters. Why did you say that this would not work if there was an error term? Doesn't the solver compute (with certain confidence intervals) the same parameters, even if there is an error term? $\endgroup$
    – Daycent
    Feb 10, 2022 at 17:20
  • $\begingroup$ Also, what if I relax the econometrician's understanding of the form of the relationship? e.g. $$x_{nt}^{*} = \delta_na_tx_{nt}+u_t+b_n+\epsilon_{nt}$$ OR $$x_{nt}^{*} = \delta_n(a_tx_{nt}+u_t+b_n)+\epsilon_{nt}$$ This would still work, right? I would just use the nonlinear solver for each functional form of the relationship that I suspect, and then compare estimates given different functional forms, correct? As long as $NT>2N+2T+1$? $\endgroup$
    – Daycent
    Feb 10, 2022 at 17:21
  • 1
    $\begingroup$ @Daycent: I wanted to say that if you set $\varepsilon_{nt}=0$ in $$ \log( y_{nt} ) = \gamma \log( x_{nt})+\varepsilon_{nt},$$ then the (nonlinear) sum of squared residuals will be exactly zero in your case, and the solution will be exact and not random. I should add a R code in my answer... to illustrate the claim. When $\varepsilon_{nt}$ is there, it is better not trying to estimate the "incidental" parameters but rather parameters of their distribution. See Wooldridge textbook for details. In your example $N=2$ and $T=29$ the sample is too small to obtain "good" parameter estimates. $\endgroup$
    – Bertrand
    Feb 10, 2022 at 18:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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