Commit 5fae862c authored by Manuela's avatar Manuela

edits

parent 328a065a
......@@ -26,7 +26,7 @@ BugReports: https://git.math.uzh.ch/reinhard.furrer/PRSim-devel
License: GPL-3
Encoding: UTF-8
LazyData: true
Depends: homtest, goftest, wmtsa, R >= 3.5.0
Depends: homtest, goftest, wmtsa, (R >= 3.5.0)
Suggests: lattice, ismev, evd, GB2
Imports: stats
RoxygenNote: 7.0.0
......@@ -248,6 +248,7 @@ prsim.wave <- function(data, station_id="Qobs", number_sim=1, win_h_length=15,
if(verbose) cat(paste0("Starting ",number_sim," simulations:\n"))
### run through all stations
out_list<-list()
for(l in 1:length(data)){
### list for storing results
data_sim <- list()
......@@ -422,23 +423,45 @@ prsim.wave <- function(data, station_id="Qobs", number_sim=1, win_h_length=15,
if (GoFtest=="NULL") {
p_vals <- NULL
}
### set output directory
setwd(out_dir)
if(marginal != "empirical"){
if (marginalpar) { # also return intermediate results
# return(list(simulation=data_stoch, pars=par_day, p_val=p_vals))
out_list <- list(simulation=data_stoch, pars=par_day, p_val=p_vals)
save(file=paste(l,'_stoch_sim.rda',sep=''),out_list)
} else {
# return(list(simulation=data_stoch, pars=NULL, p_val=p_vals))
out_list <- list(simulation=data_stoch, pars=NULL, p_val=p_vals)
save(file=paste(l,'_stoch_sim.rda',sep=''),out_list)
if(!is.na(out_dir)){
### set output directory
setwd(out_dir)
if(marginal != "empirical"){
if (marginalpar) { # also return intermediate results
# return(list(simulation=data_stoch, pars=par_day, p_val=p_vals))
out_list <- list(simulation=data_stoch, pars=par_day, p_val=p_vals)
save(file=paste(l,'_stoch_sim.rda',sep=''),out_list)
} else {
# return(list(simulation=data_stoch, pars=NULL, p_val=p_vals))
out_list <- list(simulation=data_stoch, pars=NULL, p_val=p_vals)
save(file=paste(l,'_stoch_sim.rda',sep=''),out_list)
}
}else{
# return(list(simulation=data_stoch))
out_list <- list(simulation=data_stoch, pars=NULL, p_val=NULL)
save(file=paste(l,'_stoch_sim.rda',sep=''),simulation=out_list)
}
}else{
# return(list(simulation=data_stoch))
out_list <- list(simulation=data_stoch, pars=NULL, p_val=NULL)
save(file=paste(l,'_stoch_sim.rda',sep=''),simulation=out_list)
}
### to to next station
if(is.na(out_dir)){
### store values in list
if(marginal != "empirical"){
if (marginalpar) { # also return intermediate results
# return(list(simulation=data_stoch, pars=par_day, p_val=p_vals))
out_list[[l]] <- list(simulation=data_stoch, pars=par_day, p_val=p_vals)
} else {
# return(list(simulation=data_stoch, pars=NULL, p_val=p_vals))
out_list[[l]] <- list(simulation=data_stoch, pars=NULL, p_val=p_vals)
}
}else{
# return(list(simulation=data_stoch))
out_list[[l]] <- list(simulation=data_stoch, pars=NULL, p_val=NULL)
}
}
### to to next station
}
if(is.na(out_dir)){
return(out_list)
}
}
No preview for this file type
No preview for this file type
......@@ -3,9 +3,9 @@ dontrun{
data(runoff_multi_sites)
### for empirical distribution
prsim.wave(data=runoff_multi_sites, number_sim=1, marginal="empirical",out_dir="~/PRSim-devel/data/simulations_multi_sites")
out <- prsim.wave(data=runoff_multi_sites, number_sim=1, marginal="empirical",out_dir=NA)
### for kappa distribution
prsim.wave(data=runoff_multi_sites, number_sim=1, marginal="kappa", GoFtest = "KS",out_dir="~/PRSim-devel/data/simulations_multi_sites")
prsim.wave(data=runoff_multi_sites, number_sim=1, marginal="kappa", GoFtest = "KS",out_dir=NA)
### for GEV distribution
require("evd")
......@@ -16,13 +16,12 @@ GEV_fit <- function( xdat, ...) gev.fit( xdat, show=FALSE, ...)$mle
### GEV
prsim.wave(data=runoff_multi_sites, number_sim=1, marginal="GEV", GoFtest = "KS", n_par=3, out_dir="~/PRSim-devel/data/simulations_multi_sites")
prsim.wave(data=runoff_multi_sites, number_sim=1, marginal="GEV", GoFtest = "KS", n_par=3, out_dir=NA)
### load stochastically simulated time series
### station 2
load("~/PRSim-devel/data/simulations_multi_sites/3_stoch_sim.rda")
sim <- out_list$simulation
sim <- out[[2]]$simulation
par(mai=c(.9,.9,.1,.1))
### observed time series
......
......@@ -22,7 +22,7 @@ prsim.wave(data, station_id="Qobs", number_sim=1, win_h_length=15,
\item{verbose}{logical. Should progress be reported?}
\item{marginalpar}{logical. Should the estimated parameters of the distribution used be returned?}
\item{n_wave}{number of scales to be considered in the continuous wavelet transform.}
\item{out_dir}{path of output directory where the stochastic simulations for the stations considered are saved.}
\item{out_dir}{path of output directory where the stochastic simulations for the stations considered are saved. If NA, list of data frames for the different sites is returned}
\item{suppWarn}{logical. See \sQuote{Details}.}
\item{...}{any other argument passed to the sub-function specifying the cdf for fitting. See \sQuote{Details} and \sQuote{Examples}. }
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment