Search code examples
netlogointegraltrend

Trend calculation in netlogo


I would like to calcul a trend from a list in Netlogo. Before looking for an integral calculation. Is there any tricky way to do that? If not, as mentioned in the Netlogo mailing list, I have taken a look at Netlogo-R-extention and RNetlogo but I would like to be sure. Any ideas and suggestions are welcome. :-)

For example : each of my agents has a memory of one indictor as a list of n elements. I would like to know with a numeric indictor if this list increase or decrease...

Memory is manage as

to manage-memory ;; hunter procedure
  let _lgh-mem length mem-hunted-wolves
  ifelse _lgh-mem < mem-size [
    set mem-hunted-wolves lput tick-hunted-wolves mem-hunted-wolves
    set mem-hunted-sheep lput tick-hunted-sheep mem-hunted-sheep
  ][
    ;; Wolves
    set mem-hunted-wolves lput tick-hunted-wolves mem-hunted-wolves
    set mem-hunted-wolves remove-item 0 mem-hunted-wolves
    set slope-mem-wolves calcul-mem-slope mem-hunted-wolves ;; calcul slope from killed wolves list

    ;; sheep
    set mem-hunted-sheep lput tick-hunted-sheep mem-hunted-sheep
    set mem-hunted-sheep remove-item 0 mem-hunted-sheep
    set slope-mem-sheep calcul-mem-slope mem-hunted-sheep ;; calcul slope from killed wolves list
  ]
end

Where mem-size is in the GUI.

My goal would be to discriminate list A as [5 8 6 7 4 5] to list B as [5 5 5 5 5 5].

The more I thought about it the more integral seem to be a solution. But I would not use "big R" for one some integral ...


Solution

  • One way to establish a "trend" would be to look at the slope of a simple regression line through the points. The slope of the line would indicate whether the trend was positive or negative, and perhaps give additionally useful information as to the magnitude of the trend. The matrix extension has a simple trend primitive and works in both NetLogo v6.0 and 5.3. The stats extension allows more complex regressions, but works (at the moment) only with 5.3.

    Charles