In: Statistics and Probability
Imagine that you and your friend have caught COVID-19 while jogging without social distancing. Your case is more severe than your friend’s at the beginning: there are 400 millions of coronavirus in you, and only 120 million in your friend. However, your immune system is more effective. In your body, the number coronavirus decreases by 20 percent each day (new = 0.8 × original), while in your friend it decreases by 10 percent each day (new = 0.9 × original).
Write a for-loop to compute the number of coronavirus in your body and your friend’s over the next 14 days.
Plot the number of coronavirus in your and your friend’s body from day 1 to day 14 (time series plot). Make sure to plot two time series in one figure.
Find the day that the number of coronavirus in your friend’s body begins to surpass that in yours.
PLEASE USE R CODE TO ANSWER THE PROBLEM.
1)
#RCode :for-loop to compute the number of coronavirus in your body and your friend’s over the next 14 days.
Your_orginal=400
friend_orginal=120
Your_coronavirus =numeric()
Friend_coronavirus =numeric()
Day=numeric()
for( i in 1:14){
Your_new = 0.8*Your_orginal
friend_new = 1.1*friend_orginal
Your_coronavirus =append(Your_coronavirus , Your_new)
Friend_coronavirus =append(Friend_coronavirus ,friend_new)
Day=append(Day,i)
Your_orginal=Your_new
friend_orginal=friend_new
}
Data=data.frame(Day,Your_coronavirus,Friend_coronavirus)
plot(Day,Your_coronavirus,type="l",col="Green")
lines(Day,Friend_coronavirus,col="Blue")
=======================
2)
Green represent =Your_coronavirus
Blue represent =Friend_coronavirus
3) Day = 4
4th day that the number of coronavirus in your friend’s body begins to surpass that in yours.
===================================================
If you have any doubt please let me know through comment
Please give positive vote if you find this solution helpful. Thank
you!