# NOT RUN {
#Simple test example
#Create data from a subset of our test dataset
#Just use two years
biol_data <- Mass[1:2, ]
clim_data <- MassClimate[grep(pattern = "1979|1986", x = MassClimate$Date), ]
single <- singlewin(xvar = list(Temp = clim_data$Temp),
cdate = clim_data$Date,
bdate = biol_data$Date,
baseline = lm(Mass ~ 1, data = biol_data),
range = c(1, 0),
type = "relative", stat = "mean",
func = c("lin"), cmissing = FALSE, cinterval = "day")
auto <- autowin(reference = single,
xvar = list(Temp = clim_data$Temp),
cdate = clim_data$Date, bdate = biol_data$Date,
baseline = lm(Mass ~ 1, data = biol_data), range = c(1, 0),
stat = "mean", func = "lin",
type = "relative",
cmissing = FALSE, cinterval = "day")
plotcor(auto, type = "A")
# }
# NOT RUN {
# Full working example
# Visualise climate autocorrelation
data(Mass)
data(MassClimate)
# Fit a single climate window using the datasets Mass and MassClimate.
single <- singlewin(xvar = list(Temp = MassClimate$Temp),
cdate = MassClimate$Date, bdate = Mass$Date,
baseline = lm(Mass ~ 1, data = Mass),
range = c(72, 15),
stat = "mean", func = "lin",
type = "absolute", refday = c(20, 5),
cmissing = FALSE, cinterval = "day")
# Test the autocorrelation between the climate in this single window and other climate windows.
auto <- autowin(reference = single,
xvar = list(Temp = MassClimate$Temp),
cdate = MassClimate$Date, bdate = Mass$Date,
baseline = lm(Mass ~ 1, data = Mass),
range = c(365, 0),
stat = "mean", func = "lin",
type = "absolute", refday = c(20, 5),
cmissing = FALSE, cinterval = "day")
# Plot the auto-correlation data
plotcor(auto, type = "A")
# }
Run the code above in your browser using DataLab