fit_phenology: Fit the phenology parameters to timeseries of counts.

Description Usage Arguments Details Value Author(s) Examples

View source: R/fit_phenology.R

Description

Function of the package phenology to fit parameters to timeseries.
To fit data, the syntaxe is :
Result <- fit_phenology(data=dataset, fitted.parameters=par, fixed.parameters=pfixed, trace=1, method_incertitude=2, zero_counts=TRUE, hessian=TRUE)
or if no parameter is fixed :
Result <- fit_phenology(data=dataset, fitted.parameters=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.
If the parameter Theta is fixed to +Inf, a Poissonian model of daily nest distribution is implemented.

Usage

1
2
3
4
5
fit_phenology(data = file.choose(), fitted.parameters = NULL,
  fixed.parameters = NULL, method_incertitude = "convolution",
  infinite = 200, zero_counts = TRUE, hessian = TRUE, silent = FALSE,
  growlnotify = TRUE, cofactors = NULL, add.cofactors = NULL,
  zero = 1e-09, control = list(trace = 1, REPORT = 100, maxit = 500))

Arguments

data

A dataset generated by add_format

fitted.parameters

Set of parameters to be fitted

fixed.parameters

Set of fixed parameters

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 dSnbinom() 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.

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)

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

zero

If the theoretical nest number is under this value, this value wll be used

control

List for control parameters for optimx

Details

fit_phenology fits parameters to timeseries.

Value

Return a list of with data and result

Author(s)

Marc Girondot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
## 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, fixed.parameters=NULL)
# Run the optimisation
result_Gratiot <- fit_phenology(data=data_Gratiot, 
		fitted.parameters=parg, fixed.parameters=NULL)
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, fixed.parameters=NULL, add.cofactors="Level")
result_Gratiot_CF <- fit_phenology(data=data_Gratiot, 
		fitted.parameters=parg, fixed.parameters=NULL, cofactors=td6, 
		add.cofactors="Level")
compare_AIC(WithoutCF=result_Gratiot, WithCF=result_Gratiot_CF)
plot(result_Gratiot_CF)

## End(Not run)

phenology documentation built on May 30, 2017, 5:23 a.m.

Search within the phenology package
Search all R packages, documentation and source code