Plotting Residuals

I am getting confused with residuals. For my project we are running a multivariate regression. We have used foels to run the regression. First off is it possible to even create a residual plot with 5 dependent variables along with the 10 ind variables? If so is this simple plot function the way to do so? Or is there a better way? It appears that not all of my variables are showing up on the code when posted.

model1 <- feols(c(GI_2000, GI_2005, GI_2010, GI_2015, GI_2020) ~  Rel_Gal_2009 + Rel_ComOver + Rel_Com40u + Rel_Com40. + RDI_2010 + EFI_2004 + CFI_2004 + HDI_2019 + as.factor(Pol_Reg2000) + as.factor(Pol_Reg2020), data = Religion)
  summary(model1)
  etable(model1)
  dftest = (model1)
  plot(resid(model1))

See the FAQ: How to do a minimal reproducible example reprex for beginners. Without Religion, it's hard to see what's going on.

unfortunately since I am a new user I cannot upload files.. Any suggestions around this issue?

You are not supposed to. Read the guide on the link technocrat gave you and try to provide a proper reproducible example.

1 Like

Hopefully I did this correctly.. For the regression I posted WVS_2017_2020 is not used. Would it be more useful if the 10 countries I provide have observations in each of the variables. Since when running the regression I only end up with 80 total observations that get used.

Religion <- tibble::tribble(
                           ~Country, ~GI_2000, ~GI_2005, ~GI_2010, ~GI_2015, ~GI_2020, ~WVS_2017_2020, ~Rel_Gal_2009, ~Rel_ComOver, ~Rel_Com40u, ~`Rel_Com40+`, ~RDI_2010, ~EFI_2004, ~CFI_2004, ~HDI_2019, ~Pol_Reg2000, ~Pol_Reg2020,
                      "Afghanistan", -1.98112, -1.52447, -1.74212, -1.47594, -1.66635,             NA,          0.97,         0.92,        0.92,          0.93,       0.1,     0.751,     0.679,     0.511,           0L,           1L,
                          "Albania", -0.61644, -0.50955,  -0.1756,  -0.0179,  -0.1043,             NA,          0.39,         0.15,        0.12,          0.19,       3.7,     0.097,     0.082,     0.795,           1L,           2L,
                          "Algeria", -1.06009, -0.61914, -0.87371, -0.85393, -0.86697,             NA,          0.95,         0.73,        0.69,          0.81,       0.5,      0.32,     0.237,     0.748,           1L,           1L,
                          "Andorra", 1.349465, 1.303461, 1.337512, 1.346724, 1.480983,          0.095,            NA,           NA,          NA,            NA,       2.2,        NA,        NA,     0.868,           NA,           NA,
                           "Angola", -1.65688, -1.20684, -1.01531, -1.01078, -0.88531,             NA,            NA,           NA,          NA,            NA,         2,     0.756,     0.242,     0.581,           0L,           1L,
              "Antigua and Barbuda", 0.751698, 0.637114, 0.800987, 0.580114, 0.461485,             NA,            NA,           NA,          NA,            NA,       1.5,        NA,        NA,     0.778,           NA,           NA,
                        "Argentina", 0.077514, -0.23133, -0.26673, -0.31302, -0.12324,          0.243,          0.66,         0.43,        0.35,          0.51,         3,     0.255,         0,     0.845,           2L,           2L,
                          "Armenia",  -0.4881, -0.29829, -0.30587, -0.27161, -0.07541,             NA,          0.73,         0.53,        0.54,          0.53,       0.3,     0.134,     0.124,     0.776,           1L,           1L,
                        "Australia", 1.654658, 1.571539, 1.595423, 1.550205, 1.484216,          0.138,            NA,         0.18,        0.17,          0.19,       5.6,     0.149,     0.147,     0.944,           3L,           3L

Try
model1$GI_2000$residuals

etc.

So I would have a residual plot for each? So GI_2000, GI_2005 etc..? Not just 1 plot combined together?

Yes, although as with any other variables you could arrange to put them on the same plot.

What would be your suggestion then to put them into a plot so I don't just get numbers?

plot(model1$GI_2000$residuals) will plot points in the order the data appears in the file. You might think if you want to compare the residuals against some other variable. Than something like

plot(some_other_variable, model1$GI_2000$residuals)

Do you have any idea what I would be looking at with this code then?

I ran the plot(mode1$GI_2000$residuals) and they seem to be much different than when I run the above code.

I believe that resid(model1) gives you one column of residuals for each of your dependent variables.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.