Skip to contents

This function returns the choice probabilities of an RprobitB_fit object.

Usage

choice_probabilities(x, data = NULL, par_set = mean)

Arguments

x

An object of class RprobitB_fit.

data

Either NULL or an object of class RprobitB_data. In the former case, choice probabilities are computed for the data that was used for model fitting. Alternatively, a new data set can be provided.

par_set

Specifying the parameter set for calculation and either

  • a function that computes a posterior point estimate (the default is mean()),

  • "true" to select the true parameter set,

  • an object of class RprobitB_parameter.

Value

A data frame of choice probabilities with choice situations in rows and alternatives in columns. The first two columns are the decider identifier "id" and the choice situation identifier "idc".

Examples

data <- simulate_choices(form = choice ~ covariate, N = 10, T = 10, J = 2)
x <- fit_model(data)
#> Computing sufficient statistics - 0 of 4  

#> Computing sufficient statistics - 1 of 4  

#> Computing sufficient statistics - 2 of 4  

#> Computing sufficient statistics - 3 of 4  

#> Computing sufficient statistics - 4 of 4  

#> MCMC iteration - 1 of 1000  

#> MCMC iteration - 10 of 1000  

#> MCMC iteration - 20 of 1000  

#> MCMC iteration - 30 of 1000  

#> MCMC iteration - 40 of 1000  

#> MCMC iteration - 50 of 1000  

#> MCMC iteration - 60 of 1000  

#> MCMC iteration - 70 of 1000  

#> MCMC iteration - 80 of 1000  

#> MCMC iteration - 90 of 1000  

#> MCMC iteration - 100 of 1000  

#> MCMC iteration - 110 of 1000  

#> MCMC iteration - 120 of 1000  

#> MCMC iteration - 130 of 1000  

#> MCMC iteration - 140 of 1000  

#> MCMC iteration - 150 of 1000  

#> MCMC iteration - 160 of 1000  

#> MCMC iteration - 170 of 1000  

#> MCMC iteration - 180 of 1000  

#> MCMC iteration - 190 of 1000  

#> MCMC iteration - 200 of 1000  

#> MCMC iteration - 210 of 1000  

#> MCMC iteration - 220 of 1000  

#> MCMC iteration - 230 of 1000  

#> MCMC iteration - 240 of 1000  

#> MCMC iteration - 250 of 1000  

#> MCMC iteration - 260 of 1000  

#> MCMC iteration - 270 of 1000  

#> MCMC iteration - 280 of 1000  

#> MCMC iteration - 290 of 1000  

#> MCMC iteration - 300 of 1000  

#> MCMC iteration - 310 of 1000  

#> MCMC iteration - 320 of 1000  

#> MCMC iteration - 330 of 1000  

#> MCMC iteration - 340 of 1000  

#> MCMC iteration - 350 of 1000  

#> MCMC iteration - 360 of 1000  

#> MCMC iteration - 370 of 1000  

#> MCMC iteration - 380 of 1000  

#> MCMC iteration - 390 of 1000  

#> MCMC iteration - 400 of 1000  

#> MCMC iteration - 410 of 1000  

#> MCMC iteration - 420 of 1000  

#> MCMC iteration - 430 of 1000  

#> MCMC iteration - 440 of 1000  

#> MCMC iteration - 450 of 1000  

#> MCMC iteration - 460 of 1000  

#> MCMC iteration - 470 of 1000  

#> MCMC iteration - 480 of 1000  

#> MCMC iteration - 490 of 1000  

#> MCMC iteration - 500 of 1000  

#> MCMC iteration - 510 of 1000  

#> MCMC iteration - 520 of 1000  

#> MCMC iteration - 530 of 1000  

#> MCMC iteration - 540 of 1000  

#> MCMC iteration - 550 of 1000  

#> MCMC iteration - 560 of 1000  

#> MCMC iteration - 570 of 1000  

#> MCMC iteration - 580 of 1000  

#> MCMC iteration - 590 of 1000  

#> MCMC iteration - 600 of 1000  

#> MCMC iteration - 610 of 1000  

#> MCMC iteration - 620 of 1000  

#> MCMC iteration - 630 of 1000  

#> MCMC iteration - 640 of 1000  

#> MCMC iteration - 650 of 1000  

#> MCMC iteration - 660 of 1000  

#> MCMC iteration - 670 of 1000  

#> MCMC iteration - 680 of 1000  

#> MCMC iteration - 690 of 1000  

#> MCMC iteration - 700 of 1000  

#> MCMC iteration - 710 of 1000  

#> MCMC iteration - 720 of 1000  

#> MCMC iteration - 730 of 1000  

#> MCMC iteration - 740 of 1000  

#> MCMC iteration - 750 of 1000  

#> MCMC iteration - 760 of 1000  

#> MCMC iteration - 770 of 1000  

#> MCMC iteration - 780 of 1000  

#> MCMC iteration - 790 of 1000  

#> MCMC iteration - 800 of 1000  

#> MCMC iteration - 810 of 1000  

#> MCMC iteration - 820 of 1000  

#> MCMC iteration - 830 of 1000  

#> MCMC iteration - 840 of 1000  

#> MCMC iteration - 850 of 1000  

#> MCMC iteration - 860 of 1000  

#> MCMC iteration - 870 of 1000  

#> MCMC iteration - 880 of 1000  

#> MCMC iteration - 890 of 1000  

#> MCMC iteration - 900 of 1000  

#> MCMC iteration - 910 of 1000  

#> MCMC iteration - 920 of 1000  

#> MCMC iteration - 930 of 1000  

#> MCMC iteration - 940 of 1000  

#> MCMC iteration - 950 of 1000  

#> MCMC iteration - 960 of 1000  

#> MCMC iteration - 970 of 1000  

