-
Notifications
You must be signed in to change notification settings - Fork 0
added files to be reviewed #3
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
base: empty
Are you sure you want to change the base?
Conversation
SongshGeo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I believe that the NetLogo version accurately rewrites the Julia code. The only change I insisted on was writing the model documentation according to NetLogo standard practices to help users understand the model. For the same reason, I also suggested removing parts of the code that do not run (the wheel-type).
Regarding the issue of experimental reproducibility mentioned during our meeting, I pointed out some differences in random processes which could lead to variations, but I believe the two approaches are mathematically equivalent overall. I'm sorry—I did read the paper but did not spend more time thinking about the relationship between its mismatched experimental results and codebase (anyhow, I'm not a reviewer of the paper, just a reviewer of the code). :)
| ## WHAT IS IT? | ||
|
|
||
| (a general understanding of what the model is trying to show or explain) | ||
|
|
||
| ## HOW IT WORKS | ||
|
|
||
| (what rules the agents use to create the overall behavior of the model) | ||
|
|
||
| ## HOW TO USE IT | ||
|
|
||
| (how to use the model, including a description of each of the items in the Interface tab) | ||
|
|
||
| ## THINGS TO NOTICE | ||
|
|
||
| (suggested things for the user to notice while running the model) | ||
|
|
||
| ## THINGS TO TRY | ||
|
|
||
| (suggested things for the user to try to do (move sliders, switches, etc.) with the model) | ||
|
|
||
| ## EXTENDING THE MODEL | ||
|
|
||
| (suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.) | ||
|
|
||
| ## NETLOGO FEATURES | ||
|
|
||
| (interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features) | ||
|
|
||
| ## RELATED MODELS | ||
|
|
||
| (models in the NetLogo Models Library and elsewhere which are of related interest) | ||
|
|
||
| ## CREDITS AND REFERENCES |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In NetLogo, publicly released models should typically include relevant documentation, such as the model's purpose and any pertinent references. This is standard practice in NetLogo.
| to experiment | ||
| repeat trial-size [ ; run the set number of trials | ||
| ifelse random-float 1 < pg-B [ ; generate random result ; if you get a positive result then | ||
| set my-positive my-positive + 1 ; add one to total positive results | ||
| ] | ||
| [ set my-negative my-negative + 1 | ||
| ] | ||
| ] | ||
| if my-negative > my-positive [ | ||
| set color red | ||
| ] | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mathematically equivalent, the implementation differs from the Julia code. Julia uses a built-in binomial random number generator; NetLogo uses multiple Bernoulli trials. A possible impact is the generation of different random number sequences. However, long-term statistical properties should be consistent. I think the difference doesn't matter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick note here... I agree that the two distributions would theoretically necessarily converge over time due to the CLT, but I think it is worth a bit of caution that the trials are often very short. The default value in the Netlogo model is 20, and without running sweeps myself I can at least say that that number strikes me as really short in context. It seems possible that the investigators could see a converging effect if they swept through various params of trial-size).
I will expand on this later, but would pin this as something to dig into further.
| ifelse network-type = "wheel" [ | ||
| setup-wheel | ||
| ] [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that it is not fully developed, I suggest removing the wheel section in the current version. A new version can be added later. Git and GitHub make version control very convenient.
Code Review: General FindingsAfter analysis comparing the Julia and NetLogo implementations against the paper's description, here is some commentary. The most critical finding: The paper's Appendix A reveals that the analysis uses an "approximation" where agents receive and update based on "the average (i.e., expected) result" from each scientist, not individual trial outcomes. This is consistent with the Julia code, but it fundamentally differs from the standard Bayesian updating described in the main text (and the investigators' Netlogo code). Given this acknowledged approximation in theoretical framework, exact replication of the paper's results should not be the goal. (p. 22--working from the arxiv.org copy) 1. The "Expected Value" Approximation vs. Standard Bayesian UpdatingThe paper's Appendix A explicitly states:
And indeed we have an update function in the Julia code that "lumps together" all the updates: top = (1-player.belief)*((.5-game.epsilon)/(.5+game.epsilon))^(2*game.players[i].result-game.binom_n)The Netlogo model instead processes Bayes' rule exactly as would be expected, with evidence being processed one piece at a time. This difference is happening very many times in the model operation and its effects are being compounded each time. In other words, the Netlogo model departs from the Appendix in the same way that the Appendix departs from the main paper! We have already discussed the potential ramifications of the distributions difference at short trial lengths. All of these differences would be addressible via additional mathematical analysis that is likely outside the scope of a code review---and might also be seen as unnecessary to the goal. 2. Undocumented "goodfriends" Filtering MechanismAnother deviation in the Julia code does not make it into the paper at all: for x in game.players
y = []
for z in x.friends
if game.players[z].belief > .5 # only listen to those who believe B is better
y = vcat(y,z)
end
end
x.goodfriends = y
endThen in the @everywhere function Update(game,player)
for i in player.goodfriends # only updates from filtered subset
top = (1-player.belief)*((.5-game.epsilon)/(.5+game.epsilon))^(2*game.players[i].result-game.binom_n)
player.belief = 1/(1+top/player.belief)
end
endThis creates a dynamic filtering where agents only learn from neighbors who currently believe B is better (belief > 0.5). This is not mentioned anywhere in the paper, which states agents update "based on what they, and all their network neighbors, have observed." Note that the code in the Netlogo model does seem to faithfully reproduce this line from paper. 3. Paper Specification InadequacySo, given the fact that the provided Julia code diverges from the facts of the paper, we might observe that the value of the code---being as it is not peer-reviewed---is really only as a guide. It should not be viewed as useful specifically for new model validation. The critical description of the step updates to belief in Section 2 of the paper is:
Bayes rule being applied in a multi-agent setting---such as the one we have here---is a prospect far too complicated to be adequately described in a single sentence. We are missing probability function details, trial mechanisms, information handling, edge case handling, and, yes, even randomization details. The Netlogo code could certainly be adjusted to more closely mimic the Julia updates and thus the paper's Appendix, but what would be the point in doing so, when the paper is communicating a specific phenomenon with approximate data? We can easily observe that the investigators have already achieved that with the Netlogo implementation. Conclusions:
Recommendations:The investigators should consider:
I will try and update a followup comment with just a few line-by-line notes on the Netlogo model. |
| set color green | ||
| initialize-beliefs | ||
| ] | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is standard in netlogo to take this approach to setup (sub-procedures for individual setup routines), but consider refactoring everything like clear-turtles and reset-ticks into the main proc. Not doing so is an easy source of headache in the future.
| @@ -0,0 +1,1081 @@ | |||
| globals | |||
| [ | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wound up commenting for myself:
;; advantage-B <-- epsilon
;; trial-size <-- _n_
;; number_turtles <-- _K_
;; policymaker_connectedness <-- _k_
;; pg-B <-- _p_sub_B_
I recommend using variables from the paper for naming your Netlogo controls, or adding labels into the UI with the matching paper formal variables. It can be very confusing to a reviewer having a large difference between control names and system variables.
|
|
||
| to setup | ||
| ca | ||
| ifelse network-type = "cycle" [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review indentation
| link-prop-to-pol | ||
| end | ||
| @#$#@#$#@ | ||
| GRAPHICS-WINDOW |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are commited to Netlogo you might consider the value of visual plots, especially given the respect you give to saving priors.
| ; For each policymaker, select policymaker-connectedness scientists and create links | ||
| ask policymakers [ | ||
| let target-scientists n-of policymaker-connectedness scientists | ||
| print (word "Policymaker " who " is linking to " count target-scientists " scientists.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this print is relatively expensive, if performance is a consideration. try commenting out.
The ticket for this code review is: Replicating Propagandist
This repository is ready for review.