Question
R language
(A) Write a function sir_step(5.1,R, beta, ganna) that takes the values S. 1, R. at a given time, along with the model parame
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program Code to Copy:

sir_step <- function(S,I,R,beta,gamma){
#Total Population
N = S + I + R
#S(t+1) is given by below formula
nextS = S + round(- beta * S * I / N,0)
#I(t+1) is given by below formula
nextI = I + round((beta * S * I / N) - gamma * I,0)
#R(t+1) is given by below formula
nextR = round(gamma * I,0)
  
result = c(nextS,nextI,nextR)
  
return(result)
}
resultant_vector = sir_step(S=9996,I=4,R=0,beta=2,gamma=0.5)
print(resultant_vector)

Code and Output Screenshot:

Add a comment
Know the answer?
Add Answer to:
R language (A) Write a function sir_step(5.1,R, beta, ganna) that takes the values S. 1, R....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question is two parts In R(Programming language). Define and write a function which takes one number...

    Question is two parts In R(Programming language). Define and write a function which takes one number as input and detects whether the number is even. Return TRUE if it is even, and FALSE otherwise. You need to first detect if the input is an integer; if not, return NA. Note 1: TRUE and FALSE are logical values, not strings! Note 2: No need to get user input from the console. Test your function using your_function_name(1), your_function_name(2), and your_function_name(1.5). Hint: What...

  • Part A - SIR model for the spread of disease Overview. This part of the assignment...

    Part A - SIR model for the spread of disease Overview. This part of the assignment uses a mix of theory and data to estimate the contact number c=b/k of an epidemic and hence to estimate the infection-spreading parameter b. The point is that once you know the value of b for a certain disease and population, you can use it in your model the next time there is an cpidemic, thus cnabling you to make predictions about the demand...

  • Question1 Consider the following economy of Hicksonia. 1. The consumption function is given by C ...

    Need the answer from question 5 to 9, do not put the answer from 1 to 4, please. Question1 Consider the following economy of Hicksonia. 1. The consumption function is given by C 200 + 0.75(Y-T). The investment function is 1 = 200-2500. Government purchases and taxes are both 100. Derive the IS curve 2. The money demand function in Hicksonia is (Md/P)-Y-10000 The money supply (M) is 1,000. Derive the LM curve under an arbitrary value of P (Hint:...

  • Using C programming language Question 1 a) through m) Exercise #1: Write a C program that...

    Using C programming language Question 1 a) through m) Exercise #1: Write a C program that contains the following steps (make sure all variables are int). Read carefully each step as they are not only programming steps but also learning topics that explain how functions in C really work. a. Ask the user for a number between 10 and 99. Write an input validation loop to make sure it is within the prescribed range and ask again if not. b....

  • I'm working on the following: Write a python program: 1. Write the definition of the function...

    I'm working on the following: Write a python program: 1. Write the definition of the function displaySubMenu that displays the following menu; this function doesn't collect the user's input; only display the following menu.: [S]top – Press 'S' to stop. 2. Write the definition of the function setNextGenList that creates a pattern of next generation (tempGen) based on the current generation (currentGen); modify the tempGen based on the currentGen by applying the rules of Game of Life. Conway's Game of...

  • 1) Repeated doubling, in which each doubling occurs in the same amount of time, is a...

    1) Repeated doubling, in which each doubling occurs in the same amount of time, is a hallmark of linear growth. A) True B) False 2) Money in a bank account earning compound interest at an annual percentage rate of 3% represents an example of linear growth. A) True B) False 3) Suppose you had a magic bank account in which your balance doubled each day. If you started with just $ 1, you'd be a millionaire in less than a...

  • 1. In this exercise, you will analyze the supply-demand equilibrium of a city under some special...

    1. In this exercise, you will analyze the supply-demand equilibrium of a city under some special simplifying assumptions about land use. The assumptions are: • all dwellings are situated within apartment complexes, • all dwellings must contain exactly 1,500 square feet of floor space, re- gardless of location, and • apartment complexes must contain exactly 15,000 square feet of floor space per square block of land area. These land-use restrictions, which are imposed by a zoning authority, mean that dwelling...

  • Evaluate the arical writ the response in which you state your agreement or disagreement with writer...

    Evaluate the arical writ the response in which you state your agreement or disagreement with writer up un these questions guidelines 1) can empathy lead us astrary? how 2) our heart will always go out to the baby in the well, its a measure of our humanity. but empathy will have to yield to reason if humanity is to have a future can empathy yield to reason? how? thank you The Baby in the Well: The Case against Empathy* -Paul...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT