Commit 1fe6dd19 authored by Jana Ulrich's avatar Jana Ulrich
Browse files

found some small mistakes: gev.d.params + in two examples i forgot to change...

found some small mistakes: gev.d.params + in two examples i forgot to change parameter names -> fixed
parent 8271db2b
...@@ -209,7 +209,7 @@ NULL ...@@ -209,7 +209,7 @@ NULL
#' data('example',package = 'IDF') #' data('example',package = 'IDF')
#' # fit d-gev #' # fit d-gev
#' fit <- gev.d.fit(example$dat,example$d,ydat = as.matrix(example[,c("cov1","cov2")]) #' fit <- gev.d.fit(example$dat,example$d,ydat = as.matrix(example[,c("cov1","cov2")])
#' ,mul = c(1,2),sigl = 1) #' ,mutl = c(1,2),sigma0l = 1)
#' # get parameters for cov1 = 1, cov2 = 1 #' # get parameters for cov1 = 1, cov2 = 1
#' par <- gev.d.params(fit = fit, ydat = matrix(1,1,2)) #' par <- gev.d.params(fit = fit, ydat = matrix(1,1,2))
#' # plot quantiles #' # plot quantiles
......
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
#' data('example',package ='IDF') #' data('example',package ='IDF')
#' #'
#' gev.d.fit(xdat=example$dat,ds = example$d,ydat=as.matrix(example[,c('cov1','cov2')]) #' gev.d.fit(xdat=example$dat,ds = example$d,ydat=as.matrix(example[,c('cov1','cov2')])
#' ,mul=c(1,2),sigl=1) #' ,mutl=c(1,2),sigma0l=1)
gev.d.fit<- gev.d.fit<-
function(xdat, ds, ydat = NULL, mutl = NULL, sigma0l = NULL, xil = NULL, thetal = NULL, etal = NULL, function(xdat, ds, ydat = NULL, mutl = NULL, sigma0l = NULL, xil = NULL, thetal = NULL, etal = NULL,
...@@ -322,7 +322,7 @@ gev.d.init <- function(xdat,ds,link){ ...@@ -322,7 +322,7 @@ gev.d.init <- function(xdat,ds,link){
#' # compute log-likelihood of observation values not included in fit #' # compute log-likelihood of observation values not included in fit
#' train.set <- example[example$d!=2,] #' train.set <- example[example$d!=2,]
#' test.set <- example[example$d==2,] #' test.set <- example[example$d==2,]
#' fit <- gev.d.fit(train.set$dat,train.set$d,mul = c(1,2),sigl = 1 #' fit <- gev.d.fit(train.set$dat,train.set$d,mutl = c(1,2),sigma0l = 1
#' ,ydat = as.matrix(train.set[c('cov1','cov2')])) #' ,ydat = as.matrix(train.set[c('cov1','cov2')]))
#' params <- gev.d.params(fit,ydat = as.matrix(test.set[c('cov1','cov2')])) #' params <- gev.d.params(fit,ydat = as.matrix(test.set[c('cov1','cov2')]))
#' gev.d.lik(xdat = test.set$dat,ds = test.set$d,mut = params[,1],sigma0 = params[,2],xi = params[,3] #' gev.d.lik(xdat = test.set$dat,ds = test.set$d,mut = params[,1],sigma0 = params[,2],xi = params[,3]
...@@ -450,18 +450,21 @@ gev.d.diag <- function(fit,subset=NULL,cols=NULL,pch=NULL,which='both',mfrow=c(1 ...@@ -450,18 +450,21 @@ gev.d.diag <- function(fit,subset=NULL,cols=NULL,pch=NULL,which='both',mfrow=c(1
#' @examples #' @examples
#' data('example',package = 'IDF') #' data('example',package = 'IDF')
#' fit <- gev.d.fit(example$dat,example$d,ydat = as.matrix(example[,c("cov1","cov2")]) #' fit <- gev.d.fit(example$dat,example$d,ydat = as.matrix(example[,c("cov1","cov2")])
#' ,mul = c(1,2),sigl = 1) #' ,mutl = c(1,2),sigma0l = 1)
#' gev.d.params(fit = fit,ydat = cbind(c(0.9,1),c(0.5,1))) #' gev.d.params(fit = fit,ydat = cbind(c(0.9,1),c(0.5,1)))
gev.d.params <- function(fit,ydat=NULL){ gev.d.params <- function(fit,ydat=NULL){
if(!class(fit)%in%c("gev.d.fit","gev.fit"))stop("'fit' must be an object returned by 'gev.d.fit' or 'gev.fit'.") if(!class(fit)%in%c("gev.d.fit","gev.fit"))stop("'fit' must be an object returned by 'gev.d.fit' or 'gev.fit'.")
if(fit$trans){ if(!is.null(ydat)){
# check covariates matrix # check covariates matrix
if(!is.matrix(ydat))stop("'ydat' must be of class matrix.") if(!is.matrix(ydat))stop("'ydat' must be of class matrix.")
n.par <- max(sapply(fit$model,function(x){return(ifelse(is.null(x),0,max(x)))})) n.par <- max(sapply(fit$model,function(x){return(ifelse(is.null(x),0,max(x)))}))
if(n.par>ncol(ydat))stop("Covariates-Matrix 'ydat' has ",ncol(ydat), " columns, but ", n.par," are required.") if(n.par>ncol(ydat))stop("Covariates-Matrix 'ydat' has ",ncol(ydat), " columns, but ", n.par," are required.")
}else(ydat <- matrix(1)) }else{if(!fit$trans){# no model -> no covariates matrix
ydat <- matrix(1)
}else{stop("To calculate parameter estimates, covariates matrix 'ydat' must be provided.")}
}
# number of parameters # number of parameters
npmu <- length(fit$model[[1]]) + 1 npmu <- length(fit$model[[1]]) + 1
......
...@@ -39,7 +39,7 @@ Plotting of IDF curves at a chosen station ...@@ -39,7 +39,7 @@ Plotting of IDF curves at a chosen station
data('example',package = 'IDF') data('example',package = 'IDF')
# fit d-gev # fit d-gev
fit <- gev.d.fit(example$dat,example$d,ydat = as.matrix(example[,c("cov1","cov2")]) fit <- gev.d.fit(example$dat,example$d,ydat = as.matrix(example[,c("cov1","cov2")])
,mul = c(1,2),sigl = 1) ,mutl = c(1,2),sigma0l = 1)
# get parameters for cov1 = 1, cov2 = 1 # get parameters for cov1 = 1, cov2 = 1
par <- gev.d.params(fit = fit, ydat = matrix(1,1,2)) par <- gev.d.params(fit = fit, ydat = matrix(1,1,2))
# plot quantiles # plot quantiles
......
...@@ -103,7 +103,7 @@ For details on the d-GEV and the parameter definitions, see \link{IDF-package}. ...@@ -103,7 +103,7 @@ For details on the d-GEV and the parameter definitions, see \link{IDF-package}.
data('example',package ='IDF') data('example',package ='IDF')
gev.d.fit(xdat=example$dat,ds = example$d,ydat=as.matrix(example[,c('cov1','cov2')]) gev.d.fit(xdat=example$dat,ds = example$d,ydat=as.matrix(example[,c('cov1','cov2')])
,mul=c(1,2),sigl=1) ,mutl=c(1,2),sigma0l=1)
} }
\seealso{ \seealso{
\code{\link{IDF-package}}, \code{\link{IDF.agg}}, \code{\link{gev.fit}}, \code{\link{optim}} \code{\link{IDF-package}}, \code{\link{IDF.agg}}, \code{\link{gev.fit}}, \code{\link{optim}}
......
...@@ -25,7 +25,7 @@ Computes (log-) likelihood of d-GEV model ...@@ -25,7 +25,7 @@ Computes (log-) likelihood of d-GEV model
# compute log-likelihood of observation values not included in fit # compute log-likelihood of observation values not included in fit
train.set <- example[example$d!=2,] train.set <- example[example$d!=2,]
test.set <- example[example$d==2,] test.set <- example[example$d==2,]
fit <- gev.d.fit(train.set$dat,train.set$d,mul = c(1,2),sigl = 1 fit <- gev.d.fit(train.set$dat,train.set$d,mutl = c(1,2),sigma0l = 1
,ydat = as.matrix(train.set[c('cov1','cov2')])) ,ydat = as.matrix(train.set[c('cov1','cov2')]))
params <- gev.d.params(fit,ydat = as.matrix(test.set[c('cov1','cov2')])) params <- gev.d.params(fit,ydat = as.matrix(test.set[c('cov1','cov2')]))
gev.d.lik(xdat = test.set$dat,ds = test.set$d,mut = params[,1],sigma0 = params[,2],xi = params[,3] gev.d.lik(xdat = test.set$dat,ds = test.set$d,mut = params[,1],sigma0 = params[,2],xi = params[,3]
......
...@@ -22,7 +22,7 @@ from results of \code{\link{gev.d.fit}} with covariates or link funktions other ...@@ -22,7 +22,7 @@ from results of \code{\link{gev.d.fit}} with covariates or link funktions other
\examples{ \examples{
data('example',package = 'IDF') data('example',package = 'IDF')
fit <- gev.d.fit(example$dat,example$d,ydat = as.matrix(example[,c("cov1","cov2")]) fit <- gev.d.fit(example$dat,example$d,ydat = as.matrix(example[,c("cov1","cov2")])
,mul = c(1,2),sigl = 1) ,mutl = c(1,2),sigma0l = 1)
gev.d.params(fit = fit,ydat = cbind(c(0.9,1),c(0.5,1))) gev.d.params(fit = fit,ydat = cbind(c(0.9,1),c(0.5,1)))
} }
\seealso{ \seealso{
......
Supports Markdown
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