-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cdectree_expected_values and dectree_expected_values give different results #6
Comments
Hi Josephine (I think!), there are certainly inconsistencies with this. I've basically just kept adding bits to it over quite a bit of time whenever I needed something for a project so theres very little overall design decision. Its great that you're trying it out tho! I should sort it out so this is a good excuse. Can you send me the example you've tried which gives the problem please and I'll fix it... n.green[at]ucl.ac.uk |
Hi Nathan
Thanks!
The difference can be seen using your examples ("cost" and "probs")
mt <- define_model(transmat=list(vals=cost,prob=probs))
dectree_expected_values(model=mt)
1 2 3 4 5 6 7
5.6 12.8 3.8 10.0 1.0 10.0 1.0
Cdectree_expected_values(vals=as.matrix(cost),p=as.matrix(probs))
[1] 5.6 2.8 2.8 0.0 0.0 0.0 0.0
Are you able to clarify whether this is a different output being calculated
or does one of them have an error?
Also, I thought that the value for node 1 should be equivalent to the
below, but perhaps I'm calculating something different or incorrectly?
probs[1,2]*cost[1,2]*probs[2,4]*cost[2,4] +
probs[1,2]*cost[1,2]*probs[2,5]*cost[2,5] +
+ probs[1,3]*cost[1,3]*probs[3,6]*cost[3,6] +
probs[1,3]*cost[1,3]*probs[3,7]*cost[3,7]
2
1 7.84
I can get 2.8 like this:
probs[1,2]*cost[2,4]*probs[2,4] + probs[1,2]*cost[2,5]*probs[2,5] +
probs[1,3]*cost[3,6]*probs[3,6] + probs[1,3]*cost[3,7]*probs[3,7]
Or 12.8 like this:
cost[1,2] + probs[1,2]*cost[2,4]*probs[2,4] +
probs[1,2]*cost[2,5]*probs[2,5] +
probs[1,3]*cost[3,6]*probs[3,6] + probs[1,3]*cost[3,7]*probs[3,7]
Also, just to note that in my transition matrix I had some probabilities
that were repeating decimals. This meant that some of the functions weren't
working because is_prob_matrix(test[["prob"]]) was returning FALSE even
though when I looked at the value it looked like a 1! So I rounded all my
probabilities (to 6 decimal places) and it works fine now.
Thanks again
Josephine
…On Mon, Nov 16, 2020 at 3:44 PM Dr Nathan Green ***@***.***> wrote:
Hi Josephine (I think!), there are certainly inconsistencies with this.
I've basically just kept adding bits to it over quite a bit of time
whenever I needed something for a project so theres very little overall
design decision. Its great that you're trying it out tho! I should sort it
out so this is a good excuse. Can you send me the example you've tried
which gives the problem please and I'll fix it... n.green[at]ucl.ac.uk
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#6 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA7OI6L2T2YHT6SJXA753P3SQFCFZANCNFSM4TXH7EEQ>
.
|
Hi, I have been playing around with this package and trying to get it to work for quite a big decision tree which would be a huge hassle to manually calculate expected probabilities. It looks like in dectree_expected_values all endpoint nodes are given their inputted cost value directly, while in Cdectree_expected_values, endpoint nodes have a value of 0.
The text was updated successfully, but these errors were encountered: