phtest error: Error in solve.default(dvcov)

Hi! I've been working on a project for my econometric class.

I'm trying to use the Hausman Test for panel models from plm package. Everytime I try the test I get this answer:

Error in solve.default(dvcov) :
system is computationally singular: reciprocal condition number = 2.7187e-18

So I can not compare Fixed Effects model vs Random Effects.

Hope someone can help.

Thank you,

Gabriel

Hi, and welcome.

Could you post a reproducible example, called a reprex, please?

Also, there's a there's a community guideline concerning homework, FAQ: Homework Policy, that you should be aware of for reference.

How does your case differ from the example in the documentation?

library(plm)
data(Wages)
ht <- plm(lwage ~ wks + south + smsa + married + exp + I(exp ^ 2) + 
               bluecol + ind + union + sex + black + ed |
               bluecol + south + smsa + ind + sex + black |
               wks + married + union + exp + I(exp ^ 2), 
           data = Wages, index = 595,
           random.method = "ht", model = "random", inst.method = "baltagi")
summary(ht)
#> Oneway (individual) effect Random Effect Model 
#>    (Hausman-Taylor's transformation)
#> Instrumental variable estimation
#>    (Baltagi's transformation)
#> 
#> Call:
#> plm(formula = lwage ~ wks + south + smsa + married + exp + I(exp^2) + 
#>     bluecol + ind + union + sex + black + ed | bluecol + south + 
#>     smsa + ind + sex + black | wks + married + union + exp + 
#>     I(exp^2), data = Wages, model = "random", random.method = "ht", 
#>     inst.method = "baltagi", index = 595)
#> 
#> Balanced Panel: n = 595, T = 7, N = 4165
#> 
#> Effects:
#>                   var std.dev share
#> idiosyncratic 0.02304 0.15180 0.025
#> individual    0.88699 0.94180 0.975
#> theta: 0.9392
#> 
#> Residuals:
#>       Min.    1st Qu.     Median    3rd Qu.       Max. 
#> -12.643736  -0.466002   0.043285   0.524739  13.340263 
#> 
#> Coefficients:
#>                Estimate  Std. Error z-value  Pr(>|z|)    
#> (Intercept)  2.9127e+00  2.8365e-01 10.2687 < 2.2e-16 ***
#> wks          8.3740e-04  5.9973e-04  1.3963   0.16263    
#> southyes     7.4398e-03  3.1955e-02  0.2328   0.81590    
#> smsayes     -4.1833e-02  1.8958e-02 -2.2066   0.02734 *  
#> marriedyes  -2.9851e-02  1.8980e-02 -1.5728   0.11578    
#> exp          1.1313e-01  2.4710e-03 45.7851 < 2.2e-16 ***
#> I(exp^2)    -4.1886e-04  5.4598e-05 -7.6718 1.696e-14 ***
#> bluecolyes  -2.0705e-02  1.3781e-02 -1.5024   0.13299    
#> ind          1.3604e-02  1.5237e-02  0.8928   0.37196    
#> unionyes     3.2771e-02  1.4908e-02  2.1982   0.02794 *  
#> sexfemale   -1.3092e-01  1.2666e-01 -1.0337   0.30129    
#> blackyes    -2.8575e-01  1.5570e-01 -1.8352   0.06647 .  
#> ed           1.3794e-01  2.1248e-02  6.4919 8.474e-11 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> Total Sum of Squares:    243.04
#> Residual Sum of Squares: 4163.6
#> R-Squared:      0.60945
#> Adj. R-Squared: 0.60833
#> Chisq: 6891.87 on 12 DF, p-value: < 2.22e-16

Created on 2019-11-24 by the reprex package (v0.3.0)

Thank you. I'll read the guideline.

The model I'm testing is based on Kuznet's Enviromental Curve, so almost all variables are different from the example. The only thing in common is the squeart relation that gives the model the form of an inverted U. In the model I'm testing the relation is:

random <- plm (CO2 ~ GDP.P + GDP.P2 + LIND, DATA, model = "random")

fixed <- plm (CO2 ~ GDP.P + GDP.P2 + LIND, DATA, model = "within")

phtest(random, fixed)

Error in solve.default(dvcov) :
system is computationally singular: reciprocal condition number = 1.9145e-21

I'm comparing it against fixed effects with Huasman Test, phtest, but I get this error.

Please don't ask us to guess about the data. Post a reproducible example, called a reprex. Not many are going to spend the time trying to reverse engineer the problem and a search on plm in the community here shows only 20 posts, so you're unlikely to come to the attention of anyone here who has seen the error message and can tell you how to fix it off the top of her head.

Otherwise, you can look for guidance like this S/O post to see how it illuminates your problem.

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