"Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...)..." in Ordered Logit R2MLwiN

Welcome to the forum for R2MLwiN users. Feel free to post your question about R2MLwiN here. The Centre for Multilevel Modelling take no responsibility for the accuracy of these posts, we are unable to monitor them closely. Do go ahead and post your question and thank you in advance if you find the time to post any answers!

Go to R2MLwiN: Running MLwiN from within R >> http://www.bris.ac.uk/cmm/software/r2mlwin/
Post Reply
dcanarteg
Posts: 14
Joined: Tue Feb 05, 2019 9:30 pm

"Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...)..." in Ordered Logit R2MLwiN

Post by dcanarteg » Tue Mar 05, 2019 1:46 am

Hello

I am now building an Ordered Logit Model. My DV is 3 category response (0 = no support, 1 = 1 type of support, 2 = multiplex; Reference = 0). The IGLS worked. Both single-level models using IGLS and MCMC worked as well. However, when trying the MCMC I got the following error.

Below are the code for both Variance Component Models.

"Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
0 (non-NA) cases"

# ============= Variance Component Ordered Logit with IGLS ============================== =
m2 = logit(AltMultiplexSupport) ~ 1 + (1 [1:2] | EgoIdentifier)
(VarCompMCMCIgls <- runMLwiN(Formula = m2, D = "Ordered Multinomial", data = RomaAllData2))

# ============= Variance Component Ordered Logit with MCMC ============================== =
m3 = logit(AltMultiplexSupport) ~ 1 + (1 [1:2] | EgoIdentifier)
(VarCompMCMC <- runMLwiN(Formula = m3, D = "Ordered Multinomial", data = RomaAllData2,
estoptions = list(EstM = 1)))


I double checked whether I have missing values in my DV and I don't.

What can I do?

One more question. I read in Browne (2015) "MCMC manual for MLwiN 2.32" that I must first run every model with IGLS in order to obtain the appropriate starting values for MCMC? I just want to confirm this.

ChrisCharlton
Posts: 1132
Joined: Mon Oct 19, 2009 10:34 am

Re: "Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...)..." in Ordered Logit R2MLwiN

Post by ChrisCharlton » Tue Mar 05, 2019 10:10 am

I have only encountered an error message similar to this once before in a case where the estimates had gone to a NaN value:

Code: Select all

Actual update 5000 of 5000, Stored update 5000 of 5000
-2 * Loglike = -nan(ind)
PUPN c1003 c1004
AVER c1091 b99 b100

Count   =           5000
Average =       -nan(ind)
S.D.    =       -nan(ind)
S.E.M.  =       -nan(ind)

ECHO 0
Execution completed

Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 
  0 (non-NA) cases
Calls: runMLwiN -> effectiveSize -> spectrum0.ar -> lm -> lm.fit
Execution halted
The error here was due to the effective sample size code being unable to run with such data. Does the above output look similar to yours?

I would suggest adding debugmode=TRUE to your estoptions list so that you go into the MLwiN GUI after running the function, and checking the data/model there to see that it looks correct.

The two reasons to run (R)IGLS first before MCMC are to set up certain model structures and to provide starting values. R2MLwiN automatically runs with (R)IGLS for a couple of iterations to set up the model when you run the MCMC model anyway, so if using this you only need IGLS for the starting values. You can if you wish avoid this by specifying your own, and there are cases such as for cross-classified models where you might want to do this. For details on how to provide your own starting values see the MCMC guide chapter 5 examples on http://www.bristol.ac.uk/cmm/software/r2mlwin/examples/.

dcanarteg
Posts: 14
Joined: Tue Feb 05, 2019 9:30 pm

Re: "Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...)..." in Ordered Logit R2MLwiN

Post by dcanarteg » Thu Mar 07, 2019 4:54 pm

Indeed is very similar. This is what I am getting

"Actual update 4950 of 5000, Stored update 4950 of 5000
-2 * Loglike = nan
Actual update 5000 of 5000, Stored update 5000 of 5000
-2 * Loglike = nan
PUPN c1003 c1004
AVER c1091 b99 b100

Count = 5000
Average = nan
S.D. = nan
S.E.M. = nan

ECHO 0
Execution completed

Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
0 (non-NA) cases"

I am going to try debugmode = TRUE and see if works. Thanks a lot.

Post Reply