Description Usage Arguments Value Examples
This function fits a Dirichlet distribution to an elicited set of quantiles from, e.g. an expert elicitation workshop. The function uses the crs2lm() function from the nloptr package to search for the set of hyperparameters that that generates quantiles that match the elicited data as closely as possible. crs2lm() repeatedly calls TestFitDirichlet() until it finds the best fitting set of inputs. The function returns a data frame containing the best fit set of hyperparameters of the Dirichlet, the Target quantiles and the modelled quantiles.
1 | fitDirichlet(Outcomes, RawData, SearchParams, Quantiles)
|
Outcomes |
A vector of names of outcomes |
RawData |
matrix of lower, middle and upper quantiles for each dimension elicited from experts |
SearchParams |
A vector of number of iterations and max number of searches. Number of iterations is the number of draws from the mCM distribution used to estimate the quantiles. Try 10,000 first. Max number of searches is the maximum number of searches the search algorithm conducts. The higher the better the solution, but also the longer it takes. Try 1000 first. |
Quantiles |
Sets the quantiles to be fit. If median and 95% Credibility Intervals, then set to c(0.025,0.5,0.975). If median and tertiles then c(0.33,0.5,0.66). If median and quartiles then c(0.25,0.5,0.75) and so on. |
Returns a matrix, each row representing one of the Outcomes. Column 'Dirichlet' is the parameters of the Dirichlet distribution. The next three columns (Tgt_LL, Tgt_MED, Tgt_UL) are the target quantiles input to the function as 'RawData' in the example above. The final three (Mdl_LL, Mdl_MED, Mdl_UL) are the quantiles resulting from the model fitting. If the mCM is a good fit, the Mdl columns will be identical to the Tgt columns.
1 2 3 4 5 6 7 8 9 10 11 | Outcomes <- c("Remission","Progression","Dead")
RawData <- matrix(data = c(0.43, 0.55, 0.65,
0.16, 0.27, 0.46,
0.03, 0.18, 0.23
),ncol=3,byrow=TRUE)
SearchParams <- c(10000,100) #number of iterations, max number of searches
Quantiles <- c(0.025,0.5,0.975) # example here is 95% credibility limits and median.
fitDirichlet(Outcomes, RawData, SearchParams, Quantiles)
|
0.8267704
0.8244768
0.834685
0.2163028
0.6663316
0.1538056
1.837605
1.086348
0.618916
1.027033
0.1739095
0.134731
0.3286991
0.2013126
0.7489073
1.147897
0.9623094
0.9576793
1.721807
0.2189926
0.8728922
0.8783521
0.1498962
0.4982816
0.239867
1.273784
1.504632
0.1460032
0.8856492
0.1422844
0.1945478
0.2684071
1.064921
0.8739887
2.729704
0.6758111
0.9052524
0.5054837
0.3928161
0.3185387
0.5705058
0.5601556
1.379529
0.2579187
1.32222
0.1982505
0.7042003
0.3075944
1.370967
0.6189767
0.2762056
0.2119612
0.2914502
0.2430658
0.5672918
0.6704789
0.4844596
0.6967443
0.3300448
1.094545
1.491436
0.1323439
0.8751481
0.7222784
0.1269778
0.2315591
1.438897
0.5962458
0.9528195
0.1122015
0.1877776
0.3247129
0.3995357
0.4165696
0.1024297
0.4184013
0.5008894
0.8806047
1.534349
0.3657954
0.1694709
0.4511437
0.2261886
1.66867
1.171256
1.877641
1.716386
1.08203
0.3070966
0.9234029
0.1241065
1.193184
0.1624865
0.3042638
0.1854249
1.262478
0.5727054
0.2567378
0.2578561
0.7158577
0.4981281
0.5827827
Call:
nloptr(x0 = x0, eval_f = fn, lb = lower, ub = upper, opts = opts)
Minimization using NLopt version 2.4.2
NLopt solver status: 5 ( NLOPT_MAXEVAL_REACHED: Optimization stopped because
maxeval (above) was reached. )
Number of Iterations....: 100
Termination conditions: maxeval: 100 xtol_rel: 1e-04
Number of inequality constraints: 0
Number of equality constraints: 0
Current value of objective function: 0.102429657973154
Current value of controls: 3 10000 0.025 0.5 0.975 0.43 0.55 0.65 0.16 0.27 0.46 0.03 0.18 0.23 603612
411034.1 158043.5
Dirichlet Tgt_LL Tgt_MED Tgt_UL Mdl_LL Mdl_MED Mdl_UL
Remission 603612.0 0.43 0.55 0.65 0.5138 0.5147 0.5156
Progression 411034.1 0.16 0.27 0.46 0.3497 0.3505 0.3513
Dead 158043.5 0.03 0.18 0.23 0.1341 0.1348 0.1354
Dirichlet Tgt_LL Tgt_MED Tgt_UL Mdl_LL Mdl_MED Mdl_UL
Remission 603612.0 0.43 0.55 0.65 0.5138 0.5147 0.5156
Progression 411034.1 0.16 0.27 0.46 0.3497 0.3505 0.3513
Dead 158043.5 0.03 0.18 0.23 0.1341 0.1348 0.1354
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.