The error information "Equation infeasible due to rhs value"

Problems with syntax of GAMS
Post Reply
chihcheng
User
User
Posts: 2
Joined: 1 year ago

The error information "Equation infeasible due to rhs value"

Post by chihcheng »

Dear Sir,

I am learning to estimate the Tobit model and implement its statistics inference through GAMS. However, as I am calculate the inverse of hessian matrix, the error information "Equation infeasible due to rhs value" come out all the time.
image.png
I had tried to solve this problem throuth trail and error for several day. But I still can not fix it. Attached are the files of my GAMS code and data respectively.
Tobit.gms
(5.14 KiB) Downloaded 38 times
Data_for_Tobitall.xlsx
(39.74 KiB) Downloaded 37 times
Are there anyone who can help me to point out the error parts of my code?

Thanks a lot.

Chen
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: The error information "Equation infeasible due to rhs value"

Post by bussieck »

Your model wasn't really ready to be worked on. If you share something make sure what you send works (e.g. you include a CSV file, but you only had an Excel file attached). Also you "solved" the model twice with convert (to get the Hessian) without explaining why. This looked messy/wrong. Nothing one can't figure out, but if you expect help, I suggest that in the future you invest a little more in making it easier for people to help.

The issue at hand was that you started your scalar variables at x1 and with card of m you let it go to x12. Trouble is that you forgot the objective variable, which comes first (you declared LOGIK before BETA) and hence LOGIK was x1 and your first BETA was x2 and hence you fell short the last BETA variable. The model still ran over m and hence your Hessian had a zero row and column which made the LP infeasible. This was easily fixed by declaring the xlist over x2*x%num_x% where num_ is card(m)+1. You could have noticed that since the Hessian parameter did not have any data for sigsqr. Looking at results is important!

Next issue was that the inverse of the Hessian calculated with the LP solver was numerically very bad. Your Hesse matrix is numerically very challenging. If you look at the HINV you see that this is full of zeros (and definitively not invertable which it should). An LP solver is not suited for this badly scaled problem. GAMS has tools that calculate an inverse (https://www.gams.com/latest/docs/T_LINA ... alg_invert) that pay more attention to bad numerics. If I use this, the model runs through to the end. Please find the modified model attached.
Tobit.gms
(5.23 KiB) Downloaded 35 times
-Michael

PS There are plenty female GAMS users that can potentially help. By addressing your potential helpers with "Dear Sir" you exclude many of them.
chihcheng
User
User
Posts: 2
Joined: 1 year ago

Re: The error information "Equation infeasible due to rhs value"

Post by chihcheng »

Dear Bussieck,

Firstly, I do appreciate your help on correcting my original codes. After your corrections, the error is solved finally. In addition, your explanations on the corrections are also help me to understant the logic on GMAS coding. Thank you so much.

Secondly, I am sorry for the mistake of uploading the wrong data file. I should upload the .csv one, not the .exls one. Sorry for my carelessness in my lastt post.

Thank you again for your great help.

Best,

chihcheng
2023/03/18
Post Reply