humball
2011-Oct-06 20:31 UTC
[R] Coefficients for lagged plm model variables not calculated
Hello, So I am afraid I am having a recurring problem that I just can't figure out. I am using the plm package to conduct a panel analysis - although I am not sure if the problem is arising as a result of the plm package or something more general. I am trying to run a fixed effects model with effects over time and individual. The model has various lags, and the problem is that these lags do not seem to always be taken into account when the plm model is calculated (i.e no coefficients are calculated for some of the lagged regressors when>summary(plm.object) is called).I have used exactly the same ".txt" file before, with exactly the same code, bar the name of the model objects, successfully. If I use <lm> instead of <plm> it also will usually take into account the lagged regressors when producing a <summary(model.object). The code I am using is: > b<-plm.data(b,index=c("E","M"))> b.fetw<-plm(B~lag(B,k=1)+Ma+lag(Ma,k=1)+Pa+lag(Pa,k=1)+Ya+lag(Ya,k=1)+F+lag(F,k=1)+CS+R+lag(R,k=1)+G+I, > data=b, model="within", effect="twoways")> summary(b.fetw)Twoways effects Within Model Call: plm(formula = B ~ lag(B, k = 1) + Ma + lag(Ma, k = 1) + Pa + lag(Pa, k = 1) + Ya + lag(Ya, k = 1) + F + lag(F, k = 1) + CS + R + lag(R, k = 1) + G + I, data = b, effect = "twoways", model = "within") Unbalanced Panel: n=7, T=146-152, N=1041 Residuals : Min. 1st Qu. Median Mean 3rd Qu. Max. -7150.00 -724.00 -73.00 -1.29 626.00 18100.00 Coefficients : Estimate Std. Error t-value Pr(>|t|) lag(B, k = 1) 3.7260e-01 3.3224e-02 11.2145 < 2.2e-16 *** Ma 1.9957e+12 1.7898e+13 0.1115 0.911242 lag(Ma, k = 1) -2.5335e+00 8.7506e-01 -2.8953 0.003883 ** Pa 9.8872e+11 4.2581e+13 0.0232 0.981480 Ya -4.0497e+12 4.8527e+13 -0.0835 0.933511 F -3.9471e+12 1.3589e+13 -0.2905 0.771531 CS -4.5666e+09 1.3941e+10 -0.3276 0.743321 R 1.8369e+13 3.8520e+14 0.0477 0.961976 G -8.0416e+13 1.8930e+14 -0.4248 0.671086 I 2.9025e+15 9.8887e+15 0.2935 0.769195 --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Total Sum of Squares: 3210200000 Residual Sum of Squares: 2794400000 F-statistic: 12.9582 on 10 and 871 DF, p-value: < 2.22e-16 #Now the model seems to have been read correctly, but there are no coefficients for lags of "Pa", "Ya", "F" or "R" I considered whether I need to convert all my data into <ts> data and then compile it with ts.union to create a time series data frame in case there was a problem with using the <lag> operator on my data frame, but my panel entities are not time series data so this approach seemed flawed. I have also used dynformula but this also seemed to lead to the same outcome. If on the other hand I used a simple linear model, there was no problem. Example:> b.fetw<-lm(B~lag(B,k=1)+Ma+lag(Ma,k=1)+Pa+lag(Pa,k=1)+Ya+lag(Ya,k=1)+F+lag(F,k=1)+CS+R+lag(R,k=1)+G+I,data=b) > summary(b.fetw)Call: lm(formula = B ~ lag(B, k = 1) + Ma + lag(Ma, k = 1) + Pa + lag(Pa, k = 1) + Ya + lag(Ya, k = 1) + F + lag(F, k = 1) + CS + R + lag(R, k = 1) + G + I, data = b) Residuals: Min 1Q Median 3Q Max -8.802e-12 -6.201e-13 -2.103e-13 1.976e-13 2.682e-10 Coefficients: (5 not defined because of singularities) Estimate Std. Error t value Pr(>|t|) (Intercept) -2.734e-11 1.715e-12 -1.595e+01 <2e-16 *** lag(B, k = 1) 1.000e+00 5.859e-17 1.707e+16 <2e-16 *** Ma -1.274e-16 2.416e-16 -5.270e-01 0.598 lag(Ma, k = 1) NA NA NA NA Pa -3.583e-16 3.419e-16 -1.048e+00 0.295 lag(Pa, k = 1) NA NA NA NA Ya 4.492e-16 5.023e-16 8.940e-01 0.371 lag(Ya, k = 1) NA NA NA NA F 2.251e-16 1.072e-16 2.099e+00 0.036 * lag(F, k = 1) NA NA NA NA CS -2.294e-20 1.378e-19 -1.660e-01 0.868 R -1.001e-15 2.933e-15 -3.410e-01 0.733 lag(R, k = 1) NA NA NA NA G 1.763e-16 1.561e-15 1.130e-01 0.910 I 1.677e-14 8.304e-14 2.020e-01 0.840 --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 It was only this afternoon, that I swear I was using the same code, and the same .txt file and having no problem!! I'm sure the answer is right in front of me, but I have run out of ideas. If anyone had any thoughts that may shed some light on this I would be most grateful. An example of an extract from my data is below. There are sporadic NA values in the Q and B columns. All other columns are filled. M is my time variable E are my entities (Q1 - Q2) Sorry if it looks a bit messy in copy /paste! M E Q B Ma Ya Pa F CS G R I 12 Q1 1.038461538 13915.3466 2280 2760 1593 13885 0 0 5.1 2.5 13 Q1 0.88 15871.51088 2194 2711 1279 17658 0 -16.76 100.9 2.5 14 Q1 1.333333333 16374.10791 2344 2857 1373 14469 0 -26.88 49 2.5 15 Q1 0.545454545 15907.40383 2770 3029 1194 13142 0 -56.17 53.8 2.5 16 Q1 0.95 17681.04616 3242 2802 1601 14545 0 -19.48 120 2.5 17 Q1 1.136363636 13422.43498 4444 3456 1811 16460 0 -30.76 286.5 2.5 18 Q1 1.384615385 15766.59589 4642 3090 2164 14604 0 -20.66 129.9 2.5 21 Q1 1.409090909 14014.20695 3458 2414 1453 12694 2920873 -65.79 21.6 167 Q2 3.777777778 11630.12367 2153 3229 4196 12605 0 -93.83 155.1 -1.25 168 Q2 4.352941176 11683.55864 1774 3192 3374 9886 0 -79.73 136.6 -1.25 171 Q2 NA NA 1394 1630 1948 9083 5308514 102.92 115.6 -1.25 172 Q2 5.315789474 13324.71911 1308 1762 1830 10341 0 -3.54 3.7 1.25 173 Q2 3.105263158 12577.84126 1313 1809 1562 9132 0 -15.99 80.2 1.25 174 Q2 1 15844.28398 1332 1750 1508 9606 0 73.94 72.2 1.25 175 Q2 2.75 13379.67057 1286 1846 1451 8781 0 51.86 111.8 1.25 Thank you! Note: For background, I am running this as part of a 2SLS analysis. This is one of the reduced equations and I am hoping to extract values of Bhat to feed back into the main structural equations. I am also having a similar problem with the other reduced equation (they are part of a two-equation system of simultaneous equations). -- View this message in context: http://r.789695.n4.nabble.com/Coefficients-for-lagged-plm-model-variables-not-calculated-tp3879867p3879867.html Sent from the R help mailing list archive at Nabble.com.
Daniel Malter
2011-Oct-07 00:32 UTC
[R] Coefficients for lagged plm model variables not calculated
You probably should not do panel data analysis but multiple time series analysis as your T is much larger than N. You only have seven units of observation but some 150 observations on each unit. Also, if the values on each unit of observation are very close to each other between t and t-1, then you induce quasi-collinearity by including both in your model. It could be that plm automatically kicks (quasi-) collinear variables (without telling you). Best, Daniel -- View this message in context: http://r.789695.n4.nabble.com/Coefficients-for-lagged-plm-model-variables-not-calculated-tp3879867p3880390.html Sent from the R help mailing list archive at Nabble.com.
Maybe Matching Threads
- trouble switching to 'plm' from 'xtabond' and Stata
- plm(..., model="within", effect="twoways") is very slow on unablanaced data (was: Re: Regressions with fixed-effect in R)
- Panel models: Fixed effects & random coefficients in plm
- plm package twoways effect problem
- plm "within" models: is the correct F-statistic reported?