#> MCMC iteration - 980 of 1000  

#> MCMC iteration - 990 of 1000  

#> MCMC iteration - 1000 of 1000  

#> Computing log-likelihood
choice_probabilities(x)
#>     id idc            A         B
#> 1    1   1 0.0159733803 0.9840266
#> 2    1   2 0.0076522958 0.9923477
#> 3    1   3 0.0006038894 0.9993961
#> 4    1   4 0.0309773121 0.9690227
#> 5    1   5 0.0224256436 0.9775744
#> 6    1   6 0.0000420972 0.9999579
#> 7    1   7 0.0021707474 0.9978293
#> 8    1   8 0.0011237670 0.9988762
#> 9    1   9 0.0148334052 0.9851666
#> 10   1  10 0.0232285488 0.9767715
#> 11   2   1 0.0033331941 0.9966668
#> 12   2   2 0.0045292681 0.9954707
#> 13   2   3 0.0148478401 0.9851522
#> 14   2   4 0.0119655689 0.9880344
#> 15   2   5 0.0009306035 0.9990694
#> 16   2   6 0.0163978598 0.9836021
#> 17   2   7 0.0052296000 0.9947704
#> 18   2   8 0.0019990303 0.9980010
#> 19   2   9 0.0121097494 0.9878903
#> 20   2  10 0.0016913287 0.9983087
#> 21   3   1 0.0210169011 0.9789831
#> 22   3   2 0.0312265536 0.9687734
#> 23   3   3 0.0163079266 0.9836921
#> 24   3   4 0.0227852033 0.9772148
#> 25   3   5 0.0590375131 0.9409625
#> 26   3   6 0.0495304557 0.9504695
#> 27   3   7 0.0013254700 0.9986745
#> 28   3   8 0.0041786592 0.9958213
#> 29   3   9 0.0207982384 0.9792018
#> 30   3  10 0.0127097175 0.9872903
#> 31   4   1 0.0254169687 0.9745830
#> 32   4   2 0.0638556632 0.9361443
#> 33   4   3 0.0282509647 0.9717490
#> 34   4   4 0.0038591614 0.9961408
#> 35   4   5 0.0168419322 0.9831581
#> 36   4   6 0.0001833428 0.9998167
#> 37   4   7 0.0368372508 0.9631627
#> 38   4   8 0.0497029584 0.9502970
#> 39   4   9 0.0151365934 0.9848634
#> 40   4  10 0.0025416250 0.9974584
#> 41   5   1 0.0132242493 0.9867758
#> 42   5   2 0.0142557016 0.9857443
#> 43   5   3 0.0608356888 0.9391643
#> 44   5   4 0.0011122088 0.9988878
#> 45   5   5 0.0028634592 0.9971365
#> 46   5   6 0.0141506704 0.9858493
#> 47   5   7 0.0436367421 0.9563633
#> 48   5   8 0.0154635762 0.9845364
#> 49   5   9 0.0860572174 0.9139428
#> 50   5  10 0.0213989868 0.9786010
#> 51   6   1 0.0225185818 0.9774814
#> 52   6   2 0.0167760745 0.9832239
#> 53   6   3 0.0055607831 0.9944392
#> 54   6   4 0.0245017817 0.9754982
#> 55   6   5 0.0243825121 0.9756175
#> 56   6   6 0.0584129617 0.9415870
#> 57   6   7 0.0125973231 0.9874027
#> 58   6   8 0.0075714702 0.9924285
#> 59   6   9 0.0017935637 0.9982064
#> 60   6  10 0.0072145910 0.9927854
#> 61   7   1 0.0147995600 0.9852004
#> 62   7   2 0.0239838598 0.9760161
#> 63   7   3 0.0210533119 0.9789467
#> 64   7   4 0.0216029869 0.9783970
#> 65   7   5 0.0033664863 0.9966335
#> 66   7   6 0.0122980729 0.9877019
#> 67   7   7 0.0011854194 0.9988146
#> 68   7   8 0.0123471436 0.9876529
#> 69   7   9 0.0047916347 0.9952084
#> 70   7  10 0.0084457664 0.9915542
#> 71   8   1 0.0251876260 0.9748124
#> 72   8   2 0.0030355963 0.9969644
#> 73   8   3 0.0169824402 0.9830176
#> 74   8   4 0.0123348658 0.9876651
#> 75   8   5 0.0285059624 0.9714940
#> 76   8   6 0.0082930131 0.9917070
#> 77   8   7 0.0106292864 0.9893707
#> 78   8   8 0.0060086837 0.9939913
#> 79   8   9 0.0136922567 0.9863077
#> 80   8  10 0.0002300603 0.9997699
#> 81   9   1 0.0284117181 0.9715883
#> 82   9   2 0.0068467214 0.9931533
#> 83   9   3 0.0014047682 0.9985952
#> 84   9   4 0.0700056741 0.9299943
#> 85   9   5 0.0277250607 0.9722749
#> 86   9   6 0.0515292492 0.9484708
#> 87   9   7 0.0061711751 0.9938288
#> 88   9   8 0.0053934295 0.9946066
#> 89   9   9 0.0523953890 0.9476046
#> 90   9  10 0.0372939876 0.9627060
#> 91  10   1 0.0123594541 0.9876405
#> 92  10   2 0.0243339831 0.9756660
#> 93  10   3 0.0580017915 0.9419982
#> 94  10   4 0.0042099739 0.9957900
#> 95  10   5 0.0453048258 0.9546952
#> 96  10   6 0.0145474918 0.9854525
#> 97  10   7 0.0201876959 0.9798123
#> 98  10   8 0.0234259848 0.9765740
#> 99  10   9 0.0058726627 0.9941273
#> 100 10  10 0.0037883937 0.9962116