Last chance! 50% off unlimited learning
Sale ends in
Estimate indices in periodic timeseries based on anchored minimum and maximum. The data.frame minmax can be generated manually. It should have three columns (time, index, SD), with all the successive minimum and maximum indices. It can be used with sun.info() to get the time of minimum and maximum air temperature or with getTide() to reconstruct the sea level.
index.periodic(minmax, time = NULL, replicates = 100, progressbar = FALSE)
A data.frame returned by minmax.periodic
The time at which produced the estimate
Number of replicates to estimate SD
Does a progression bar must be shown
A data.frame with a column time and a column index
index.periodic estimate indices in periodic timeseries based on anchored minimum and maximum
Other Periodic patterns of indices:
minmax.periodic()
,
moon.info()
,
sun.info()
,
tide.info()
# NOT RUN {
# Generate a timeserie of time
time.obs <- NULL
for (i in 0:9) time.obs <- c(time.obs, c(0, 6, 12, 18)+i*24)
# For these time, generate a timeseries of temperatures
temp.obs <- rep(NA, length(time.obs))
temp.obs[3+(0:9)*4] <- rnorm(10, 25, 3)
temp.obs[1+(0:9)*4] <- rnorm(10, 10, 3)
for (i in 1:(length(time.obs)-1))
if (is.na(temp.obs[i]))
temp.obs[i] <- mean(c(temp.obs[i-1], temp.obs[i+1]))
if (is.na(temp.obs[length(time.obs)]))
temp.obs[length(time.obs)] <- temp.obs[length(time.obs)-1]/2
observed <- data.frame(time=time.obs, temperature=temp.obs)
# Search for the minimum and maximum values
r <- minmax.periodic(time.minmax.daily=c(Min=2, Max=15),
observed=observed, period=24, colname.index="temperature")
# Estimate all the temperatures for these values
t <- index.periodic(minmax=r)
plot_errbar(x=t[,"time"], y=t[,"index"],
errbar.y=ifelse(is.na(t[,"sd"]), 0, 2*t[,"sd"]),
type="l", las=1, bty="n", errbar.y.polygon = TRUE,
xlab="hours", ylab="Temperatures", ylim=c(0, 35),
errbar.y.polygon.list = list(col="grey"))
plot_add(x=t[,"time"], y=t[,"index"], type="l")
plot_add(observed$time, observed$temperature, pch=19, cex=0.5)
# }
Run the code above in your browser using DataLab