0
$\begingroup$

I am doing a multiple regression analysis and I wanted to inspect the time effect by using factor(Year) in R. However, I got the following summary results:

Do you have any suggestions why I get NA values?

Thank you!

lm(formula = Market_Cap ~ MarketCap_Lag + GDP_growthR + Ex_Rate + 
    Volatility_IR + FDI + Real_IR + dfY, data = pdata)

Residuals:
ALL 14 residuals are 0: no residual degrees of freedom!

Coefficients: (6 not defined because of singularities)
              Estimate Std. Error t value Pr(>|t|)
(Intercept)    8.31618         NA      NA       NA
MarketCap_Lag -2.19963         NA      NA       NA
GDP_growthR    0.06182         NA      NA       NA
Ex_Rate       -0.11464         NA      NA       NA
Volatility_IR -0.01256         NA      NA       NA
FDI           -0.07583         NA      NA       NA
Real_IR       -5.72360         NA      NA       NA
dfY2007        1.13081         NA      NA       NA
dfY2008        1.57863         NA      NA       NA
dfY2009        1.14343         NA      NA       NA
dfY2010        0.61157         NA      NA       NA
dfY2011        0.44408         NA      NA       NA
dfY2012        0.63869         NA      NA       NA
dfY2013        0.33754         NA      NA       NA
dfY2014             NA         NA      NA       NA
dfY2015             NA         NA      NA       NA
dfY2016             NA         NA      NA       NA
dfY2017             NA         NA      NA       NA
dfY2018             NA         NA      NA       NA
dfY2019             NA         NA      NA       NA

Residual standard error: NaN on 0 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared:      1, Adjusted R-squared:    NaN 
F-statistic:   NaN on 13 and 0 DF,  p-value: NA
$\endgroup$
3
  • 1
    $\begingroup$ How many observations do you have? $\endgroup$
    – Adrian
    Commented Jan 30, 2021 at 18:04
  • $\begingroup$ Notice the "Coefficients: (6 not defined because of singularities)" message in the output $\endgroup$
    – Adrian
    Commented Jan 30, 2021 at 18:05
  • $\begingroup$ @Adrian I think you can see from the screenshot, it is from 2005 to 2019. Yes, but I inspected the VIF, and none of the variables in that regression is above 4. $\endgroup$
    – S_Star
    Commented Jan 30, 2021 at 18:58

1 Answer 1

2
$\begingroup$

Notice the warning message at the top of the model summary: ALL 14 residuals are 0. This suggests the model was fit using only 14 observations. You're estimating 20 parameters using only 14 independent pieces of information.

I am doing a multiple regression analysis and I wanted to inspect the time effect by using factor(Year) in R.

You don't explicitly use factor(year) in your model formula, though R recognizes your measure of time (i.e., dfY) as 'categorical' by including dummy variables for each category, appending the labels to the variable name accordingly. Be careful in the future as R may 'dummy out' a measure with many levels, which may be more variables than you can afford.

Do you have any suggestions why I get NA values?

Again, you have too few $n$ observations to estimate all $p$ predictor variables. As a minimum, you require at least $n$ observations to estimate $p$ predictors. Your instinct based upon the warning message was to inspect the linear association between two or more of your input variables, but this is not your problem. You simply have more predictors than observations!


Considerations:

I see you tagged "fixed effects model" in your question. It suggests you may have wanted to fit a panel model. If this is the case, something is wrong. Do you observe multiple entities (e.g., individuals, firms, counties, etc.) over time? If so, your data frame is not in the proper format. It should be organized in long format, with each unit observed over the 13-year time period.

This brings me to my next point. You indicated in the comments that the time variation spans from 2005 to 2019. If this was so, then your output would have displayed a coefficient for 2006 as well; R will estimate the time effects in their level order, thus dropping the more recent years. I'm sure this was a minor oversight, but make sure your factor levels are ordered properly as well.

If the model really only has 14 observations, then you must model year (i.e., dfY) in a different way. Estimating year fixed effects chews up way too many degrees of freedom. A similar answer to this question recommends at least $50p$ observations to reliably identify effects with reasonable power, while others have suggested roughly 10–20 observations per parameter (see here for more information).

$\endgroup$
5
  • $\begingroup$ Thomas thank you for your detailed answer. It is multiple regression as I have only one country and I want to inspect the time effect, and I was suggested to use dummy and I found that factor() in R is used for it. $\endgroup$
    – S_Star
    Commented Jan 31, 2021 at 9:35
  • $\begingroup$ I noticed that 2006 is displayed. I also read the links you have recommended, and I see the point. Does this mean that I should not look up for any effects as I will use these observations? As I understood having monthly, weekly or daily data is the best perfect for searching the time effect in multiple regression? Finally, I haven't used PCA before, but I planning to do for my institutional factors. I guess I can use PCA as a variable, right? $\endgroup$
    – S_Star
    Commented Jan 31, 2021 at 9:35
  • $\begingroup$ In addition, do you have any recommendation for a book that explains effects in multiple regression (not panel) ? $\endgroup$
    – S_Star
    Commented Jan 31, 2021 at 9:37
  • $\begingroup$ Presently, you have too few observations to model time as a factor variable. And unless I am mistaken, you use PCA as a technique, not as a variable. PCA is a method for reducing the dimensionality of your data. Peruse the answers here for some helpful tips. As for a learning aid, I would invest in the text Regression and Other Stories by Gelman et al. (2020). It is loaded with great examples and R code. $\endgroup$ Commented Feb 1, 2021 at 22:35
  • $\begingroup$ Thank you very much! $\endgroup$
    – S_Star
    Commented Feb 6, 2021 at 20:08

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.