Re: [R] Solving sparse, singular systems of equations

2016-04-20 Thread Jeff Newmiller
The usual culprit in messy code is posting in HTML format. That usually leads to stripping of the formatting by the mailing list and a notice that that occurred, but I don't see that warning here. I still think posting plain text format would fix the problem. -- Sent from my phone. Please excu

Re: [R] Solving sparse, singular systems of equations

2016-04-20 Thread A A via R-help
Thanks for the help. Sorry, I am not sure why it looks like that in the mailing list - it looks much more neat on my end (see attached file). On Wednesday, April 20, 2016 2:01 PM, Berend Hasselman wrote: > On 20 Apr 2016, at 13:22, A A via R-help wrote: > > > > > I have a situati

Re: [R] Solving sparse, singular systems of equations

2016-04-20 Thread A A via R-help
Thanks for the response. Yes, in that situation a solution of x = 1 would be just as good as x = 1000 or any other value of x for me (but in my problem the matrix has nonzero rank, so I can't just randomly choose a vector and have it be a solution). If it helps, what I'm interested in is the R e

Re: [R] Solving sparse, singular systems of equations

2016-04-20 Thread A A via R-help
Thanks for the advice. I fixed the function and ran it on my systems just to see if it would work; for the first set of A and b, I got a valid solution, but for the second set, I got the error "Error in complete.cases(x, y, wt) : not all arguments have the same length".  On Wednesday, Apri

Re: [R] Solving sparse, singular systems of equations

2016-04-20 Thread Berend Hasselman
> On 20 Apr 2016, at 13:22, A A via R-help wrote: > > > > > I have a situation in R where I would like to find any x (if one exists) that > solves the linear system of equations Ax = b, where A is square, sparse, and > singular, and b is a vector. Here is some code that mimics my issue with

Re: [R] Solving sparse, singular systems of equations

2016-04-20 Thread Jeff Newmiller
This is kind of like asking for a solution to x+1=x+1. Go back to linear algebra and look up Singular Value Decomposition, and decide if you really want to proceed. See also ?svd and package irlba. -- Sent from my phone. Please excuse my brevity. On April 20, 2016 4:22:34 AM PDT, A A via R-hel

Re: [R] Solving sparse, singular systems of equations

2016-04-20 Thread William Dunlap via R-help
This is not a solution but your lsfit attempt #Error in lsfit(A, b) : only 3 cases, but 4 variables lsfit(A,b) gave that error because lsfit adds a column of 1 to its first argument unless you use intercept=FALSE. Then it will give you an answer (but I think it converts your sparse matrix int