Description Usage Arguments Value See Also Examples
View source: R/PrecipitationOccurenceModel.R
This functions creates a stochastic Occurrence Model for the variable x
(PrecipitationOccurrenceModel
S3 object) through a calibration from observed data.
1 2 3 4 5 6 7 8 9 | PrecipitationOccurrenceModel(
x,
exogen = NULL,
p = 1,
monthly.factor = NULL,
valmin = 0.5,
id.name = NULL,
...
)
|
x |
variable utilized for the auto-regression of its occurrence, e.g. daily precipitaton |
exogen |
exogenous predictors |
p |
auto-regression order |
monthly.factor |
vector of factors indicating the month of the days |
valmin |
minimum admitted value for daily precipitation amount |
id.name |
identification name of the station |
... |
further arguments |
The function returns a PrecipitationOccurrenceModel-class
S3 object containing the following elements:
predictor
data frame containg the endogenous and exogenous predictors of the logistic regression model;
glm
the genaralized liner model using for the logistic regression;
p
auto-regression order
valmin
minimum admitted value for daily precipitation amount
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | library(RGENERATEPREC)
data(trentino)
year_min <- 1961
year_max <- 1990
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)
model <- PrecipitationOccurrenceModel(x=prec_mes[,it],exogen=vect,monthly.factor=months)
probs <- predict(model$glm,type="response")
plot(months[-1],probs)
newdata <- model$predictor[2000:2007,]
probs0 <- predict(model,newdata=newdata)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.