melff / mclogit

mclogit: Multinomial Logit Models, with or without Random Effects or Overdispersion
http://melff.github.io/mclogit/
22 stars 4 forks source link

Error with "predict" command in newest versions #14

Closed kaylynsanbower closed 3 years ago

kaylynsanbower commented 3 years ago

Hello Prof. Elff, I'm using the mclogit command for an analysis and encountered an error with the post estimation command "predict" when using a more recent version of the package. The error reads:

Error in .TM.repl.i.mat(as(x, "TsparseMatrix"), j=j, value=value) : column indices must be <= ncol(.) which is 1417.

I'm able to get the predicted choice probabilities with version 0.8.5.1, but the error with the newer version makes me think that there may be a bug. Thanks for all of your work on this package; it's been incredibly useful for me. Cheers, Kaylyn

melff commented 3 years ago

I thought to have fixed this or a similar bug recently with release 0.8.7. Can you confirm that this error shows up with the most recent release?

kaylynsanbower commented 3 years ago

Yes, I get this error with version 0.8.6.4. I just re-ran it to double check.

melff commented 3 years ago

Can you try again with 0.8.7 (https://github.com/melff/mclogit/releases/tag/0.8.7)?

kaylynsanbower commented 3 years ago

With this version, I get a new error in the estimation stage, so I'm not sure what will happen if I try to predict. Here's the error:

Error in mclogit(cbind(choice, id) ~ rvn_1.25 + treat_1.25 + int_1.25 + : No predictor variable remains in random part of the model. Please reconsider your model specification. In addition: Warning message: In mclogit(cbind(choice, id) ~ rvn_1.25 + treat_1.25 + int_1.25 + : removing intercept from random part of the model because of insufficient within-choice set variance

melff commented 3 years ago

It looks as if your independent variables are constant within choice sets. This is what the error message says. Perhaps what you want to do is a baseline logit model. See ?mblogit.

kaylynsanbower commented 3 years ago

Good point! I had a mistake in my code to create the data frame that I was working on. I fixed that issue, so now I do have variation across my independent variables within the choice sets and am able to estimate with mclogit now. However, I'm still getting the error with the predict command using version 8.7. (The same error I showed above.)

melff commented 3 years ago

Can you send me (an extract of) your data, so that I can debug? Thanks!

kaylynsanbower commented 3 years ago

Here’s an extract of the data and an excerpt of the code in case you want to see what I was trying to do when I ran into the error. Thanks!

From: Martin Elff notifications@github.com Reply-To: melff/mclogit reply@reply.github.com Date: Thursday, January 7, 2021 at 11:14 AM To: melff/mclogit mclogit@noreply.github.com Cc: "Sanbower, Kaylyn" kaylyn.renee.sanbower@emory.edu, Author author@noreply.github.com Subject: [External] Re: [melff/mclogit] Error with "predict" command in newest versions (#14)

Can you send me (an extract of) your data, so that I can debug? Thanks!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmelff%2Fmclogit%2Fissues%2F14%23issuecomment-756215210&data=04%7C01%7Ckaylyn.renee.sanbower%40emory.edu%7C89d5c71ee554426d5b0e08d8b3274cdc%7Ce004fb9cb0a4424fbcd0322606d5df38%7C0%7C0%7C637456328660579672%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=5MCybgEP7A0ADwlMw9%2FwIaDh61Mx7MUkuLEBTXZu7Ug%3D&reserved=0, or unsubscribehttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAISOJB56EXDUCDGWRIYWB7TSYXMWBANCNFSM4VZAJFCQ&data=04%7C01%7Ckaylyn.renee.sanbower%40emory.edu%7C89d5c71ee554426d5b0e08d8b3274cdc%7Ce004fb9cb0a4424fbcd0322606d5df38%7C0%7C0%7C637456328660579672%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=JnfXsIv4SIzYuc%2FUkT%2BIFm2OQCXw8bF%2F9Vr6PgSzsw4%3D&reserved=0.


This e-mail message (including any attachments) is for the sole use of the intended recipient(s) and may contain confidential and privileged information. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this message (including any attachments) is strictly prohibited.

If you have received this message in error, please contact the sender by reply e-mail message and destroy all copies of the original message (including attachments).

melff commented 3 years ago

Sorry, this didn't work. Please either upload the file via the GitHub interface or send the file to me directly, i.e. martin@elf.eu.

melff commented 3 years ago

Fixed in release 0.8.7.1

kaylynsanbower commented 3 years ago

Works like a charm! Thanks for your responsiveness and your work on this package in general.