It is an implentation of generate method

# S3 method for class 'PrecipitationAmountModel'
generate(x, ...)

# S3 method for class 'PrecipitationOccurrenceModel'
generate(
  x,
  newdata = NULL,
  previous = NULL,
  n = 30,
  random = runif(n, min = 0, max = 1),
  exogen = NULL,
  monthly.factor = NULL,
  ...
)

# S3 method for class 'CCGammaObjectListPerEachMonth'
generate(x, ...)

# S3 method for class 'PrecipitationOccurrenceMultiSiteModel'
generate(
  x,
  exogen,
  n = NA,
  origin = "1961-1-1",
  end = "1990-1-1",
  previous = NULL,
  monthly.factor = NULL,
  ...
)

# S3 method for class 'PrecipitationAmountModel'
generate(x, ...)

Arguments

x

model returned by PrecipitationOccurrenceModel or PrecipitationOccurrenceMultiSiteModel

...

further arguments

newdata

predictor or exogenous variables. See predict.PrecipitationOccurrenceModel

previous

logical vector containing previously occurred states

n

number of generations. See generate. Here it is ignored and the number of generations is given by origin,end or monthly.factor.

random

vector of random or calculated numbers ranging between 0 and 1

exogen

predictor or exogenous variables

monthly.factor

vector of factors indicating the month of the days

origin, end

character strings (yyyy-dd-mm) indicating the start and/or end date of the daily weather generation.

Value

A vector or a data frame reporting generated time series for each station.

References

D.S. Wilks (1998), Multisite Generalization of a Daily Stochastic Precipitation Generation Model, Journal of Hydrology, Volume 210, Issues 1-4, September 1998, Pages 178-191, https://www.sciencedirect.com/science/article/pii/S0022169498001863

Muamaraldin Mhanna and Willy Bauwens (2011) A Stochastic Space-Time Model for the Generation of Daily Rainfall in the Gaza Strip, International Journal of Climatology, Volume 32, Issue 7, pages 1098-1112, doi:10.1002/joc.2305 , https://rmets.onlinelibrary.wiley.com/doi/10.1002/joc.2305

Examples


library(RGENERATEPREC)


## A function example can be found in the following script file: 
scriptfile <- system.file("example.generate.R",package="RGENERATEPREC")
## The corrent file path is given by 'scriptfile' variable:
print(scriptfile)
#> [1] "/tmp/RtmpD5u1hn/temp_libpath3094d53627f286/RGENERATEPREC/example.generate.R"
## To run the example file, launch the file with 'source' command (uncomment the following line)
#source(scriptfile)

## ALTERNATIVELY you can run the following lines:



data(trentino)

year_min <- 1961
year_max <- 1990

origin <- paste(year_min,1,1,sep="-")
end <- paste(year_max,12,31,sep="-")

period <- PRECIPITATION$year>=year_min & PRECIPITATION$year<=year_max
period_temp <- TEMPERATURE_MAX$year>=year_min & TEMPERATURE_MAX$year<=year_max

prec_mes <- PRECIPITATION[period,]
Tx_mes <- TEMPERATURE_MAX[period_temp,]
Tn_mes <- TEMPERATURE_MIN[period_temp,]
accepted <- array(TRUE,length(names(prec_mes)))
names(accepted) <- names(prec_mes)
for (it in names(prec_mes)) {
  acc <- TRUE
  acc <- (length(which(!is.na(Tx_mes[,it])))==length(Tx_mes[,it]))
  acc <- (length(which(!is.na(Tn_mes[,it])))==length(Tn_mes[,it])) & acc
  accepted[it]  <- (length(which(!is.na(prec_mes[,it])))==length(prec_mes[,it])) & acc
  
}

valmin <- 1.0
prec_mes <- prec_mes[,accepted]



Tx_mes <- Tx_mes[,accepted]
Tn_mes <- Tn_mes[,accepted]
prec_occurrence_mes <- prec_mes>=valmin

station <- names(prec_mes)[!(names(prec_mes) %in% c("day","month","year"))]
it <- station[2]
vect <- Tx_mes[,it]-Tn_mes[,it]
months <- factor(prec_mes$month)

 
# \donttest{
model <- 
PrecipitationOccurrenceModel(x=prec_mes[,it],exogen=vect,
monthly.factor=months,valmin=valmin)

obs <- prec_mes[,it]>=valmin

gen <- generate(model,exogen=vect,monthly.factor=months,n=length(months))
# }

## Only 10 generated realizations!!
gen10 <- generate(model,exogen=vect,monthly.factor=months,n=10)


### MultiSite Generation 


station <- station[1:2]
exogen <- Tx_mes[,station]-Tn_mes[,station]

months <- factor(prec_mes$month)


# \donttest{
 
model_multisite <- 
PrecipitationOccurrenceMultiSiteModel(x=prec_mes[,station],
exogen=exogen,origin=origin,multisite_type="wilks")
#> lag
#> 0
#> Hmm... p0 - first argument - must be a matrix of probabilities!!!
#> lag
#> 0
#> Hmm... p0 - first argument - must be a matrix of probabilities!!!
#> lag
#> 0
#> Hmm... p0 - first argument - must be a matrix of probabilities!!!
#> lag
#> 0
#> Hmm... p0 - first argument - must be a matrix of probabilities!!!
#> lag
#> 0
#> Hmm... p0 - first argument - must be a matrix of probabilities!!!
#> lag
#> 0
#> Hmm... p0 - first argument - must be a matrix of probabilities!!!
#> lag
#> 0
#> Hmm... p0 - first argument - must be a matrix of probabilities!!!
#> lag
#> 0
#> Hmm... p0 - first argument - must be a matrix of probabilities!!!
#> lag
#> 0
#> Hmm... p0 - first argument - must be a matrix of probabilities!!!
#> lag
#> 0
#> Hmm... p0 - first argument - must be a matrix of probabilities!!!
#> lag
#> 0
#> Hmm... p0 - first argument - must be a matrix of probabilities!!!
#> lag
#> 0
#> Hmm... p0 - first argument - must be a matrix of probabilities!!!


## LOGIT-type Model 
model_multisite_logit <- 
PrecipitationOccurrenceMultiSiteModel(x=prec_mes,exogen=exogen,
origin=origin,multisite_type="logit",station=station)


obs_multisite <- prec_mes[,station]>=valmin

gen_multisite <- generate(model_multisite,exogen=exogen,origin=origin,end=end)
#> Processing T0001
#> Processing T0014

gen_multisite_logit <- generate(model_multisite_logit,exogen=exogen,origin=origin,end=end)
#> Processing: 5.00%
#> Processing: 10.00%
#> Processing: 15.00%
#> Processing: 20.00%
#> Processing: 25.00%
#> Processing: 30.00%
#> Processing: 35.00%
#> Processing: 40.00%
#> Processing: 45.00%
#> Processing: 50.00%
#> Processing: 55.00%
#> Processing: 60.00%
#> Processing: 65.00%
#> Processing: 70.00%
#> Processing: 75.00%
#> Processing: 80.00%
#> Processing: 85.00%
#> Processing: 90.00%
#> Processing: 95.00%
#> Processing: 100.00%
# }