## Not run:
# library(phenology)
# # Read a file with data
# Gratiot <- read.delim("http://max2.ese.u-psud.fr/epc/conservation/BI/Complete.txt", header=FALSE)
# data(Gratiot)
# # Generate a formatted list nammed data_Gratiot
# data_Gratiot <- add_phenology(Gratiot, name="Complete",
# reference=as.Date("2001-01-01"), format="%d/%m/%Y")
# # Generate initial points for the optimisation
# parg <- par_init(data_Gratiot, parametersfixed=NULL)
# # Run the optimisation
# result_Gratiot <- fit_phenology(data=data_Gratiot,
# parametersfit=parg, parametersfixed=NULL, trace=1)
# data(result_Gratiot)
# # Plot the phenology and get some stats
# output <- plot(result_Gratiot)
# # Use fit with co-factor
# # First extract tide information for that place
# td <- tide.info(year=2001, latitude=4.9167, longitude=-52.3333, tz="America/Cayenne")
# td2 <- td[td$Tide=="High Tide", ]
# td3 <- cbind(td2, Date=as.Date(td2$Date.Time))
# td4 <- td3[(as.POSIXlt(td3$Date.Time)$hou<6) | (as.POSIXlt(td3$Date.Time)$hou>18), ]
# with(td4, plot(Date.Time, Level, type="l"))
# data_Gratiot$Complete$Date
# td5 <- merge(data_Gratiot$Complete, td4, by.x="Date", by.y="Date")
# td6 <- td5[, c("Date", "Level")]
# parg <- par_init(data_Gratiot, parametersfixed=NULL, add.cofactors="Level")
# result_Gratiot_CF <- fit_phenology(data=data_Gratiot,
# parametersfit=parg, parametersfixed=NULL, trace=1, cofactors=td6,
# add.cofactors="Level")
# compare_AIC(WithoutCF=result_Gratiot, WithCF=result_Gratiot_CF)
# plot(result_Gratiot_CF)
# ## End(Not run)
Run the code above in your browser using DataLab