Re: [R] "2 not defined because of singularities" appearing after introducing Fixed Effects
Sorry, please nevermind. It seems to have been an econometrical problem after all. (A variable consisting of 2 or more of the 150 Country-Dummies for the fixed effects causes perfect multicollinearity as well. So does a variable that differs over cross-sections but not over periods, seemingly. I was not aware before...) -- View this message in context: http://r.789695.n4.nabble.com/2-not-defined-because-of-singularities-appearing-after-introducing-Fixed-Effects-tp2327047p2328686.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] "2 not defined because of singularities" appearing after introducing Fixed Effects
The set runs fine without the fixed effects. However, once I add the "+factor(HostCode)"-part, it throws out two variables. The africa-dummy thrown out certainly does not exhibit perfect multicollinearity, I checked that. The litrate variable is continuous and therefore cannot be perfectly related to the FE-dummies introduced by R. This is the used code: > cdmoutcome<- lm(log(value)~#factor(year) > +factor(HostCode) > +log(gdppcpppconst)+log(gdppcpppconstAII) > +log(co2eemisspc)+log(co2eemisspcAII) > +fdiboth > +odapartnertohost > +infraindex > +litrate > +africa > +imr > , data=cdmdata2, subset=zero==1) > summary(cdmoutcome > These are the results (please expand to see the relevant part): > Coefficients: (2 not defined because of singularities) > Estimate Std. Error t value Pr(>|t|) > (Intercept)1.144e+01 3.077e+01 0.372 0.7103 > factor(HostCode)7 -3.296e+00 4.617e+00 -0.714 0.4759 > factor(HostCode)19-1.242e+01 8.764e+00 -1.417 0.1575 > factor(HostCode)20 1.548e+00 4.087e+00 0.379 0.7052 > factor(HostCode)23-4.183e+00 3.786e+00 -1.105 0.2702 > factor(HostCode)29-1.473e+01 1.168e+01 -1.261 0.2083 > factor(HostCode)35 7.631e-01 7.870e-01 0.970 0.3330 > factor(HostCode)36 7.700e+00 4.340e+00 1.774 0.0771 . > factor(HostCode)37-6.549e+00 4.844e+00 -1.352 0.1774 > factor(HostCode)42-1.020e+01 5.074e+00 -2.010 0.0453 * > factor(HostCode)51 1.738e+00 3.206e+00 0.542 0.5882 > factor(HostCode)52 1.032e+00 2.742e+00 0.376 0.7069 > factor(HostCode)53 3.210e+00 2.768e+00 1.160 0.2471 > factor(HostCode)54-8.851e+00 6.340e+00 -1.396 0.1637 > factor(HostCode)60 2.146e+00 3.531e+00 0.608 0.5438 > factor(HostCode)65-7.436e+00 5.958e+00 -1.248 0.2129 > factor(HostCode)70-9.056e+00 6.711e+00 -1.349 0.1782 > factor(HostCode)75-5.239e+00 5.696e+00 -0.920 0.3585 > factor(HostCode)78-4.482e+00 5.185e+00 -0.864 0.3881 > factor(HostCode)79 4.259e-01 3.777e+00 0.113 0.9103 > factor(HostCode)84 2.035e+00 3.374e+00 0.603 0.5468 > factor(HostCode)94-2.008e+01 1.315e+01 -1.528 0.1276 > factor(HostCode)1066.563e+00 3.027e+00 2.168 0.0309 * > factor(HostCode)1135.919e+00 1.010e+00 5.858 1.23e-08 *** > factor(HostCode)115 -2.429e+00 4.274e+00 -0.568 0.5702 > factor(HostCode)1171.240e+01 5.779e+00 2.146 0.0327 * > factor(HostCode)119 -8.822e-01 4.118e+00 -0.214 0.8305 > factor(HostCode)123 -2.530e+01 1.616e+01 -1.566 0.1185 > factor(HostCode)126 -5.210e+00 6.782e+00 -0.768 0.4430 > factor(HostCode)128 -7.044e+00 8.246e+00 -0.854 0.3937 > factor(HostCode)132 -3.570e+00 6.508e+00 -0.548 0.5838 > factor(HostCode)134 -1.756e+00 3.905e+00 -0.450 0.6534 > factor(HostCode)135 -3.403e+00 7.444e+00 -0.457 0.6479 > factor(HostCode)137 -7.738e+00 6.175e+00 -1.253 0.2111 > factor(HostCode)138 -1.066e+01 7.116e+00 -1.498 0.1351 > factor(HostCode)1601.251e+00 4.889e+00 0.256 0.7982 > factor(HostCode)162 -1.337e+01 8.742e+00 -1.529 0.1273 > factor(HostCode)171 -1.804e+00 2.404e+00 -0.750 0.4537 > factor(HostCode)1763.873e+00 2.711e+00 1.428 0.1542 > factor(HostCode)180 -3.186e+01 1.734e+01 -1.837 0.0671 . > factor(HostCode)185 -2.367e+01 5.831e+00 -4.059 6.30e-05 *** > factor(HostCode)189 -4.209e+00 5.328e+00 -0.790 0.4302 > log(gdppcpppconst) 1.116e+00 3.849e+00 0.290 0.7721 > log(gdppcpppconstAII) -7.209e-01 7.850e-01 -0.918 0.3592 > log(co2eemisspc) -1.149e+01 6.230e+00 -1.845 0.0661 . > log(co2eemisspcAII) -2.182e-01 3.851e-01 -0.567 0.5714 > fdiboth1.707e-04 1.055e-04 1.619 0.1066 > odapartnertohost 2.886e-03 1.354e-03 2.132 0.0338 * > infraindex 4.394e+01 9.097e+00 4.830 2.18e-06 *** > litrate NA NA NA NA > africaNA NA NA NA > imr1.470e+00 7.173e-01 2.049 0.0414 * > Does anyone know how to solve this problem so I can use the FE and still keep the variables in? (Or what I made have wrong on a technical level?) -- View this message in context: http://r.789695.n4.nabble.com/2-not-defined-because-of-singularities-appearing-after-introducing-Fixed-Effects-tp2327047p2327047.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http:
Re: [R] Regression Error: Otherwise good variable causes singularity. Why?
@JLucke: As for the africa variable: I took it out of the model, so that we can exclude this variable itself and collinearity between the africa and the litrate variable as causes for the litrate-problem. This also removed the singularity remark at the top. However, the problem with litrate-variable seen as many factors remains. Just to clarify: The second results table is fictional to explain where I was headed with my regression. Anyway, thanks for the quick answer. @David: Thanks for the pointer. It was in fact a bad variable, but I created it myself. I changed the set halfway in between my calculations and thought I had adjusted everything. It turns out, that I forgot to adjust the set-length which is re-set in between the two steps of my Heckman-procedure. In any case: Thanks for the quick and helpful reply. :-) -- View this message in context: http://r.789695.n4.nabble.com/Regression-Error-Otherwise-good-variable-causes-singularity-Why-tp2322780p2322925.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Regression Error: Otherwise good variable causes singularity. Why?
This command cdmoutcome<- glm(log(value)~factor(year) > +log(gdppcpppconst)+log(gdppcpppconstAII) > +log(co2eemisspc)+log(co2eemisspcAII) > +log(dist) > +fdiboth > +odapartnertohost > +corrupt > +log(infraindex) > +litrate > +africa > +imr > , data=cdmdata2, subset=zero==1, gaussian(link = > "identity")) results in this table Coefficients: (1 not defined because of singularities) > Estimate Std. Error t value Pr(>|t|) > (Intercept)1.216e+01 5.771e+01 0.211 0.8332 > factor(year)2006 -1.403e+00 5.777e-01 -2.429 0.0157 * > factor(year)2007 -2.799e-01 7.901e-01 -0.354 0.7234 > log(gdppcpppconst) 2.762e-01 5.517e+00 0.050 0.9601 > log(gdppcpppconstAII) -1.344e-01 9.025e-01 -0.149 0.8817 > log(co2eemisspc) 5.655e+00 2.903e+00 1.948 0.0523 . > log(co2eemisspcAII) -1.411e-01 4.245e-01 -0.332 0.7399 > log(dist) -2.938e-01 4.023e-01 -0.730 0.4658 > fdiboth1.326e-04 1.133e-04 1.171 0.2425 > odapartnertohost 2.319e-03 1.437e-03 1.613 0.1078 > corrupt1.875e+00 3.313e+00 0.566 0.5718 > log(infraindex)4.783e+00 1.091e+01 0.438 0.6615 > litrate0.47 -2.485e+01 3.190e+01 -0.779 0.4365 > litrate0.499 -1.657e+01 2.591e+01 -0.639 0.5230 > litrate0.523 -2.440e+01 3.427e+01 -0.712 0.4769 > litrate0.528 -9.184e+00 1.379e+01 -0.666 0.5060 > litrate0.595 -2.309e+01 2.776e+01 -0.832 0.4062 > litrate0.66 -1.451e+01 2.734e+01 -0.531 0.5961 > litrate0.675 -1.707e+01 2.813e+01 -0.607 0.5444 > litrate0.68 -6.346e+00 1.063e+01 -0.597 0.5509 > litrate0.699 2.717e+00 3.541e+00 0.768 0.4434 > litrate0.706 -1.960e+01 2.933e+01 -0.668 0.5046 > litrate0.714 -2.586e+01 4.002e+01 -0.646 0.5186 > litrate0.736 5.641e+00 1.561e+01 0.361 0.7181 > litrate0.743 -2.692e+01 4.253e+01 -0.633 0.5273 > litrate0.762 -2.208e+01 3.100e+01 -0.712 0.4767 > litrate0.802 -2.325e+01 3.766e+01 -0.617 0.5375 > litrate0.847 -2.620e+01 3.948e+01 -0.664 0.5075 > litrate0.86 -3.576e+01 4.950e+01 -0.722 0.4707 > litrate0.864 -4.482e+01 6.274e+01 -0.714 0.4755 > litrate0.872 -1.946e+01 2.715e+01 -0.717 0.4739 > litrate0.877 -2.710e+01 3.702e+01 -0.732 0.4646 > litrate0.879 -3.460e+01 5.147e+01 -0.672 0.5020 > litrate0.886 -3.276e+01 4.860e+01 -0.674 0.5008 > litrate0.889 -4.120e+01 5.755e+01 -0.716 0.4746 > litrate0.904 -2.282e+01 2.985e+01 -0.764 0.4453 > litrate0.91 -3.478e+01 5.037e+01 -0.691 0.4904 > litrate0.923 -1.762e+01 2.551e+01 -0.691 0.4902 > litrate0.925 -2.445e+01 3.611e+01 -0.677 0.4990 > litrate0.926 -2.995e+01 4.565e+01 -0.656 0.5123 > litrate0.928 -2.839e+01 3.933e+01 -0.722 0.4710 > litrate0.937 -2.571e+01 3.795e+01 -0.677 0.4986 > litrate0.94 -2.109e+01 3.051e+01 -0.691 0.4900 > litrate0.959 -2.078e+01 2.895e+01 -0.718 0.4735 > litrate0.96 -3.403e+01 4.798e+01 -0.709 0.4787 > litrate0.962 -4.084e+01 5.755e+01 -0.710 0.4785 > litrate0.971 -3.743e+01 5.247e+01 -0.713 0.4761 > litrate0.98 -3.709e+01 5.170e+01 -0.717 0.4737 > litrate0.986 -2.663e+01 4.437e+01 -0.600 0.5488 > litrate0.991 -3.045e+01 4.166e+01 -0.731 0.4654 > litrate1 -2.732e+01 4.459e+01 -0.613 0.5405 > africaNA NA NA NA > imr2.160e+00 9.357e-01 2.309 0.0216 * although it should result in something similar to this: Coefficients: (1 not defined because of singularities) > Estimate Std. Error t value Pr(>|t|) > (Intercept)1.216e+01 5.771e+01 0.211 0.8332 > factor(year)2006 -1.403e+00 5.777e-01 -2.429 0.0157 * > factor(year)2007 -2.799e-01 7.901e-01 -0.354 0.7234 > log(gdppcpppconst) 2.762e-01 5.517e+00 0.050 0.9601 > log(gdppcpppconstAII) -1.344e-01 9.025e-01 -0.149 0.8817 > log(co2eemisspc) 5.655e+00 2.903e+00 1.948 0.0523 . > log(co2eemisspcAII) -1.411e-01 4.245e-01 -0.332 0.7399 > log(dist) -2.938e-01 4.023e-01 -0.730 0.4658 > fdiboth1.326e-04 1.133e-04 1.171 0.2425 > odapartnertohost 2.319e-03 1.437e-03 1.613 0.1078 > corrupt1.875e+00 3.313e+00 0.566 0.5718 > log(infraindex)4.783e+00 1.091e+01 0