Learn R Programming

GWEX (version 1.1.3)

fitGwexModel: fitGwexModel: fit a GWex model to observations.

Description

fitGwexModel: fit a GWex model to observations.

Usage

fitGwexModel(objGwexObs, parMargin = NULL, listOption = NULL)

Value

Return an object of class GwexFit with:

  • p: The number of station,

  • version: package version,

  • variable: the type of variable,

  • fit: a list containing the list of options listOption and the list of estimated parameters listPar.

Arguments

objGwexObs

an object of class GwexObs

parMargin

(not required for temperature) list parMargin where and each element corresponds to a month (1...12) and contains a matrix nStation x 3 of pre-estimated parameters of the marginal distributions (EGPD or Mixture of Exponentials)

listOption

for precipitation, a list with the following fields:

  • th: threshold value in mm above which precipitation observations are considered to be non-zero (=0.2 by default)

  • nLag: order of the Markov chain for the transitions between dry and wet states (=2 by default)

  • typeMargin: 'EGPD' (Extended GPD) or 'mixExp' (Mixture of Exponentials). 'mixExp' by default

  • copulaInt: 'Gaussian' or 'Student': type of dependence for amounts (='Gaussian' by default)

  • isMAR: logical value, do we apply a Autoregressive Multivariate Autoregressive model (order 1) = FALSE by default

  • is3Damount: logical value, do we apply the model on 3D-amount. =FALSE by default

  • nChainFit: integer, length of the runs which are generated during the fitting procedure. =100000 by default

  • nCluster: integer, number of clusters which can be used for the parallel computation

and for temperature, a list with the following fields:

  • hasTrend: logical value, do we fit a linear trend for the long-term change, =FALSE by default

  • objGwexPrec: object of class GwexObs containing precipitation observations. If provided, we assume that temperature must be modelled and simulated according to the precipitation states 'dry' and 'wet'. For each state, a seasonal cycle is fitted (mean and sd).

  • typeMargin: 'SGED' (default) or 'Gaussian': type of marginal distribution.

  • depStation: 'MAR1' (default) or 'Gaussian': MAR1 (Multivariate Autoregressive model order 1) for the spatial and temporal dependence or 'Gaussian' for the spatial dependence only.

Author

Guillaume Evin

Examples

Run this code
# Format dates corresponding to daily observations of precipitation and temperature
vecDates = seq(from=as.Date("01/01/2005",format="%d/%m/%Y"),
to=as.Date("31/12/2014",format="%d/%m/%Y"),by='day')

###############################################################
#               FIT THE PRECIPITATION MODEL
###############################################################

# Format observations: create a Gwex object for one station only to show a quick
# example. The syntax is similar for multi-site applications.
myObsPrec = GwexObs(variable='Prec',date=vecDates,obs=dailyPrecipGWEX[,1,drop=FALSE])

# Fit precipitation model with a threshold of 0.5 mm to distinguish wet and dry 
# states (th) and keep default options otherwise, e.g. a Gaussian
# copula for the spatial dependence (copulaInt) and a mixExp distribution for 
# marginal intensities ('typeMargin')
myParPrec = fitGwexModel(myObsPrec,listOption=list(th=0.5))
myParPrec # print object

###############################################################
#     FIT THE TEMPERATURE MODEL, COND. TO PRECIPITATION
###############################################################
# Format observations: create a G-Wex object
myObsTemp = GwexObs(variable='Temp',date=vecDates,obs=dailyTemperGWEX)

# Fit temperature model with a long-term linear trend ('hasTrend'), Gaussian margins 
# ('typeMargin') and Gaussian spatial dependence ('depStation')
myParTemp = fitGwexModel(myObsTemp,listOption=list(hasTrend=TRUE,typeMargin='Gaussian',
depStation='Gaussian'))
myParTemp # print object

Run the code above in your browser using DataLab