1

I was able to include the recovery or die but now I'm having trouble getting the standard deviation and of the turtles that died. I think I got the standard deviation but can't get the mean

if random-float 1 < recover-or-die [
  set epi-state recovered-code
  set color green
  ifelse random-float 1 < 0.90[


  ]
]

]

I tried this for the mean and it kept saying "Expected Command"

  • This site is to help you resolve errors in your code and your code looks okay. For the multiple simulations, look at BehaviorSpace in the Tools menu. Apart from that, what is your actual question? – JenB Apr 26 '20 at 07:27
  • Hi JenB, thank you for getting back to me. My question is how do I incorporate mortality into my code? For example, the case fatality is 0.1 for influenza and I want the turtles to either recover at 0.1 or die at 0.1 – terriblecontact7 Apr 26 '20 at 18:50
  • Like this? if-else (random-float 1 < recovery-prob) [ if (recovered-code < 0.1 or exposed-to-infectious-prob > 0.1)[ set epi-state recovered-code set color green die ] ][ – terriblecontact7 Apr 26 '20 at 19:39

1 Answers1

2

Your problem is ifelse recovery-prob < 0.1 = true. I don't know what your recovery-prob is set to, but this line is always true or always false. What you probably want to do (and what is in your comment) is:

ask turtles with [epi-state = infectious-code]
[ ifelse random-float 1 < recovery-prob
  [ set epi-state recovered-code
    set color green
  ]
  [ die
  ]
]

Note that you don't need to actually have the = true part.

If you have recover-prob set to 0.05 (for example), the condition is true for all turtles and they all recover. If it's set to 0.2 (for example), it is false for all turtles and they all die.

This block still has a logic problem I think. The way you have it written, any infectious turtle will either recover or die immediately. What about the turtles who stay infectious for more than one tick?

JenB
  • 17,620
  • 2
  • 17
  • 45
  • How would I make it for it to recover or die at the case fatality of 0.1%? – terriblecontact7 Apr 27 '20 at 18:14
  • You need to re-read your homework instructions. See BehaviorSpace for multiple runs for the mean and standard deviation issue. For case fatality - what is the case fatality of the model at the moment? How could you change that to 0.1% – JenB Apr 27 '20 at 21:07