# NOT RUN {
library(Rbeast)
data(covid19)
# }
# NOT RUN {
newcases = covid19$newcases
# This ts varies periodically every 7 days. 7 days can't be precisely represented
# in the unit of year bcz some years has 365 days and others has 366. So, here we
# use the date number as the time unit--the num of days lapsed since 1970-01-01.
datenum = as.numeric(covid19$date)
o = beast(newcases, start=min(datenum), deltat=1, freq=7)
o$time = as.Date(o$time, origin='1970-01-01') # Convert from integers to Date.
plot(o)
# Apply BEAST to the square root-transformed time series
o = beast(sqrt(newcases), start=min(datenum), deltat=1, freq=7)
o$time = as.Date(o$time, origin='1970-01-01') # Convert from integers to Date.
plot(o)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab