wilcoxon-example.nlogo 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. ;; Wilcoxon Rank Sum Test example of R-extension
  2. ;;
  3. ;;
  4. ;; by Jan C. Thiele
  5. ;; University of Goettingen, Germany
  6. ;; Department Ecoinformatics, Biometrics and Forest Growth
  7. ;; Buesgenweg 4
  8. ;; 37077 Goettingen
  9. ;; Germany
  10. ;;
  11. ;; Contact: jthiele@gwdg.de
  12. ;;
  13. ;; Copyright: 2011, J.C. Thiele
  14. extensions [r]
  15. patches-own [elevation food]
  16. turtles-own [fitness change_rate]
  17. breed [lowland_bugs lowland_bug]
  18. breed [highland_bugs highland_bug]
  19. to setup
  20. clear-all
  21. ask patches
  22. [
  23. set elevation random 600
  24. set food random 100
  25. set pcolor elevation / 200
  26. ]
  27. create-lowland_bugs 50
  28. [
  29. move-to one-of patches with [elevation < 300]
  30. set change_rate 0.1
  31. set fitness r:get "rweibull(1,1)" * 0.8
  32. ]
  33. create-highland_bugs 50
  34. [
  35. move-to one-of patches with [elevation > 300]
  36. set change_rate 0.15
  37. set fitness r:get "rweibull(1,1)" * 0.2
  38. ]
  39. end
  40. to go
  41. ask turtles
  42. [
  43. set fitness random-float 2.0 * [food] of patch-here * change_rate
  44. ]
  45. r:putagent "lowland" lowland_bugs "fitness"
  46. r:putagent "highland" highland_bugs "fitness"
  47. r:eval "w <- wilcox.test(lowland$fitness, highland$fitness, exact=FALSE)"
  48. print r:get "w$p.value"
  49. set-current-plot "Wilcoxon Rank Sum Test"
  50. plot r:get "w$p.value"
  51. end
  52. @#$#@#$#@
  53. GRAPHICS-WINDOW
  54. 403
  55. 10
  56. 704
  57. 312
  58. -1
  59. -1
  60. 8.9
  61. 1
  62. 10
  63. 1
  64. 1
  65. 1
  66. 0
  67. 1
  68. 1
  69. 1
  70. -16
  71. 16
  72. -16
  73. 16
  74. 0
  75. 0
  76. 1
  77. ticks
  78. 30.0
  79. BUTTON
  80. 8
  81. 10
  82. 71
  83. 43
  84. NIL
  85. setup
  86. NIL
  87. 1
  88. T
  89. OBSERVER
  90. NIL
  91. NIL
  92. NIL
  93. NIL
  94. 1
  95. BUTTON
  96. 77
  97. 11
  98. 140
  99. 44
  100. NIL
  101. go
  102. NIL
  103. 1
  104. T
  105. OBSERVER
  106. NIL
  107. NIL
  108. NIL
  109. NIL
  110. 1
  111. PLOT
  112. 7
  113. 48
  114. 395
  115. 334
  116. Wilcoxon Rank Sum Test
  117. time
  118. p-value
  119. 0.0
  120. 1.0
  121. 0.0
  122. 1.0
  123. true
  124. false
  125. "" ""
  126. PENS
  127. "default" 1.0 0 -16777216 true "" ""
  128. @#$#@#$#@
  129. ## WHAT IS IT?
  130. This section could give a general understanding of what the model is trying to show or explain.
  131. ## HOW IT WORKS
  132. This section could explain what rules the agents use to create the overall behavior of the model.
  133. ## HOW TO USE IT
  134. This section could explain how to use the model, including a description of each of the items in the interface tab.
  135. ## THINGS TO NOTICE
  136. This section could give some ideas of things for the user to notice while running the model.
  137. ## THINGS TO TRY
  138. This section could give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model.
  139. ## EXTENDING THE MODEL
  140. This section could give some ideas of things to add or change in the procedures tab to make the model more complicated, detailed, accurate, etc.
  141. ## NETLOGO FEATURES
  142. This section could point out any especially interesting or unusual features of NetLogo that the model makes use of, particularly in the Procedures tab. It might also point out places where workarounds were needed because of missing features.
  143. ## RELATED MODELS
  144. This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.
  145. ## CREDITS AND REFERENCES
  146. This section could contain a reference to the model's URL on the web if it has one, as well as any other necessary credits or references.
  147. @#$#@#$#@
  148. default
  149. true
  150. 0
  151. Polygon -7500403 true true 150 5 40 250 150 205 260 250
  152. airplane
  153. true
  154. 0
  155. Polygon -7500403 true true 150 0 135 15 120 60 120 105 15 165 15 195 120 180 135 240 105 270 120 285 150 270 180 285 210 270 165 240 180 180 285 195 285 165 180 105 180 60 165 15
  156. arrow
  157. true
  158. 0
  159. Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150
  160. box
  161. false
  162. 0
  163. Polygon -7500403 true true 150 285 285 225 285 75 150 135
  164. Polygon -7500403 true true 150 135 15 75 150 15 285 75
  165. Polygon -7500403 true true 15 75 15 225 150 285 150 135
  166. Line -16777216 false 150 285 150 135
  167. Line -16777216 false 150 135 15 75
  168. Line -16777216 false 150 135 285 75
  169. bug
  170. true
  171. 0
  172. Circle -7500403 true true 96 182 108
  173. Circle -7500403 true true 110 127 80
  174. Circle -7500403 true true 110 75 80
  175. Line -7500403 true 150 100 80 30
  176. Line -7500403 true 150 100 220 30
  177. butterfly
  178. true
  179. 0
  180. Polygon -7500403 true true 150 165 209 199 225 225 225 255 195 270 165 255 150 240
  181. Polygon -7500403 true true 150 165 89 198 75 225 75 255 105 270 135 255 150 240
  182. Polygon -7500403 true true 139 148 100 105 55 90 25 90 10 105 10 135 25 180 40 195 85 194 139 163
  183. Polygon -7500403 true true 162 150 200 105 245 90 275 90 290 105 290 135 275 180 260 195 215 195 162 165
  184. Polygon -16777216 true false 150 255 135 225 120 150 135 120 150 105 165 120 180 150 165 225
  185. Circle -16777216 true false 135 90 30
  186. Line -16777216 false 150 105 195 60
  187. Line -16777216 false 150 105 105 60
  188. car
  189. false
  190. 0
  191. Polygon -7500403 true true 300 180 279 164 261 144 240 135 226 132 213 106 203 84 185 63 159 50 135 50 75 60 0 150 0 165 0 225 300 225 300 180
  192. Circle -16777216 true false 180 180 90
  193. Circle -16777216 true false 30 180 90
  194. Polygon -16777216 true false 162 80 132 78 134 135 209 135 194 105 189 96 180 89
  195. Circle -7500403 true true 47 195 58
  196. Circle -7500403 true true 195 195 58
  197. circle
  198. false
  199. 0
  200. Circle -7500403 true true 0 0 300
  201. circle 2
  202. false
  203. 0
  204. Circle -7500403 true true 0 0 300
  205. Circle -16777216 true false 30 30 240
  206. cow
  207. false
  208. 0
  209. Polygon -7500403 true true 200 193 197 249 179 249 177 196 166 187 140 189 93 191 78 179 72 211 49 209 48 181 37 149 25 120 25 89 45 72 103 84 179 75 198 76 252 64 272 81 293 103 285 121 255 121 242 118 224 167
  210. Polygon -7500403 true true 73 210 86 251 62 249 48 208
  211. Polygon -7500403 true true 25 114 16 195 9 204 23 213 25 200 39 123
  212. cylinder
  213. false
  214. 0
  215. Circle -7500403 true true 0 0 300
  216. dot
  217. false
  218. 0
  219. Circle -7500403 true true 90 90 120
  220. face happy
  221. false
  222. 0
  223. Circle -7500403 true true 8 8 285
  224. Circle -16777216 true false 60 75 60
  225. Circle -16777216 true false 180 75 60
  226. Polygon -16777216 true false 150 255 90 239 62 213 47 191 67 179 90 203 109 218 150 225 192 218 210 203 227 181 251 194 236 217 212 240
  227. face neutral
  228. false
  229. 0
  230. Circle -7500403 true true 8 7 285
  231. Circle -16777216 true false 60 75 60
  232. Circle -16777216 true false 180 75 60
  233. Rectangle -16777216 true false 60 195 240 225
  234. face sad
  235. false
  236. 0
  237. Circle -7500403 true true 8 8 285
  238. Circle -16777216 true false 60 75 60
  239. Circle -16777216 true false 180 75 60
  240. Polygon -16777216 true false 150 168 90 184 62 210 47 232 67 244 90 220 109 205 150 198 192 205 210 220 227 242 251 229 236 206 212 183
  241. fish
  242. false
  243. 0
  244. Polygon -1 true false 44 131 21 87 15 86 0 120 15 150 0 180 13 214 20 212 45 166
  245. Polygon -1 true false 135 195 119 235 95 218 76 210 46 204 60 165
  246. Polygon -1 true false 75 45 83 77 71 103 86 114 166 78 135 60
  247. Polygon -7500403 true true 30 136 151 77 226 81 280 119 292 146 292 160 287 170 270 195 195 210 151 212 30 166
  248. Circle -16777216 true false 215 106 30
  249. flag
  250. false
  251. 0
  252. Rectangle -7500403 true true 60 15 75 300
  253. Polygon -7500403 true true 90 150 270 90 90 30
  254. Line -7500403 true 75 135 90 135
  255. Line -7500403 true 75 45 90 45
  256. flower
  257. false
  258. 0
  259. Polygon -10899396 true false 135 120 165 165 180 210 180 240 150 300 165 300 195 240 195 195 165 135
  260. Circle -7500403 true true 85 132 38
  261. Circle -7500403 true true 130 147 38
  262. Circle -7500403 true true 192 85 38
  263. Circle -7500403 true true 85 40 38
  264. Circle -7500403 true true 177 40 38
  265. Circle -7500403 true true 177 132 38
  266. Circle -7500403 true true 70 85 38
  267. Circle -7500403 true true 130 25 38
  268. Circle -7500403 true true 96 51 108
  269. Circle -16777216 true false 113 68 74
  270. Polygon -10899396 true false 189 233 219 188 249 173 279 188 234 218
  271. Polygon -10899396 true false 180 255 150 210 105 210 75 240 135 240
  272. house
  273. false
  274. 0
  275. Rectangle -7500403 true true 45 120 255 285
  276. Rectangle -16777216 true false 120 210 180 285
  277. Polygon -7500403 true true 15 120 150 15 285 120
  278. Line -16777216 false 30 120 270 120
  279. leaf
  280. false
  281. 0
  282. Polygon -7500403 true true 150 210 135 195 120 210 60 210 30 195 60 180 60 165 15 135 30 120 15 105 40 104 45 90 60 90 90 105 105 120 120 120 105 60 120 60 135 30 150 15 165 30 180 60 195 60 180 120 195 120 210 105 240 90 255 90 263 104 285 105 270 120 285 135 240 165 240 180 270 195 240 210 180 210 165 195
  283. Polygon -7500403 true true 135 195 135 240 120 255 105 255 105 285 135 285 165 240 165 195
  284. line
  285. true
  286. 0
  287. Line -7500403 true 150 0 150 300
  288. line half
  289. true
  290. 0
  291. Line -7500403 true 150 0 150 150
  292. pentagon
  293. false
  294. 0
  295. Polygon -7500403 true true 150 15 15 120 60 285 240 285 285 120
  296. person
  297. false
  298. 0
  299. Circle -7500403 true true 110 5 80
  300. Polygon -7500403 true true 105 90 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 195 90
  301. Rectangle -7500403 true true 127 79 172 94
  302. Polygon -7500403 true true 195 90 240 150 225 180 165 105
  303. Polygon -7500403 true true 105 90 60 150 75 180 135 105
  304. plant
  305. false
  306. 0
  307. Rectangle -7500403 true true 135 90 165 300
  308. Polygon -7500403 true true 135 255 90 210 45 195 75 255 135 285
  309. Polygon -7500403 true true 165 255 210 210 255 195 225 255 165 285
  310. Polygon -7500403 true true 135 180 90 135 45 120 75 180 135 210
  311. Polygon -7500403 true true 165 180 165 210 225 180 255 120 210 135
  312. Polygon -7500403 true true 135 105 90 60 45 45 75 105 135 135
  313. Polygon -7500403 true true 165 105 165 135 225 105 255 45 210 60
  314. Polygon -7500403 true true 135 90 120 45 150 15 180 45 165 90
  315. square
  316. false
  317. 0
  318. Rectangle -7500403 true true 30 30 270 270
  319. square 2
  320. false
  321. 0
  322. Rectangle -7500403 true true 30 30 270 270
  323. Rectangle -16777216 true false 60 60 240 240
  324. star
  325. false
  326. 0
  327. Polygon -7500403 true true 151 1 185 108 298 108 207 175 242 282 151 216 59 282 94 175 3 108 116 108
  328. target
  329. false
  330. 0
  331. Circle -7500403 true true 0 0 300
  332. Circle -16777216 true false 30 30 240
  333. Circle -7500403 true true 60 60 180
  334. Circle -16777216 true false 90 90 120
  335. Circle -7500403 true true 120 120 60
  336. tree
  337. false
  338. 0
  339. Circle -7500403 true true 118 3 94
  340. Rectangle -6459832 true false 120 195 180 300
  341. Circle -7500403 true true 65 21 108
  342. Circle -7500403 true true 116 41 127
  343. Circle -7500403 true true 45 90 120
  344. Circle -7500403 true true 104 74 152
  345. triangle
  346. false
  347. 0
  348. Polygon -7500403 true true 150 30 15 255 285 255
  349. triangle 2
  350. false
  351. 0
  352. Polygon -7500403 true true 150 30 15 255 285 255
  353. Polygon -16777216 true false 151 99 225 223 75 224
  354. truck
  355. false
  356. 0
  357. Rectangle -7500403 true true 4 45 195 187
  358. Polygon -7500403 true true 296 193 296 150 259 134 244 104 208 104 207 194
  359. Rectangle -1 true false 195 60 195 105
  360. Polygon -16777216 true false 238 112 252 141 219 141 218 112
  361. Circle -16777216 true false 234 174 42
  362. Rectangle -7500403 true true 181 185 214 194
  363. Circle -16777216 true false 144 174 42
  364. Circle -16777216 true false 24 174 42
  365. Circle -7500403 false true 24 174 42
  366. Circle -7500403 false true 144 174 42
  367. Circle -7500403 false true 234 174 42
  368. turtle
  369. true
  370. 0
  371. Polygon -10899396 true false 215 204 240 233 246 254 228 266 215 252 193 210
  372. Polygon -10899396 true false 195 90 225 75 245 75 260 89 269 108 261 124 240 105 225 105 210 105
  373. Polygon -10899396 true false 105 90 75 75 55 75 40 89 31 108 39 124 60 105 75 105 90 105
  374. Polygon -10899396 true false 132 85 134 64 107 51 108 17 150 2 192 18 192 52 169 65 172 87
  375. Polygon -10899396 true false 85 204 60 233 54 254 72 266 85 252 107 210
  376. Polygon -7500403 true true 119 75 179 75 209 101 224 135 220 225 175 261 128 261 81 224 74 135 88 99
  377. wheel
  378. false
  379. 0
  380. Circle -7500403 true true 3 3 294
  381. Circle -16777216 true false 30 30 240
  382. Line -7500403 true 150 285 150 15
  383. Line -7500403 true 15 150 285 150
  384. Circle -7500403 true true 120 120 60
  385. Line -7500403 true 216 40 79 269
  386. Line -7500403 true 40 84 269 221
  387. Line -7500403 true 40 216 269 79
  388. Line -7500403 true 84 40 221 269
  389. x
  390. false
  391. 0
  392. Polygon -7500403 true true 270 75 225 30 30 225 75 270
  393. Polygon -7500403 true true 30 75 75 30 270 225 225 270
  394. @#$#@#$#@
  395. NetLogo 6.0-BETA2
  396. @#$#@#$#@
  397. @#$#@#$#@
  398. @#$#@#$#@
  399. @#$#@#$#@
  400. @#$#@#$#@
  401. default
  402. 0.0
  403. -0.2 0 0.0 1.0
  404. 0.0 1 1.0 0.0
  405. 0.2 0 0.0 1.0
  406. link direction
  407. true
  408. 0
  409. Line -7500403 true 150 150 90 180
  410. Line -7500403 true 150 150 210 180
  411. @#$#@#$#@
  412. 0
  413. @#$#@#$#@