In: Statistics and Probability
R - STUDIO R PROGRAMMING STATISTICS
Imagine that you and your friend have catched 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 millions in your friend. However, your immune system is more effective. In your body the number coronavirus decrease by 20 percent each day (new = 0.8 × orginal), while in your friend it increases by 10 percent each day (new = 0.9 × orginal).
1. Write a for-loop to compute the number of coronavirus in your body and your friend’s over the next 14 days.
2. Plot the number of coronavirus in your and your friend’s body from day 1 to day 14 (time series plot). Make sure plot two time series in one figure.
3. Find the day that the number of coronavirus in your friend’s body begins to surpass that in yours.
1)
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!