This function calculates the parameters of a parametric probability distribution by fitting daily precipitation data for each station and each month. It is a wrapper function for fitdistr

Share:

Description

This function calculates the parameters of a parametric probability distribution by fitting daily precipitation data for each station and each month. It is a wrapper function for fitdistr

Usage

1
2
fitdistrForPrecipitation(data, dname = "exp", start = NULL,
  sample = "all", origin = "1961-1-1", valmin = 0.5, ...)

Arguments

data

dataset

dname

name of the pobability distribution to be fitted, e.g. "exp".

start

initialization configuration of probability distribution parameters for fitdistr.

sample

character string indicated if the parameters must be estimated differently for subset of the year, e.g. monthly. Admitted values are NULL (Default), "all" or "monthly".

origin

character string containing the date releted to the first row of data. Default is "1961-1-1".

valmin

threshold precipitation value [mm] for wet/dry day indicator. If precipitation is lower than valmin, day is considered dry. Default is 0.5 mm. See continuity_ratio,CCGamma.

...

further arguments for fitdistr

Value

a list containig the fitting parameters: S3 fitdistrForEachStation-class or fitdistrForEachStationForEachMonth-class (sample=="monthly") object

See Also

fitdistr,adddate

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
library(RMRAINGEN)


data(trentino)

year_min <- 1961
year_max <- 1990

period <- PRECIPITATION$year>=year_min & PRECIPITATION$year<=year_max
station <- names(PRECIPITATION)[!(names(PRECIPITATION) %in% c("day","month","year"))]
prec_mes <- PRECIPITATION[period,station]

## removing nonworking stations (e.g. time series with NA)
accepted <- array(TRUE,length(names(prec_mes)))
names(accepted) <- names(prec_mes)
for (it in names(prec_mes)) {
		 accepted[it]  <- (length(which(!is.na(prec_mes[,it])))==length(prec_mes[,it]))
}

prec_mes <- prec_mes[,accepted]
## the dateset is reduced!!!
prec_mes <- prec_mes[,1:3]

fit  <- fitdistrForPrecipitation(data=prec_mes,dname="exp",start=NULL,sample=NULL)

origin <- paste(year_min,1,1,sep="-")


fit_monthly  <- fitdistrForPrecipitation(data=prec_mes,dname="exp",
					start=NULL,sample="monthly",origin=origin)
fit_monthly_gamma  <- fitdistrForPrecipitation(data=prec_mes,dname="gamma",
						 start=NULL,sample="monthly",origin=origin)