fix: Use "choice" from the profile
I was using the "choice" variable directly, which is referred to by different names in different profiles. The profile is supposed to be agnostic about any variable name in the instrument, so this was a bug.
This commit is contained in:
parent
56968e62f2
commit
5184a1383d
|
@ -1,6 +1,6 @@
|
|||
Package: rcguts
|
||||
Title: Backend Functions for R Choice Packages
|
||||
Version: 0.19.0
|
||||
Version: 0.19.1
|
||||
Authors@R: person('Brian Albert', 'Monroe', email = 'brianalbertmonroe@gmail.com', role = c('aut', 'cre'))
|
||||
Description: This package provides some backend functions that are shared by the R Choice family of pacakes. In particular, likelihood functions written in c++.
|
||||
Depends: R (>= 3.4.1)
|
||||
|
|
|
@ -185,8 +185,12 @@ arma::mat calc_likelihood(arma::mat pmat, DataFrame inst, List ftypes, List ft_i
|
|||
arma::vec mlgeneral(arma::mat pmat, DataFrame inst, List ftypes, List ft_index, List profile) {
|
||||
// Get the likelihoods for the options
|
||||
arma::mat likelihoods = calc_likelihood(pmat, inst, ftypes, ft_index, profile);
|
||||
// Grab the choice index from the profile
|
||||
arma::uword choice_i = profile["choice"];
|
||||
// Adjust from 1 base vectors to 0 base
|
||||
choice_i -= 1;
|
||||
// Grab the choice vector
|
||||
arma::uvec choice = inst["choice"];
|
||||
arma::uvec choice = inst[choice_i];
|
||||
// Generate the final likelihood vector
|
||||
arma::vec like(likelihoods.n_rows);
|
||||
// Select the likelihood corresponding to the choice
|
||||
|
|
Loading…
Reference in New Issue