cnchapman / choicetools

Tools for Choice Modeling, Conjoint Analysis, and MaxDiff analysis of Best-Worst Surveys
Apache License 2.0
27 stars 14 forks source link

Code not working & including a none option for estimation #4

Open JoshSchramm94 opened 2 years ago

JoshSchramm94 commented 2 years ago

Thanks for this awesome package. Somehow, the code in the example, when running the following code "cbc.hb <- estimateMNLfromDesignHB". I get multiple error messages:

1) argument "directory" is missing, with no default --> however, I can not set the directory similar to choicemodelR. 2) Error in mcmcIters * pitersUsed : non-numeric argument to binary operator --> I am not quite sure, what is causing this error.

Somehow, I can not run this final code without any errors.

2) And another question. What if I also include a none option? I know from ChoicemodelR that you take out the none option however, code the choice as 4 (in case there are 3 options plus a none option for one task). It would be awesome if you could share these codes, as I really like the codes in your book.

3) Lastly, is there a chance to get the successive estimates of alpha draws? I think I can get them when using the compdraw in choicemodelR, however, the problem is that i do not get them for all attribute levels, but only for the one of the model matrix formula.

I would be happy to hear from you. Thanks a lot

cnchapman commented 2 years ago

Hi Josh --

Thank you for the mail. I believe the latest releases of R made a change to temporary directories that filtered through choicemodelr, which now has no default. Hence the need and the error with our package.

I just added a default to use the current R working directory. Try installing the package again -- devtools::install_github("cnchapman/choicetools") -- and you should get version 0.9082, which ought to work (or LMK if not).

devtools::install_github("cnchapman/choicetools") ... ─ building ‘choicetools_0.0.0.9082.tar.gz’ ... packageVersion("choicetools") [1] ‘0.0.0.9082’

As for a none option, our code doesn't directly support that although choicemodelr does. Our CBC code is mostly didactic rather than fully featured for actual analyses, so we have not yet included that. Personally if I wanted to include none, I'd make a copy of our code and then add the formatting to fit choicemodelr's data layout. (In practice, I mostly use Sawtooth Software to estimate CBC models. By contrast, the MaxDiff functions in our package are useful for a wider range of actual analysis.)

I'm not sure what you're looking for with the draws. The alphas are indeed in the compdraw lists (1 for every saved iteration) while betas are more conveniently in a single matrix "betadraw". Most analysts just use the average of betas as a good estimate and proxy for the alphas although that is not exactly correct.

Anyway, HTH! Best wishes,

-- Chris

On Thu, Sep 8, 2022 at 4:11 PM JoshSchramm94 @.***> wrote:

Thanks for this awesome package. Somehow, the code in the example, when running the following code "cbc.hb <- estimateMNLfromDesignHB". I get multiple error messages:

  1. argument "directory" is missing, with no default --> however, I can not set the directory similar to choicemodelR.
  2. Error in mcmcIters * pitersUsed : non-numeric argument to binary operator --> I am not quite sure, what is causing this error.

Somehow, I can not run this final code without any errors.

1.

And another question. What if I also include a none option? I know from ChoicemodelR that you take out the none option however, code the choice as 4 (in case there are 3 options plus a none option for one task). It would be awesome if you could share these codes, as I really like the codes in your book. 2.

Lastly, is there a chance to get the successive estimates of alpha draws? I think I can get them when using the compdraw in choicemodelR, however, the problem is that i do not get them for all attribute levels, but only for the one of the model matrix formula.

I would be happy to hear from you. Thanks a lot

— Reply to this email directly, view it on GitHub https://github.com/cnchapman/choicetools/issues/4, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABG7RQQ5JHJP2O4LKJFAUPLV5JXAHANCNFSM6AAAAAAQIGF3CE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

JoshSchramm94 commented 2 years ago

Hi Chris,

thanks a lot for your help. Now everything is working. Thanks for providing the functions :-).

Best wishes, Josh

JoshSchramm94 commented 2 years ago

Hi Chris,

sorry for reopening this issue. I was reading about choicetools again in your conference paper of the Sawtooth Software Proceedings from 2021. I was trying to run the MaxDiff example, however, when I am exporting my .cho file, my export only includes a .cho file, an .att file, as well as a .position file. When I try to read in the data file, R gives me the error message due to my temp.csv (object 'temp.csv' not found). I could export the data .csv file from sawtooth, however, I am not quite sure if this is meant by this and if yes, which order should that data frame have (as mine includes system variables as well). I am using the MaxDiff study from the Sawtooth software sample studies.

And I have a second question, how I would include a direct or indirect anchoring MaxDiff Approach? For me, it seems that the indirect approach is directly included in the .cho file, and I can define the direct approach before exporting the .cho file. However, I am not sure how to include it in the HB estimation.

Happy to hear from you as I think it is quite cool to have a package that directly works with the data from Sawtooth.

Thanks a lot.

cnchapman commented 2 years ago

Please share your exact code. Note that there is a separate read**.cho() function for CHO files. Sawtooth has been somewhat deprecating CHO files so there could be an issue there as well.

TBH if you're using Sawtooth then I would strongly recommend using their HB estimation instead of choicetools -- it is very fast and efficient, and is able to handle options like anchored items and covariates that our default code doesn't. (Most folks who use choicetools are using Qualtrics data, not Sawtooth.) HTH!

On Tue, Sep 20, 2022, 2:17 AM JoshSchramm94 @.***> wrote:

Reopened #4 https://github.com/cnchapman/choicetools/issues/4.

— Reply to this email directly, view it on GitHub https://github.com/cnchapman/choicetools/issues/4#event-7420330950, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABG7RQXB3V7LRDFAXRSBHF3V7F6LFANCNFSM6AAAAAAQIGF3CE . You are receiving this because you commented.Message ID: @.***>