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
  • 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...

  • 1. (a) Find the value of that maximizes the following function. Note thatェ2 0. f(r) 102...

    1. (a) Find the value of that maximizes the following function. Note thatェ2 0. f(r) 102 +45 Hint: For ar2 + br + c = 0, the values of r which are the solutions of the equation are given by: 2a (b) At the value of r you found in (a), does it satisfy the second-order condition for the maximum? Explain your answer 2. Suppose that a consumer has income of $12 to spend on i and Also suppose that...

  • 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:...

  • Please do exercise 129: Exercise 128: Define r:N + N by r(n) = next(next(n)). Let f:N...

    Please do exercise 129: Exercise 128: Define r:N + N by r(n) = next(next(n)). Let f:N → N be the unique function that satisfies f(0) = 2 and f(next(n)) =r(f(n)) for all n E N. 102 1. Prove that f(3) = 8. 2. Prove that 2 <f(n) for all n E N. Exercise 129: Define r and f as in Exercise 128. Assume that x + y. Define r' = {(x,y),(y,x)}. Let g:N + {x,y} be the unique function that...

  • 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...

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