Learn R Programming

phenology (version 5.1)

fit_phenology: Fit the phenology parameters to timeseries of counts.

Description

Function of the package phenology to fit parameters to timeseries. To fit data, the syntaxe is : Result <- fit_phenology(data=dataset, parametersfit=par, parametersfixed=pfixed, trace=1, method_incertitude=2, zero_counts=TRUE, hessian=TRUE) or if no parameter is fixed : Result <- fit_phenology(data=dataset, parametersfit=par) Add trace=1 [default] to have information on the fit progression or trace=0 to hide information on the fit progression. zero_counts = c(TRUE, TRUE, FALSE) indicates whether the zeros have been recorded for each of these timeseries. Defaut is TRUE for all. hessian = FALSE does not estimate se of parameters.

Usage

fit_phenology(data = file.choose(), parametersfit = NULL, parametersfixed = NULL, trace = 1, maxit = 500, method_incertitude = "convolution", infinite = 200, zero_counts = TRUE, cofactors = NULL, add.cofactors = NULL, hessian = TRUE, silent = FALSE, growlnotify = TRUE, zero = 1e-09)

Arguments

data
A dataset generated by add_format
parametersfit
Set of parameters to be fitted
parametersfixed
Set of fixed parameters
trace
If 1, it shows the progression of fit; 0 is silent (don't be afraid if it is very long !)
maxit
Number of iterations for search before checking if it converges. If it does not converge, it will continue to search for. Default is 500.
method_incertitude
'combinatory' estimates likelihood of all combinations for nest numbers; 'convolution' [default] uses the exact likelihood of the sum of negative binomial distribution.
infinite
Number of iterations for dmnbinom() used for method_incertitude='sum'
zero_counts
example c(TRUE, TRUE, FALSE) indicates whether the zeros have been recorded for each of these timeseries. Defaut is TRUE for all.
cofactors
data.frame with a column Date and a column for each cofactor
add.cofactors
Names of the column of parameter cofactors to use as a cofactor
hessian
If FALSE does not estimate se of parameters
silent
If TRUE does not show any message
growlnotify
If FALSE, does not send growl notification (only in MacOSX)
zero
If the theoretical nest number is under this value, this value wll be used

Value

Return a list of with data and result

Details

fit_phenology fits parameters to timeseries.

Examples

Run this code
## 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