Rui Neiva
2012-Dec-09 22:31 UTC
[R] Error message "cs_lu(A) failed: near-singular A (or out of memory)"
Hi there everyone, I have the following model (this is naturally a simplified version just for showing my problem, in case you're wondering this is a translog cost function with the associated cost share equations): C ~ á + â1 log X + â2 log Y + ã1 log Z + ã2 log XX C1 ~ â1 + â2 log YY + ã1 log ZZ Then I have some restrictions on the coefficients, namely that the sum of â equal 1 and the some of ã equal zero So, I've added the following equations to the model C2 ~ 0 + â1.Y1 + â2.Y2 C3 ~ 0 + ã1.Y3 + ã2. Y4 I've created columns in my data frame with values of 0 for variable C3 and values of 1 for Y1, Y2, Y3, Y4 and C2 I'm using the systemfit package to solve a multiple equation system using the SURE method, and using a matrix to impose the restrictions on the coefficients (i.e., that the â1 in all equations is the same value, and the same for all the other coefficients). When I try to run the model without the restricting equations (C2, C3) it runs just fine, but when I add these two equations I get the error: "Error in solve(xtOmegaInv %*% xMat2, xtOmegaInv %*% yVec, tol = solvetol) : cs_lu(A) failed: near-singular A (or out of memory)" Any ideas on what the problem might be? All the best, Rui Neiva P.S.: I've also posted this question on the Matrix help forum, but since I do not know how active that forum is I've decided to see if anyone in the mailing list would be able to help. [[alternative HTML version deleted]]
Arne Henningsen
2012-Dec-25 08:08 UTC
[R] Error message "cs_lu(A) failed: near-singular A (or out of memory)"
Dear Rui If you impose the homogeneity (adding-up) restrictions, your system becomes singular, because the error terms of the share equations always sum up to zero. Therefore, you can arbitrarily delete one of the share equations and obtain the coefficients that were not directly estimated by the homogeneity restrictions. Furthermore, you can impose the homogeneity restriction at each single equation by normalization with one input price (num?raire). Finally, I suggest to impose the cross-equation restrictions by the argument "restrict.regMat" rather than by argument "restrict.matrix", because the documentation says "the advantage of imposing restrictions on the coefficients by 'restrict.regMat' is that the matrix, which has to be inverted during the estimation, gets smaller by this procedure, while it gets larger if the restrictions are imposed by 'restrict.matrix' and 'restrict.rhs'." I will send you my lecture notes on econometric production analysis with R by private mail. Please do not forget to cite R and the R packages that you use in your publications. If you have further questions regarding system estimation, microeconomic analysis, or stochastic frontier (efficiency) analysis with R, you can use a forum at the R-Forge sites of the systemfit [1,2], micEcon [3,4], or frontier [5] packages/projects, respectively. [1] http://www.systemfit.org/ [2] http://r-forge.r-project.org/projects/systemfit/ [3] http://www.micEcon.org/ [4] http://r-forge.r-project.org/projects/micecon/ [5] http://r-forge.r-project.org/projects/frontier/ Best (holiday) wishes from Copenhagen, Arne On 9 December 2012 23:31, Rui Neiva <ruiqneiva at gmail.com> wrote:> Hi there everyone, > > I have the following model (this is naturally a simplified version just for > showing my problem, in case you're wondering this is a translog cost > function with the associated cost share equations): > > C ~ ? + ?1 log X + ?2 log Y + ?1 log Z + ?2 log XX > C1 ~ ?1 + ?2 log YY + ?1 log ZZ > > Then I have some restrictions on the coefficients, namely that the sum of ? > equal 1 and the some of ? equal zero > So, I've added the following equations to the model > > C2 ~ 0 + ?1.Y1 + ?2.Y2 > C3 ~ 0 + ?1.Y3 + ?2. Y4 > > I've created columns in my data frame with values of 0 for variable C3 and > values of 1 for Y1, Y2, Y3, Y4 and C2 > > I'm using the systemfit package to solve a multiple equation system using > the SURE method, and using a matrix to impose the restrictions on the > coefficients (i.e., that the ?1 in all equations is the same value, and the > same for all the other coefficients). > > When I try to run the model without the restricting equations (C2, C3) it > runs just fine, but when I add these two equations I get the error: > > "Error in solve(xtOmegaInv %*% xMat2, xtOmegaInv %*% yVec, tol = solvetol) > : > cs_lu(A) failed: near-singular A (or out of memory)" > > Any ideas on what the problem might be? > > All the best, > Rui Neiva > > P.S.: I've also posted this question on the Matrix help forum, but since I > do not know how active that forum is I've decided to see if anyone in the > mailing list would be able to help. > > [[alternative HTML version deleted]] > > > ______________________________________________ > R-help at 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. >-- Arne Henningsen http://www.arne-henningsen.name