Dear Kailas Gokhale,
The negative individual variance is not a problem with your code or plm.
It a property of your data. Please check the posts of Giovanni Millo on
this topic:
[R] R: plm random effect: the estimated variance of the individual
effect is negative
Millo Giovanni Giovanni_Millo at Generali.com
Sat Jan 5 10:10:01 CET 2013
You can find the posts in the archive by rseek.org.
Kind regards,
Nina Sch?nfelder
-----
FernUniversit?t in Hagen
Fakult?t f?r Wirtschaftswissenschaft
Lehrstuhl f?r Volkswirtschaftslehre,
insbes. Makro?konomik
58084 Hagen
E-Mail: Nina.Schoenfelder at FernUni-Hagen.de
Telefon: +49 2331 987 - 2379
Fax: +49 2331 987 - 391
Hausanschrift:
Informationszentrum (IZ, ehemals TGZ)
Universit?tsstr. 11
Raum B110
Am 06.06.2017 um 12:00 schrieb r-help-request at
r-project.org:> Message: 1
> Date: Mon, 5 Jun 2017 15:41:23 +0530
> From: Kailas Gokhale<kls.gokhale at gmail.com>
> To:r-help at r-project.org
> Subject: [R] issues in plm using random effect model
> Message-ID:
> <CAMO91N4oCvTf1ZkHLqQ4t3SAbVw=VYLM-6JKt49CPbw+kUBiGg at
mail.gmail.com>
> Content-Type: text/plain; charset="UTF-8"
>
> Dear Sir,
>
> Thank you for accepting my request for registration on this site.
> I am trying to solve panel data problems using plm package , but while
> suing random effect model i am getting following messege saying
> "
>
> Warning message:In sqrt(sigma2) : NaNs produced
>
> "
>
> In some other cases i am getting message saying where TSS = NA , that I am
> not understanding
> I am sending you my code along with out put.
>
> Kindly help me .
>
> I am sending you my code and output for your kind reference. data file is
> also attached
>
>
> rm(list=ls())
> library(MASS)
> library(bdsmatrix)
> library(zoo)
> library(nlme)
> library(sandwich)
> library(car)
> library(lmtest)
> library(plm)
>
> data1<- read.csv(file.choose(),header=TRUE,sep=",")
> D<-na.omit(data1)
> attach(D)
> Pdata<-plm.data(D, index=c("CT","T"))
>
> pool11<- plm(Y~X1+X2,data = Pdata, model="pooling")
> # pool21<- plm(Equity.dividend.1~ Profit.after.tax.1+ LaggedDivd.1+
> log(Size.1)+factor(CompanyName)-1,data = Pdata, model="pooling")
> fixed.mod1<- plm(Y~X1+X2,data = Pdata, model="within")
> rand.mod1<- plm(Y~X1+X2,data = Pdata, model="random")
>
>
> summary(pool11)
> summary(fixed.mod1)
> summary(fixef(fixed.mod1))
> summary(rand.mod1)
>
>
> ##################output####################
>
> Oneway (individual) effect Pooling Model
>
> Call:
> plm(formula = Y ~ X1 + X2, data = Pdata, model = "pooling")
>
> Unbalanced Panel: n=6, T=4-6, N=34
>
> Residuals :
> Min. 1st Qu. Median 3rd Qu. Max.
> -19.400 -9.810 -0.648 8.490 23.900
>
> Coefficients :
> Estimate Std. Error t-value Pr(>|t|)
> (Intercept) 25.229162 6.858418 3.6786 0.0008847 ***
> X1 0.016438 0.046905 0.3504 0.7283744
> X2 -2.231250 2.220346 -1.0049 0.3227198
> ---
> Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1
>
> Total Sum of Squares: 5082
> Residual Sum of Squares: 4892.7
> R-Squared: 0.037241
> Adj. R-Squared: 0.033955
> F-statistic: 0.599566 on 2 and 31 DF, p-value: 0.55529>
> summary(fixed.mod1)Oneway (individual) effect Within Model
>
> Call:
> plm(formula = Y ~ X1 + X2, data = Pdata, model = "within")
>
> Unbalanced Panel: n=6, T=4-6, N=34
>
> Residuals :
> Min. 1st Qu. Median 3rd Qu. Max.
> -24.0000 -8.0400 -0.0795 6.6300 25.1000
>
> Coefficients :
> Estimate Std. Error t-value Pr(>|t|)
> X1 0.065306 0.060090 1.0868 0.2871
> X2 -3.082215 2.514602 -1.2257 0.2313
>
> Total Sum of Squares: 4791.9
> Residual Sum of Squares: 4380.7
> R-Squared: 0.085822
> Adj. R-Squared: 0.065628
> F-statistic: 1.22042 on 2 and 26 DF, p-value: 0.31146>
> summary(fixef(fixed.mod1)) Estimate Std. Error t-value Pr(>|t|)
> A 33.2672 10.4360 3.1877 0.0014340 **
> B 21.9300 9.2930 2.3598 0.0182831 *
> C 27.6590 7.9522 3.4781 0.0005049 ***
> D 21.9369 9.4271 2.3270 0.0199647 *
> E 17.6243 8.6149 2.0458 0.0407766 *
> F 23.8578 9.2198 2.5877 0.0096625 **
> ---
> Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1>
> summary(rand.mod1)Oneway (individual) effect Random Effect Model
> (Swamy-Arora's transformation)
>
> Call:
> plm(formula = Y ~ X1 + X2, data = Pdata, model = "random")
>
> Unbalanced Panel: n=6, T=4-6, N=34
>
> Effects:
> var std.dev share
> idiosyncratic 168.49 12.98 1.117
> individual -17.60 NA -0.117
> theta :
> Min. 1st Qu. Median Mean 3rd Qu. Max.
> -0.6366 -0.6366 -0.6366 -0.5983 -0.6366 -0.3106
>
> Residuals :
> Min. 1st Qu. Median Mean 3rd Qu. Max.
> -21.000 -11.400 0.913 0.114 9.040 24.000
>
> Coefficients :
> Estimate Std. Error t-value Pr(>|t|)
> (Intercept) 26.3963638 6.5706835 4.0173 0.0003482 ***
> X1 -0.0066621 0.0433425 -0.1537 0.8788364
> X2 -2.1087903 2.1533566 -0.9793 0.3350111
> ---
> Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1
>
> Total Sum of Squares: 5548.4
> Residual Sum of Squares: 5382.1
> R-Squared: 0.037133
> Adj. R-Squared: 0.033856
> F-statistic: 0.479037 on 2 and 31 DF, p-value: 0.62389Warning
> message:In sqrt(sigma2) : NaNs produced
>
>
>
> with warm regards
> kailas D. Gokhale