# Test for a fixed climate window using the datasets 'Mass' and 'MassClimate'
# Load data##
data(Mass)
data(MassClimate)
# Test a fixed window, starting 20 May
# Test for climate windows between 100 and 0 days ago (furthest=100, closest=0)
# Fit a linear term for the mean climate (FUNC="L")
# Test at the resolution of days (CINTERVAL="D")
clim <- climatewin(Xvar = MassClimate$Temp, CDate = MassClimate$Date,
BDate = Mass$Date,
baseline = lm(Mass$Mass ~ 1),
furthest = 100, closest = 0,
STAT = "mean", FUNC = "L",
FIXED = TRUE, cutoff.day = 20, cutoff.month = 5,
nrandom = 0, CMISSING = FALSE, CINTERVAL = "D")
# Randomise biological data and re-run climate window analysis
rand <- randwin(repeats = 2,
Xvar = MassClimate$Temp, CDate = MassClimate$Date, BDate = Mass$Date,
baseline = lm(Mass$Mass ~ 1), furthest = 100, closest = 0,
STAT = "mean", FUNC = "L", FIXED = TRUE, cutoff.day = 20, cutoff.month = 5,
CMISSING = FALSE, CINTERVAL = "D")
# Visualise climate window results
plotall(Dataset = clim[[3]], DatasetRand = rand,
BestModel = clim[[1]], BestModelData = clim[[2]],
CW1 = 0.95, CW2 = 0.5, CW3 = 0.25, HISTQ = 0.99)Run the code above in your browser using DataLab