From noreply at r-forge.r-project.org Wed Oct 9 15:49:17 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 9 Oct 2013 15:49:17 +0200 (CEST) Subject: [Vinecopula-commits] r25 - in pkg: . R inst man src Message-ID: <20131009134917.32CE3184F7B@r-forge.r-project.org> Author: ulf Date: 2013-10-09 15:49:16 +0200 (Wed, 09 Oct 2013) New Revision: 25 Added: pkg/R/AD.R pkg/R/BetaMatrix.r pkg/R/BiCopPar2Beta.r pkg/R/ChatZj.R pkg/R/CvM.R pkg/R/Fhat.R pkg/R/KS.R pkg/R/RVineGofTest3.r pkg/R/RVinePIT.r pkg/R/RVinePar2Beta.r pkg/R/gof_ECP.r pkg/R/gof_PIT.r pkg/R/gof_White.r pkg/man/BetaMatrix.Rd pkg/man/BiCopPar2Beta.Rd pkg/man/RVineGofTest.Rd pkg/man/RVinePIT.Rd pkg/man/RVinePar2Beta.Rd Removed: pkg/VineCopula.pdf Modified: pkg/R/BiCopCDF.r pkg/R/BiCopEst.r pkg/R/BiCopGofTest.r pkg/R/BiCopHfunc.r pkg/R/BiCopMetaContour.r pkg/R/BiCopName.r pkg/R/BiCopPDF.r pkg/R/BiCopPar2TailDep.r pkg/R/BiCopPar2Tau.r pkg/R/BiCopSelect.r pkg/R/BiCopSim.R pkg/R/BiCopVuongClarke.r pkg/R/RVineCopSelect.r pkg/R/RVineMLE.R pkg/R/RVineMatrix.R pkg/inst/ChangeLog pkg/man/BiCopGofTest.Rd pkg/man/VineCopula-package.Rd pkg/src/hfunc.c pkg/src/likelihood.c Log: Grosses update. Neuerungen s. ChangeLog Was jetzt noch fehlt ist die Dokumentation der Tawn copula. Die muss ich noch in alle Hilfefiles reinschreiben. Added: pkg/R/AD.R =================================================================== --- pkg/R/AD.R (rev 0) +++ pkg/R/AD.R 2013-10-09 13:49:16 UTC (rev 25) @@ -0,0 +1,20 @@ +"AD" = +function(cdf=NULL) +{ + # Cumulative distribution function test: + # Function that computes the Anderson-Darling test statistic + #-------------------------------------------------------------------------- + # INPUT: + # cdf CDF for which to compute AD test + # OUTPUT: + # AD Anderson-Darling test statistic + #-------------------------------------------------------------------------- + # Author: Daniel Berg + # Date: 27.03.2006 + # Version: 1.0.1 + #-------------------------------------------------------------------------- + n = length(cdf) + AD = .C("ADtest",as.double(cdf),as.integer(n),as.double(0),PACKAGE='VineCopula')[[3]] + AD +} + Added: pkg/R/BetaMatrix.r =================================================================== --- pkg/R/BetaMatrix.r (rev 0) +++ pkg/R/BetaMatrix.r 2013-10-09 13:49:16 UTC (rev 25) @@ -0,0 +1,48 @@ +BetaMatrix<-function(data) +{ + d<-dim(data)[2] + + betahat=matrix(1,d,d) + for(i in 1:(d-1)) + { + u1=data[,i] + for(j in (i+1):d) + { + u2=data[,j] + betahat[i,j]<-betaFunc(u1,u2,1/2,1/2) + betahat[j,i]=betahat[i,j] + } + } + +return(betahat) +} + + +# empirical copula +empcop<-function(u1,u2,u,v) +{ + n=length(u1) + a<-which(u1u) + b<-which(u2>v) + sc<-intersect(a,b) + return(1/n*length(sc)) +} + +# h_d +h<-function(u,v) (min(u,v)+min(1-u)-u*v-(1-u)*(1-v))^-1 + +# g_d +g<-function(u,v) (u*v)+(1-u)*(1-v) + +# beta +betaFunc<-function(u1,u2,u,v) h(u,v)*(empcop(u1,u2,u,v)+survivalcop(u1,u2,u,v)-g(u,v)) \ No newline at end of file Modified: pkg/R/BiCopCDF.r =================================================================== --- pkg/R/BiCopCDF.r 2013-09-18 13:08:33 UTC (rev 24) +++ pkg/R/BiCopCDF.r 2013-10-09 13:49:16 UTC (rev 25) @@ -5,8 +5,8 @@ if(any(u2>1) || any(u2<0)) stop("Data has be in the interval [0,1].") if(length(u1)!=length(u2)) stop("Lengths of 'u1' and 'u2' do not match.") if(family==2) stop("The CDF of the t-copula is not implemented.") - if(!(family %in% c(0,1,3,4,5,6,7,8,9,10,13,14,16,17,18,19,20,23,24,26,27,28,29,30,33,34,36,37,38,39,40,41,51,61,71))) stop("Copula family not implemented.") - if(family %in% c(7,8,9,10,17,18,19,20,27,28,29,30,37,38,39,40) && par2==0) stop("For BB1, BB6, BB7 and BB8 copulas, 'par2' must be set.") + if(!(family %in% c(0,1,3,4,5,6,7,8,9,10,13,14,16,17,18,19,20,23,24,26,27,28,29,30,33,34,36,37,38,39,40,41,51,61,71,104,114,124,134,204,214,224,234))) stop("Copula family not implemented.") + if(family %in% c(7,8,9,10,17,18,19,20,27,28,29,30,37,38,39,40,104,114,124,134,204,214,224,234) && par2==0) stop("For BB1, BB6, BB7, BB8 and Tawn copulas, 'par2' must be set.") if(family %in% c(1,3,4,5,6,13,14,16,23,24,26,33,34,36,41,51,61,71) && length(par)<1) stop("'par' not set.") if((family==1) && abs(par[1])>=1) stop("The parameter of the Gaussian has to be in the interval (-1,1).") @@ -36,6 +36,10 @@ if((family==30 || family==40) && (par2>=0 || par2<(-1))) stop("The second parameter of the rotated BB8 copula has to be in the interval [-1,0).") if((family==41 || family==51) && par<=0) stop("The parameter of the reflection asymmetric copula has to be positive.") if((family==61 || family==71) && par>=0) stop("The parameter of the rotated reflection asymmetric copula has to be negative.") + if ((family==104 || family==114 || family==204 || family==214) && par<1) stop("Please choose 'par' of the Tawn copula in [1,oo).") + if ((family==104 || family==114 || family==204 || family==214) && (par2<0 || par2>1)) stop("Please choose 'par2' of the Tawn copula in [0,1].") + if ((family==124 || family==134 || family==224 || family==234) && par>-1) stop("Please choose 'par' of the Tawn copula in (-oo,-1].") + if ((family==124 || family==134 || family==224 || family==234) && (par2<0 || par2>1)) stop("Please choose 'par2' of the Tawn copula in [0,1].") res = rep(NA, length(u1)) @@ -56,6 +60,59 @@ res = u2-.C("archCDF",as.double(1-u1),as.double(u2),as.integer(length(u1)),as.double(c(-par,-par2)),as.integer(family-20),as.double(rep(0,length(u1))),PACKAGE='VineCopula')[[6]] }else if(family %in% c(33,34,36:40,71)){ res = u1-.C("archCDF",as.double(u1),as.double(1-u2),as.integer(length(u1)),as.double(c(-par,-par2)),as.integer(family-30),as.double(rep(0,length(u1))),PACKAGE='VineCopula')[[6]] + }else if(family %in% c(104,114,124,134,204,214,224,234)){ # Kan spter ev. mal duch C-Code ersetzt werden + ## Hilfsterme fr die Ableitung ### + ta<-function(t,par,par2,par3) {(par2*t)^par+(par3*(1-t))^par} + ######## Pickands A + A<-function(t,par,par2,par3) {(1-par3)*(1-t)+(1-par2)*t+ta(t,par,par2,par3)^(1/par)} + + w<-function(u1,u2) {log(u2)/log(u1*u2)} + C<-function(u,v,par,par2,par3) {(u1*u2)^A(w(u1,u2),par,par2,par3)} + + if(family==104) + { + par3=1 + res=C(u1,u2,par,par2,par3) + } + else if(family==114) + { + par3=1 + res=u1+u2-1+C(1-u1,1-u2,par,par2,par3) + } + else if(family==124) + { + par3=1 + res=u2-C(1-u1,u2,-par,par2,par3) + } + else if(family==134) + { + par3=1 + res=u1-C(u1,1-u2,-par,par2,par3) + } + else if(family==204) + { + par3=par2 + par2=1 + res=C(u1,u2,par,par2,par3) + } + else if(family==214) + { + par3=par2 + par2=1 + res=u1+u2-1+C(1-u1,1-u2,par,par2,par3) + } + else if(family==224) + { + par3=par2 + par2=1 + res=u2-C(1-u1,u2,-par,par2,par3) + } + else if(family==234) + { + par3=par2 + par2=1 + res=u1-C(u1,1-u2,-par,par2,par3) + } } return(res) Modified: pkg/R/BiCopEst.r =================================================================== --- pkg/R/BiCopEst.r 2013-09-18 13:08:33 UTC (rev 24) +++ pkg/R/BiCopEst.r 2013-10-09 13:49:16 UTC (rev 25) @@ -22,7 +22,7 @@ if(length(u1)<2) stop("Number of observations has to be at least 2.") if(any(u1>1) || any(u1<0)) stop("Data has be in the interval [0,1].") if(any(u2>1) || any(u2<0)) stop("Data has be in the interval [0,1].") - if(!(family %in% c(0,1,2,3,4,5,6,7,8,9,10,13,14,16,17,18,19,20,23,24,26,27,28,29,30,33,34,36,37,38,39,40,41,51,61,71))) stop("Copula family not implemented.") + if(!(family %in% c(0,1,2,3,4,5,6,7,8,9,10,13,14,16,17,18,19,20,23,24,26,27,28,29,30,33,34,36,37,38,39,40,41,51,61,71,104,114,124,134,204,214,224,234))) stop("Copula family not implemented.") if(max.df<=2) stop("The upper bound for the degrees of freedom parameter has to be larger than 2.") if(!is.list(max.BB)) stop("'max.BB' has to be a list.") @@ -40,7 +40,7 @@ if(is.logical(se)==FALSE) stop("'se' has to be a logical variable (TRUE or FALSE).") - if(method=="itau" && family %in% c(2,7,8,9,10,17,18,19,20,27,28,29,30,37,38,39,40)) + if(method=="itau" && family %in% c(2,7,8,9,10,17,18,19,20,27,28,29,30,37,38,39,40,104,114,124,134,204,214,224,234)) { message("For two parameter copulas the estimation method 'itau' cannot be used. The method is automatically set to 'mle'.") method="mle" @@ -167,7 +167,7 @@ theta1=0 delta=0 - if(!(family%in%c(2,6,7,8,9,10,17,18,19,20,27,28,29,30,37,38,39,40))) + if(!(family%in%c(2,6,7,8,9,10,17,18,19,20,27,28,29,30,37,38,39,40,104,114,124,134,204,214,224,234))) { theta1=theta } @@ -289,14 +289,77 @@ theta1=max(-1.5,-max((max.BB$BB8[1]+1.001)/2,1.001)) } } + else if(family==104 || family==114) + { + if(tau<0) + { + print("The Tawn or survival Tawn copula cannot be used for negatively dependent data.") + delta=1 + theta1=1.001 + } + else + { + delta=0.5 # psi1 + theta1=2 + } + } + else if(family==124 || family==134) + { + if(tau>0) + { + print("The rotated Tawn copula cannot be used for positively dependent data.") + delta=1 + theta1=-1.001 + } + else + { + delta=0.5 # psi1 + theta1=-2 + } + } + else if(family==204 || family==214) + { + if(tau<0) + { + print("The Tawn2 or survival Tawn2 copula cannot be used for negatively dependent data.") + delta=1 + theta1=1.001 + } + else + { + delta=0.5 # psi1 + theta1=2 + } + } + else if(family==224 || family==234) + { + if(tau>0) + { + print("The rotated Tawn2 copula cannot be used for positively dependent data.") + delta=1 + theta1=-1.001 + } + else + { + delta=0.5 # psi1 + theta1=-2 + } + } - if(family!=0) + if(family!=0 && family<100) { out=MLE_intern(cbind(u1,u2),c(theta1, delta),family=family,se,max.df,max.BB,weights) theta=out$par if(se==TRUE) se1=out$se } + else if(family!=0 && family>100) # New + { + out=MLE_intern_Tawn(cbind(u1,u2),c(theta1, delta),family=family,se) + theta=out$par + if(se==TRUE) + se1=out$se + } } @@ -421,11 +484,11 @@ if(is.null(weights)) { - ll = .C("LL_mod",as.integer(family),as.integer(n),as.double(data[,2]),as.double(data[,1]),as.double(param[1]),as.double(param[2]),as.double(0),PACKAGE='VineCopula')[[7]] + ll = .C("LL_mod2",as.integer(family),as.integer(n),as.double(data[,1]),as.double(data[,2]),as.double(param[1]),as.double(param[2]),as.double(0),PACKAGE='VineCopula')[[7]] } else { - ll = .C("LL_mod_seperate",as.integer(family),as.integer(n),as.double(data[,2]), as.double(data[,1]), as.double(param[1]),as.double(param[2]), as.double(rep(0,n)),PACKAGE='VineCopula')[[7]]%*%weights + ll = .C("LL_mod_seperate",as.integer(family),as.integer(n),as.double(data[,1]), as.double(data[,2]), as.double(param[1]),as.double(param[2]), as.double(rep(0,n)),PACKAGE='VineCopula')[[7]]%*%weights } if(is.infinite(ll) || is.na(ll) || ll< -10^300) ll = -10^300 @@ -446,7 +509,7 @@ low = c(1.001,0.001) up = max.BB$BB8 }else if(family == 27 | family==37){ - up = c(-1.001,-0.001) + up = c(-0.001,-1.001) low = -max.BB$BB1 }else if(family == 28 | family==38){ up = c(-1.001,-1.001) @@ -480,11 +543,11 @@ { if(is.null(weights)) { - ll = .C("LL_mod",as.integer(family),as.integer(n),as.double(data[,2]),as.double(data[,1]),as.double(param[1]),as.double(param[2]),as.double(0),PACKAGE='VineCopula')[[7]] + ll = .C("LL_mod2",as.integer(family),as.integer(n),as.double(data[,1]),as.double(data[,2]),as.double(param[1]),as.double(param[2]),as.double(0),PACKAGE='VineCopula')[[7]] } else { - ll = .C("LL_mod_seperate",as.integer(family),as.integer(n),as.double(data[,2]), as.double(data[,1]), as.double(param[1]),as.double(param[2]), as.double(rep(0,n)),PACKAGE='VineCopula')[[7]]%*%weights + ll = .C("LL_mod_seperate",as.integer(family),as.integer(n),as.double(data[,1]), as.double(data[,2]), as.double(param[1]),as.double(param[2]), as.double(rep(0,n)),PACKAGE='VineCopula')[[7]]%*%weights } if(is.infinite(ll) || is.na(ll) || ll< -10^10) ll = -10^10 @@ -523,11 +586,11 @@ { if(is.null(weights)) { - ll = .C("LL_mod",as.integer(family),as.integer(n),as.double(data[,2]),as.double(data[,1]),as.double(start.parm[1]),as.double(param[1]),as.double(0),PACKAGE='VineCopula')[[7]] + ll = .C("LL_mod2",as.integer(family),as.integer(n),as.double(data[,1]),as.double(data[,2]),as.double(start.parm[1]),as.double(param[1]),as.double(0),PACKAGE='VineCopula')[[7]] } else { - ll = .C("LL_mod_seperate",as.integer(family),as.integer(n),as.double(data[,2]), as.double(data[,1]), as.double(start.parm[1]),as.double(param[1]), as.double(rep(0,n)),PACKAGE='VineCopula')[[7]]%*%weights + ll = .C("LL_mod_seperate",as.integer(family),as.integer(n),as.double(data[,1]), as.double(data[,2]), as.double(start.parm[1]),as.double(param[1]), as.double(rep(0,n)),PACKAGE='VineCopula')[[7]]%*%weights } if(is.infinite(ll) || is.na(ll) || ll< -10^300) ll = -10^300 @@ -563,11 +626,11 @@ { if(is.null(weights)) { - ll = .C("LL_mod",as.integer(family),as.integer(n),as.double(data[,2]), as.double(data[,1]), as.double(param),as.double(0), as.double(0),PACKAGE='VineCopula')[[7]] + ll = .C("LL_mod2",as.integer(family),as.integer(n),as.double(data[,1]), as.double(data[,2]), as.double(param),as.double(0), as.double(0),PACKAGE='VineCopula')[[7]] } else { - ll = .C("LL_mod_seperate",as.integer(family),as.integer(n),as.double(data[,2]), as.double(data[,1]), as.double(param[1]),as.double(0), as.double(rep(0,n)),PACKAGE='VineCopula')[[7]]%*%weights + ll = .C("LL_mod_seperate",as.integer(family),as.integer(n),as.double(data[,1]), as.double(data[,2]), as.double(param[1]),as.double(0), as.double(rep(0,n)),PACKAGE='VineCopula')[[7]]%*%weights } if(is.infinite(ll) || is.na(ll) || ll< -10^300) ll = -10^300 @@ -707,6 +770,69 @@ } +# New for Tawn + +MLE_intern_Tawn <- +function(data,start.parm,family,se=FALSE) +{ + + n = dim(data)[1] + tau <- fasttau(data[,1],data[,2]) + + if(family==104 || family==114 || family==204 || family==214) + { + parlower<-c(1.001,max(tau,0.0001)) + parupper<-c(20,min(tau+0.1,0.99)) + } + else if(family==124 || family==134 || family==224 || family==234) + { + parlower<-c(-20,max(-tau,0.0001)) + parupper<-c(-1.001,min(-tau+0.1,0.99)) + } + + # Hier fehlt noch die log-likelihood Funktion + loglikfunc = function(param) + { + ll = .C("LL_mod2",as.integer(family),as.integer(n),as.double(data[,1]), as.double(data[,2]), as.double(param[1]),as.double(param[2]), as.double(0),PACKAGE='VineCopula')[[7]] + if(is.infinite(ll) || is.na(ll) || ll< -10^300) ll = -10^300 + #print(param) + #print(ll) + return(ll) + } + + out=list() + #print(start.parm) + if(se == TRUE) + { + optimout=optim(par=start.parm,fn=loglikfunc,method=c("L-BFGS-B"),lower=parlower,upper=parupper,control=list(fnscale=-1,maxit=500), hessian=TRUE) + if(det(optimout$hessian)==0){ + var = diag(1,dim(optimout$hessian)[1]) + }else{ + var = (-solve(optimout$hessian)) + } + + out$se = sqrt(diag(var)) + } + else + { + optimout=optim(par=start.parm,fn=loglikfunc,method=c("L-BFGS-B"),lower=parlower,upper=parupper,control=list(fnscale=-1,maxit=500)) + } + + out$par = optimout$par + out$value=optimout$value + return(out) +} + + + + + + + + + + + fasttau<- function(x, y,weights=NA) { if(any(is.na(weights))){ Modified: pkg/R/BiCopGofTest.r =================================================================== --- pkg/R/BiCopGofTest.r 2013-09-18 13:08:33 UTC (rev 24) +++ pkg/R/BiCopGofTest.r 2013-10-09 13:49:16 UTC (rev 25) @@ -1,5 +1,8 @@ -BiCopGofTest<-function(u1, u2, family, par=0, par2=0, method="white", max.df=30, B=100, level=0.05) +BiCopGofTest<-function(u1, u2, family, par=0, par2=0, method="white", max.df=30, B=100) { + if(method=="White") method="white" + if(method=="Kendall") method="kendall" + if(is.null(u1)==TRUE || is.null(u2)==TRUE) stop("u1 and/or u2 are not set or have length zero.") if(length(u1)!=length(u2)) stop("Lengths of 'u1' and 'u2' do not match.") if(any(u1>1) || any(u1<0)) stop("Data has be in the interval [0,1].") @@ -38,7 +41,7 @@ } if(family==2 && method=="kendall") stop("The goodness-of-fit test based on Kendall's process is not implemented for the t-copula.") if(family%in%c(7,8,9,10,17,18,19,20,27,28,29,30,37,38,39,40) && method=="white") stop("The goodness-of-fit test based on White's information matrix equality is not implemented for the BB copulas.") - if((level < 0 || level > 1) && method=="kendall") stop("Significance level has to be between 0 and 1.") + #if((level < 0 || level > 1) && method=="kendall") stop("Significance level has to be between 0 and 1.") T=length(u1) @@ -123,6 +126,75 @@ } out=list(p.value=pvalue,statistic=test) } + else if(method=="IR") + { + # Information ratio GOF + # Step 1: maximum likelihood estimation + if(family==2) + { + if(par==0) + { + pars=BiCopEst(u1,u2,family=family,method="mle",max.df=max.df) + theta=pars$par + nu=pars$par2 + print(theta) + print(nu) + } + else + { + theta=par + nu=par2 + } + } + else + { + nu=0 + theta=BiCopEst(u1,u2,family=family,method="mle")$par + } + + # Step 2: Calculation of Hesse and gradient + if(family==2) + { + grad=c(0,0) + rho_teil=f_rho(u1,u2,theta,nu) + nu_teil=f_nu(u1,u2,theta,nu) + rho_nu_teil=f_rho_nu(u1,u2,theta,nu) + H = matrix(c(rho_teil,rho_nu_teil,rho_nu_teil,nu_teil),2,2) # Hesse matrix + grad[1]=BiCopDeriv(u1,u2,family=family,par=theta,par2=nu,deriv="par", log=TRUE) + grad[2]=BiCopDeriv(u1,u2,family=family,par=theta,par2=nu,deriv="par2", log=TRUE) + C=grad%*%t(grad) + } + else + { + d=rep(0,T) + for(t in 1:T) + { + b=BiCopPDF(u1[t],u2[t],family,theta,nu) + d[t]=BiCopDeriv2(u1[t],u2[t],family=family,par=theta,par2=nu, deriv="par")/b + } + H=mean(d) + C=BiCopDeriv(u1,u2,family=family,par=theta,par2=nu,deriv="par", log=TRUE) + } + Phi=-solve(H)%*%C + IR=trace(Phi)/dim(H)[1] #Zwischenergebnis + + #Bootstrap procedure + if(B==0) + { + out=list(IR=IR, p.value=NULL) + } + else + { + IR_boot=boot.IR(family,theta,nu,B,length(u1)) + sigma2=var(IR_boot) + IR_new=((IR-1)/sqrt(sigma2))^2 + IR_boot=((IR_boot-1)/sqrt(sigma2))^2 + p.value = mean(IR_boot>=IR_new) + + out=list(IR=IR,p.value=p.value) + } + + } else if(method=="kendall") { if(family %in% c(13,14,16,17,18,19,20)){ @@ -161,9 +233,9 @@ sn.obs<-ostat$Sn tn.obs<-ostat$Tn - k<-as.integer((1-level)*B) - sn.critical <- sn.boot[k] # critical value of test at level 0.05 - tn.critical <- tn.boot[k] # critical value of test at level 0.05 + #k<-as.integer((1-level)*B) + #sn.critical <- sn.boot[k] # critical value of test at level 0.05 + #tn.critical <- tn.boot[k] # critical value of test at level 0.05 pv.sn<-sapply(sn.obs,function(x) (1/B)*length(which(sn.boot[1:B]>=x))) # P-value of Sn @@ -251,7 +323,7 @@ sam.par<-suppressWarnings({BiCopEst(sam[,1], sam[,2],family=fam)}) # parameter estimation of sample data sim<-BiCopSim(10000,fam,sam.par$par,sam.par$par2) # generate data for the simulation of theo. K(t) - #par2 muss auf einen Integer gesetzt werden fr mvtnorm + #par2 muss auf einen Integer gesetzt werden f?r mvtnorm param$par2=round(param$par2) cormat = matrix(c(1,param$par,param$par,1),2,2) @@ -436,3 +508,50 @@ return(out) } + +############################ + +# bootstrap for IR + +boot.IR<-function(family,theta,nu,B,n) +{ + #theta und nu sind die geschaetzten Parameter + IR=rep(0,B) + for(i in 1:B) + { + sam=BiCopSim(n,family,theta,nu) + sam.par<-BiCopEst(sam[,1], sam[,2],family=family) # parameter estimation of sample data + if(family==2) + { + theta2=sam.par[1] + nu2=sam.par[2] + grad=c(0,0) + rho_teil=f_rho(sam[,1],sam[,2],theta2,nu2) + nu_teil=f_nu(sam[,1],sam[,2],theta2,nu2) + rho_nu_teil=f_rho_nu(sam[,1],sam[,2],theta2,nu2) + H = matrix(c(rho_teil,rho_nu_teil,rho_nu_teil,nu_teil),2,2) # Hesse matrix + grad[1]=BiCopDeriv(sam[,1],sam[,2],family=family,par=theta2,par2=nu2,deriv="par", log=TRUE) + grad[2]=BiCopDeriv(sam[,1],sam[,2],family=family,par=theta2,par2=nu2,deriv="par2", log=TRUE) + C=grad%*%t(grad) + } + else + { + theta2=sam.par + nu2=0 + d=rep(0,T) + for(t in 1:T) + { + b=BiCopPDF(sam[t,1],sam[t,2],family,theta,nu) + d[t]=BiCopDeriv2(sam[t,1],sam[t,2],family=family,par=theta,par2=nu, deriv="par")/b + } + H=mean(d) + C=BiCopDeriv(sam[,1],sam[,2],family=family,par=theta2,par2=nu2,deriv="par", log=TRUE) + } + Phi=-solve(H)%*%C + IR[i]=trace(Phi)/dim(H)[1] + } + + return(IR) +} + + Modified: pkg/R/BiCopHfunc.r =================================================================== --- pkg/R/BiCopHfunc.r 2013-09-18 13:08:33 UTC (rev 24) +++ pkg/R/BiCopHfunc.r 2013-10-09 13:49:16 UTC (rev 25) @@ -17,10 +17,10 @@ if(is.null(u1)==TRUE || is.null(u2)==TRUE) stop("u1 and/or u2 are not set or have length zero.") if(length(u1) != length(u2)) stop("Lengths of 'u1' and 'u2' do not match.") if(any(u1>1) || any(u1<0)) stop("Data has be in the interval [0,1].") - if(any(u2>1) || any(u2<0)) stop("Data has be in the interval [0,1].") - if(!(family %in% c(0,1,2,3,4,5,6,7,8,9,10,13,14,16,17,18,19,20,23,24,26,27,28,29,30,33,34,36,37,38,39,40,43,44, 41,51,61,71))) stop("Copula family not implemented.") - if(c(2,7,8,9,10,17,18,19,20,27,28,29,30,37,38,39,40) %in% family && par2==0) stop("For t-, BB1, BB6, BB7 and BB8 copulas, 'par2' must be set.") - if(c(1,3,4,5,6,13,14,16,23,24,26,33,34,36,41,51,61,71) %in% family && length(par)<1) stop("'par' not set.") + if(any(u2>1) || any(u2<0)) stop("Data has be in the interval [0,1].") + if(!(family %in% c(0,1,2,3,4,5,6,7,8,9,10,13,14,16,17,18,19,20,23,24,26,27,28,29,30,33,34,36,37,38,39,40,41,42,51,52,61,62,71,72,104,114,124,134,204,214,224,234))) stop("Copula family not implemented.") + if(c(2,7,8,9,10,17,18,19,20,27,28,29,30,37,38,39,40,42,52,62,72,104,114,124,134,204,214,224,234) %in% family && par2==0) stop("For t-, BB1, BB6, BB7, BB8 and Tawn copulas, 'par2' must be set.") + if(c(1,3,4,5,6,11,13,14,16,23,24,26,33,34,36,41,51,61,71) %in% family && length(par)<1) stop("'par' not set.") if((family==1 || family==2) && abs(par[1])>=1) stop("The parameter of the Gaussian and t-copula has to be in the interval (-1,1).") if(family==2 && par2<=2) stop("The degrees of freedom parameter of the t-copula has to be larger than 2.") @@ -49,6 +49,10 @@ if((family==30 || family==40) && (par2>=0 || par2<(-1))) stop("The second parameter of the rotated BB8 copula has to be in the interval [-1,0).") if((family==41 || family==51) && par<=0) stop("The parameter of the reflection asymmetric copula has to be positive.") if((family==61 || family==71) && par>=0) stop("The parameter of the rotated reflection asymmetric copula has to be negative.") + if ((family==104 || family==114 || family==204 || family==214) && par<1) stop("Please choose 'par' of the Tawn copula in [1,oo).") + if ((family==104 || family==114 || family==204 || family==214) && (par2<0 || par2>1)) stop("Please choose 'par2' of the Tawn copula in [0,1].") + if ((family==124 || family==134 || family==224 || family==234) && par>-1) stop("Please choose 'par' of the Tawn copula in (-oo,-1].") + if ((family==124 || family==134 || family==224 || family==234) && (par2<0 || par2>1)) stop("Please choose 'par2' of the Tawn copula in [0,1].") n=length(u1) Modified: pkg/R/BiCopMetaContour.r =================================================================== --- pkg/R/BiCopMetaContour.r 2013-09-18 13:08:33 UTC (rev 24) +++ pkg/R/BiCopMetaContour.r 2013-10-09 13:49:16 UTC (rev 25) @@ -213,6 +213,7 @@ } + ################################################################################# # cop.pdf # # Input: # @@ -462,6 +463,62 @@ d2=1-u2 return( pmax(a * d2 * (((12 - 9 * d1) * d1 - 3) * d2 + d1 * (6 * d1 - 8) + 2) + b * (d2 * ((d1 * (9 * d1 - 12) + 3) * d2 + (12 - 6 * d1) * d1 - 4) - 2 * d1 + 1) + 1,0) ) } + else if(copula==104) # Tawn copula (psi2 fix) + { + par=param[1] + par2=param[2] + fam=104 + return(BiCopPDF(u1,u2,fam,par,par2)) + } + else if(copula==114) # Tawn copula (psi2 fix) + { + par=param[1] + par2=param[2] + fam=104 + return(BiCopPDF(1-u1,1-u2,fam,par,par2)) + } + else if(copula==124) # Tawn copula (psi2 fix) + { + par=-param[1] + par2=param[2] + fam=104 + return(BiCopPDF(1-u1,u2,fam,par,par2)) + } + else if(copula==134) # Tawn copula (psi2 fix) + { + par=-param[1] + par2=param[2] + fam=104 + return(BiCopPDF(u1,1-u2,fam,par,par2)) + } + else if(copula==204) # Tawn copula (psi1 fix) + { + par=param[1] + par2=param[2] + fam=204 + return(BiCopPDF(u1,u2,fam,par,par2)) + } + else if(copula==214) # Tawn copula (psi1 fix) + { + par=param[1] + par2=param[2] + fam=204 + return(BiCopPDF(1-u1,1-u2,fam,par,par2)) + } + else if(copula==224) # Tawn copula (psi1 fix) + { + par=-param[1] + par2=param[2] + fam=204 + return(BiCopPDF(1-u1,u2,fam,par,par2)) + } + else if(copula==234) # Tawn copula (psi1 fix) + { + par=-param[1] + par2=param[2] + fam=204 + return(BiCopPDF(u1,1-u2,fam,par,par2)) + } } @@ -514,8 +571,8 @@ if(is.null(u1)==FALSE && (any(u1>1) || any(u1<0))) stop("Data has be in the interval [0,1].") if(is.null(u2)==FALSE && (any(u2>1) || any(u2<0))) stop("Data has be in the interval [0,1].") #if(length(u1)!=length(u2)) stop("Lengths of 'u1' and 'u2' do not match.") - if(!(family %in% c(0,1,2,3,4,5,6,7,8,9,10,13,14,16,17,18,19,20,23,24,26,27,28,29,30,33,34,36,37,38,39,40,41,42,51,52,61,62,71,72, "emp"))) stop("Copula family not implemented.") - if(c(2,7,8,9,10,17,18,19,20,27,28,29,30,37,38,39,40,42,52,62,72) %in% family && par2==0) stop("For t-, BB1 and BB7 copulas, 'par2' must be set.") + if(!(family %in% c(0,1,2,3,4,5,6,7,8,9,10,13,14,16,17,18,19,20,23,24,26,27,28,29,30,33,34,36,37,38,39,40,41,42,51,52,61,62,71,72,104,114,124,134,204,214,224,234, "emp"))) stop("Copula family not implemented.") + if(c(2,7,8,9,10,17,18,19,20,27,28,29,30,37,38,39,40,42,52,62,72,104,114,124,134,204,214,224,234) %in% family && par2==0) stop("For t-, BB1, BB6, BB7, BB8 and Tawn copulas, 'par2' must be set.") if(c(1,3,4,5,6,11,13,14,16,23,24,26,33,34,36,41,51,61,71) %in% family && length(par)<1) stop("'par' not set.") # size sollte nicht zu gross sein @@ -562,6 +619,10 @@ if(abs(b)>1) stop("The second parameter of the two-parametric asymmetric copulas has to be in the interval [-1,1]") if(a>1 || a1)) stop("Please choose 'par2' of the Tawn copula in [0,1].") + if ((family==124 || family==134 || family==224 || family==234) && par>-1) stop("Please choose 'par' of the Tawn copula in (-oo,-1].") + if ((family==124 || family==134 || family==224 || family==234) && (par2<0 || par2>1)) stop("Please choose 'par2' of the Tawn copula in [0,1].") if(PLOT!=TRUE && PLOT!=FALSE) stop("The parameter 'PLOT' has to be set to 'TRUE' or 'FALSE'.") @@ -616,7 +677,7 @@ if(family!="emp") { - if(family %in% c(2,7,8,9,10,17,18,19,20,27,28,29,30,37,38,39,40,42,52,62,72)) + if(family %in% c(2,7,8,9,10,17,18,19,20,27,28,29,30,37,38,39,40,42,52,62,72,104,114,124,134,204,214,224,234)) z <- matrix(data=meta.dens(x1=rep(x=x, each=size), x2=rep(x=y, times=size), param=c(par,par2), copula=family, margins=margins, margins.par=margins.par), nrow=size, byrow=TRUE) else Modified: pkg/R/BiCopName.r =================================================================== --- pkg/R/BiCopName.r 2013-09-18 13:08:33 UTC (rev 24) +++ pkg/R/BiCopName.r 2013-10-09 13:49:16 UTC (rev 25) @@ -43,6 +43,14 @@ else if(family==51) fam="1-par AS180" else if(family==61) fam="1-par AS90" else if(family==71) fam="1-par AS270" + else if(family==104) fam="Tawn" + else if(family==114) fam="Tawn180" + else if(family==124) fam="Tawn90" + else if(family==134) fam="Tawn270" + else if(family==204) fam="Tawn2" + else if(family==214) fam="Tawn2_180" + else if(family==224) fam="Tawn2_90" + else if(family==234) fam="Tawn2_270" else stop("Family not implemented.") } else # langer Name @@ -84,6 +92,14 @@ else if(family==51) fam="Rotated 1-parametric asymmetric 180 degree" else if(family==61) fam="Rotated 1-parametric asymmetric 90 degree" else if(family==71) fam="Rotated 1-parametric asymmetric 270 degree" + else if(family==104) fam="Tawn" + else if(family==114) fam="Rotated Tawn 180 degrees" + else if(family==124) fam="Rotated Tawn 90 degrees" + else if(family==134) fam="Rotated Tawn 270 degrees" + else if(family==204) fam="Tawn2" + else if(family==214) fam="Rotated Tawn2 180 degrees" + else if(family==224) fam="Rotated Tawn2 90 degrees" + else if(family==234) fam="Rotated Tawn2 270 degrees" else stop("Family not implemented.") } } @@ -125,6 +141,14 @@ else if(family=="1-par AS180" || family=="Rotated 1-parametric asymmetric 180 degree") fam=51 else if(family=="1-par AS90" || family=="Rotated 1-parametric asymmetric 90 degree") fam=61 else if(family=="1-par AS270" || family=="Rotated 1-parametric asymmetric 270 degree") fam=71 + else if(family=="Tawn") fam=104 + else if(family=="Tawn180" || family=="Rotated Tawn 180 degrees") fam=114 + else if(family=="Tawn90" || family=="Rotated Tawn 90 degrees") fam=124 + else if(family=="Tawn270" || family=="Rotated Tawn 270 degrees") fam=134 + else if(family=="Tawn2") fam=204 + else if(family=="Tawn2_180" || family=="Rotated Tawn2 180 degrees") fam=214 + else if(family=="Tawn2_90" || family=="Rotated Tawn2 90 degrees") fam=224 + else if(family=="Tawn2_270" || family=="Rotated Tawn2 270 degrees") fam=234 else stop("Family not implemented.") } Modified: pkg/R/BiCopPDF.r =================================================================== --- pkg/R/BiCopPDF.r 2013-09-18 13:08:33 UTC (rev 24) +++ pkg/R/BiCopPDF.r 2013-10-09 13:49:16 UTC (rev 25) @@ -4,8 +4,8 @@ if(length(u1)!=length(u2)) stop("Lengths of 'u1' and 'u2' do not match.") if(any(u1>1) || any(u1<0)) stop("Data has be in the interval [0,1].") if(any(u2>1) || any(u2<0)) stop("Data has be in the interval [0,1].") - if(!(family %in% c(0,1,2,3,4,5,6,7,8,9,10,13,14,16,17,18,19,20,23,24,26,27,28,29,30,33,34,36,37,38,39,40,41,51,61,71))) stop("Copula family not implemented.") - if(family %in% c(2,7,8,9,10,17,18,19,20,27,28,29,30,37,38,39,40) && par2==0) stop("For t-, BB1, BB6, BB7 and BB8 copulas, 'par2' must be set.") + if(!(family %in% c(0,1,2,3,4,5,6,7,8,9,10,13,14,16,17,18,19,20,23,24,26,27,28,29,30,33,34,36,37,38,39,40,41,51,61,71,104,114,124,134,204,214,224,234))) stop("Copula family not implemented.") + if(family %in% c(2,7,8,9,10,17,18,19,20,27,28,29,30,37,38,39,40,104,114,124,134,204,214,224,234) && par2==0) stop("For t-, BB1, BB6, BB7, BB8 and Tawn copulas, 'par2' must be set.") if(family %in% c(1,3,4,5,6,13,14,16,23,24,26,33,34,36,41,51,61,71) && length(par)<1) stop("'par' not set.") if((family==1 || family==2) && abs(par[1])>=1) stop("The parameter of the Gaussian and t-copula has to be in the interval (-1,1).") @@ -35,6 +35,10 @@ if((family==30 || family==40) && (par2>=0 || par2<(-1))) stop("The second parameter of the rotated BB8 copula has to be in the interval [-1,0).") if((family==41 || family==51) && par<=0) stop("The parameter of the reflection asymmetric copula has to be positive.") if((family==61 || family==71) && par>=0) stop("The parameter of the rotated reflection asymmetric copula has to be negative.") + if ((family==104 || family==114 || family==204 || family==214) && par<1) stop("Please choose 'par' of the Tawn copula in [1,oo).") + if ((family==104 || family==114 || family==204 || family==214) && (par2<0 || par2>1)) stop("Please choose 'par2' of the Tawn copula in [0,1].") + if ((family==124 || family==134 || family==224 || family==234) && par>-1) stop("Please choose 'par' of the Tawn copula in (-oo,-1].") + if ((family==124 || family==134 || family==224 || family==234) && (par2<0 || par2>1)) stop("Please choose 'par2' of the Tawn copula in [0,1].") coplik = .C("LL_mod_seperate",as.integer(family),as.integer(length(u1)),as.double(u1),as.double(u2),as.double(par),as.double(par2),as.double(rep(0,length(u1))),PACKAGE='VineCopula')[[7]] Added: pkg/R/BiCopPar2Beta.r =================================================================== --- pkg/R/BiCopPar2Beta.r (rev 0) +++ pkg/R/BiCopPar2Beta.r 2013-10-09 13:49:16 UTC (rev 25) @@ -0,0 +1,6 @@ +BiCopPar2Beta <- function(family,par,par2=0) +{ + blomBeta=4*BiCopCDF(0.5,0.5,family,par,par2)-1 + + return(blomBeta) +} \ No newline at end of file Modified: pkg/R/BiCopPar2TailDep.r =================================================================== --- pkg/R/BiCopPar2TailDep.r 2013-09-18 13:08:33 UTC (rev 24) +++ pkg/R/BiCopPar2TailDep.r 2013-10-09 13:49:16 UTC (rev 25) @@ -1,8 +1,8 @@ BiCopPar2TailDep<-function(family,par,par2=0) { - if(!(family %in% c(0,1,2,3,4,5,6,7,8,9,10,13,14,16,17,18,19,20,23,24,26,27,28,29,30,33,34,36,37,38,39,40))) stop("Copula family not implemented.") - if(c(2,7,8,9,10,17,18,19,20,27,28,29,30,37,38,39,40) %in% family && par2==0) stop("For t-, BB1, BB6, BB7 and BB8 copulas, 'par2' must be set.") - if(c(1,3,4,5,6,13,14,16,23,24,26,33,34,36) %in% family && length(par)<1) stop("'par' not set.") + if(!(family %in% c(0,1,2,3,4,5,6,7,8,9,10,13,14,16,17,18,19,20,23,24,26,27,28,29,30,33,34,36,37,38,39,40,41,42,51,52,61,62,71,72,104,114,124,134,204,214,224,234))) stop("Copula family not implemented.") + if(c(2,7,8,9,10,17,18,19,20,27,28,29,30,37,38,39,40,42,52,62,72,104,114,124,134,204,214,224,234) %in% family && par2==0) stop("For t-, BB1, BB6, BB7, BB8 and Tawn copulas, 'par2' must be set.") + if(c(1,3,4,5,6,11,13,14,16,23,24,26,33,34,36,41,51,61,71) %in% family && length(par)<1) stop("'par' not set.") if((family==1 || family==2) && abs(par[1])>=1) stop("The parameter of the Gaussian and t-copula has to be in the interval (-1,1).") [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/vinecopula -r 25 From noreply at r-forge.r-project.org Wed Oct 9 16:06:35 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 9 Oct 2013 16:06:35 +0200 (CEST) Subject: [Vinecopula-commits] r26 - pkg Message-ID: <20131009140635.13988184F7B@r-forge.r-project.org> Author: ulf Date: 2013-10-09 16:06:34 +0200 (Wed, 09 Oct 2013) New Revision: 26 Modified: pkg/DESCRIPTION pkg/NAMESPACE Log: Modified: pkg/DESCRIPTION =================================================================== --- pkg/DESCRIPTION 2013-10-09 13:49:16 UTC (rev 25) +++ pkg/DESCRIPTION 2013-10-09 14:06:34 UTC (rev 26) @@ -1,12 +1,12 @@ Package: VineCopula Type: Package Title: Statistical inference of vine copulas -Version: 1.1-3 -Date: 2013-09-18 +Version: 1.2 +Date: 2013-09-03 Author: Ulf Schepsmeier, Jakob Stoeber, Eike Christian Brechmann, Benedikt Graeler Maintainer: Ulf Schepsmeier Depends: R (>= 2.11.0), MASS, mvtnorm, igraph -Suggests: CDVine, TSP +Suggests: CDVine, TSP, ADGofTest Description: This package provides functions for statistical inference of vine copulas. It contains tools for bivariate exploratory data analysis, bivariate copula selection and (vine) tree construction. Models can be estimated either sequentially or by joint maximum likelihood estimation. Sampling algorithms and plotting methods are also included. Data is assumed to lie in the unit hypercube (so-called copula data). For C- and D-vines links to the package CDVine are provided. License: GPL (>= 2) LazyLoad: yes Modified: pkg/NAMESPACE =================================================================== --- pkg/NAMESPACE 2013-10-09 13:49:16 UTC (rev 25) +++ pkg/NAMESPACE 2013-10-09 14:06:34 UTC (rev 26) @@ -48,7 +48,13 @@ export(TauMatrix) export(RVineCor2pcor,RVinePcor2cor, RVineMatrixNormalize) +export(RVinePIT) +export(RVineGofTest) +export(BiCopPar2Beta) +export(RVinePar2Beta) +export(BetaMatrix) + S3method(print, RVineMatrix) useDynLib("VineCopula") \ No newline at end of file From noreply at r-forge.r-project.org Wed Oct 9 17:02:49 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 9 Oct 2013 17:02:49 +0200 (CEST) Subject: [Vinecopula-commits] r27 - pkg/man Message-ID: <20131009150250.109341860A9@r-forge.r-project.org> Author: ulf Date: 2013-10-09 17:02:49 +0200 (Wed, 09 Oct 2013) New Revision: 27 Modified: pkg/man/BiCopCDF.Rd Log: Hier mal eine Probedatei mit der Dokumentation der Tawn copula. Ist das so verstaendlich? Modified: pkg/man/BiCopCDF.Rd =================================================================== --- pkg/man/BiCopCDF.Rd 2013-10-09 14:06:34 UTC (rev 26) +++ pkg/man/BiCopCDF.Rd 2013-10-09 15:02:49 UTC (rev 27) @@ -44,7 +44,15 @@ \code{37} = rotated BB1 copula (270 degrees) \cr \code{38} = rotated BB6 copula (270 degrees) \cr \code{39} = rotated BB7 copula (270 degrees) \cr - \code{40} = rotated BB8 copula (270 degrees) + \code{40} = rotated BB8 copula (270 degrees) \cr + \code{104} = Tawn copula with fixed third parameter \cr + \code{114} = rotated Tawn copula (180 degrees) with fixed third parameter \cr + \code{124} = rotated Tawn copula (90 degrees) with fixed third parameter \cr + \code{134} = rotated Tawn copula (270 degrees) with fixed third parameter \cr + \code{204} = Tawn copula with fixed second parameter \cr + \code{214} = rotated Tawn copula (180 degrees) with fixed second parameter \cr + \code{224} = rotated Tawn copula (90 degrees) with fixed second parameter \cr + \code{234} = rotated Tawn copula (270 degrees) with fixed second parameter \cr } \item{par}{Copula parameter.} \item{par2}{Second parameter for bivariate copulas with two parameters (t, BB1, BB6, BB7, BB8; default: \code{par2 = 0}). \code{par2} should be an positive integer for the Students's t copula \code{family=2}.} From noreply at r-forge.r-project.org Thu Oct 10 09:28:40 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 10 Oct 2013 09:28:40 +0200 (CEST) Subject: [Vinecopula-commits] r28 - in pkg/src: . include Message-ID: <20131010072840.E414A185D1F@r-forge.r-project.org> Author: ulf Date: 2013-10-10 09:28:40 +0200 (Thu, 10 Oct 2013) New Revision: 28 Added: pkg/src/evCopula.c pkg/src/gof.c pkg/src/include/evCopula.h pkg/src/include/gof.h pkg/src/include/pit.h pkg/src/pit.c Log: Sorry, anscheinend hat das SVN die C-Dateien nicht commited Added: pkg/src/evCopula.c =================================================================== --- pkg/src/evCopula.c (rev 0) +++ pkg/src/evCopula.c 2013-10-10 07:28:40 UTC (rev 28) @@ -0,0 +1,265 @@ +#include "include/vine.h" +#include "include/evCopula.h" +#include + +#define UMAX 1-1e-10 + +#define UMIN 1e-10 + +#define XEPS 1e-4 + +// Some function for the Tawn copula + +// CDF +void ta(double* t, int* n, double* par, double* par2, double* par3, double* out) //fr CDF +{ + int i=0; + double t1,t2; + for(i=0; i<*n;i++) + { + t1=pow(*par2*t[i],*par); + t2=pow(*par3*(1.0-t[i]),*par); + out[i]=t1+t2; + } +} + +//ta<-function(t,par,par2,par3) {(par2*t)^par+(par3*(1-t))^par} + +// Pickands A +void Tawn(double* t, int* n, double* par, double* par2, double* par3, double* out) //fr CDF +{ + int i=0, T=1; + double t1,t2,t3,t4; + for(i=0; i<*n;i++) + { + t1=(1.0-*par3)*(1.0-t[i]); + t2=(1.0-*par2)*t[i]; + ta(t, &T, par, par2, par3, &t3); + t4=pow(t3,1.0/(*par)); + out[i]=t1+t2+t4; + } +} + +//Tawn<-function(t,par,par2,par3) {(1-par3)*(1-t)+(1-par2)*t+ta(t,par,par2,par3)^(1/par)} + +void TawnCDF(double* u, double* v, int* n, double* par, double* par2, double* par3, double* out) // CDF-function +{ + int i=0, T=1; + double w, A; + for(i=0; i<*n;i++) + { + w=log(v[i])/log(u[i]*v[i]); + Tawn(&w, &T, par, par2, par3, &A); //!!! + out[i]=pow(u[i]*v[i],A); + } +} + + +////////////////////////////////////////////////////////////////// +// PDF + +void ta2(double* t, int* n, double* par, double* par2, double* par3, double* out) //fr PDF +{ + int i=0; + double t1,t2; + for(i=0; i<*n;i++) + { + t1=pow(*par3*t[i],*par); + t2=pow(*par2*(1.0-t[i]),*par); + out[i]=t1+t2; + } +} + +void d1ta(double* t, int* n, double* par, double* par2, double* par3, double* out) //fr PDF +{ + int i=0; + double t1,t2; + for(i=0; i<*n;i++) + { + t1=*par3 * pow((*par3*t[i]),*par-1.0); + t2=*par2 * pow(*par2*(1.0-t[i]),*par-1.0); + out[i]=*par*(t1-t2); + } +} + +//d1ta<-function(t,par,par2,par3) {par*(par3*(par3*t)^(par-1)-par2*(par2*(1-t))^(par-1))} + +void d2ta(double* t, int* n, double* par, double* par2, double* par3, double* out) //fr PDF +{ + int i=0; + double t1,t2; + for(i=0; i<*n;i++) + { + t1=pow(*par3,2) * pow(*par3*t[i],*par-2.0); + t2=pow(*par2,2) * pow(*par2*(1.0-t[i]),*par-2.0); + out[i]=*par*(*par-1) * (t1 + t2); + } +} + +//d2ta<-function(t,par,par2,par3) {par*(par-1)*(par3^2*(par3*t)^(par-2)+par2^2*(par2*(1-t))^(par-2))} + + +void Tawn2(double* t, int* n, double* par, double* par2, double* par3, double* out) //fr PDF +{ + int i=0, T=1; + double t1,t2,t3,t4; + for(i=0; i<*n;i++) + { + t1=(1.0-*par2)*(1.0-t[i]); + t2=(1.0-*par3)*t[i]; + ta2(&t[i], &T, par, par2, par3, &t3); //!!! + t4=pow(t3,1.0/(*par)); + out[i]=t1+t2+t4; + } +} + +//Tawn<-function(t,par,par2,par3) {(1-par2)*(1-t)+(1-par3)*t+ta(t,par,par2,par3)^(1/par)} + +void d1Tawn(double* t, int* n, double* par, double* par2, double* par3, double* out) //fr PDF +{ + int i=0, T=1; + double t2,t1; + for(i=0; i<*n;i++) + { + ta2(&t[i], &T, par, par2, par3, &t1); //!! + d1ta(&t[i], &T, par, par2, par3, &t2); + out[i]=*par2-*par3+1.0/(*par) * pow(t1,(1.0/(*par)-1.0)) * t2; + } +} + +//d1Tawn<-function(t,par,par2,par3) {par2-par3+1/par*ta(t,par,par2,par3)^(1/par-1)*d1ta(t,par,par2,par3)} Wie in Afunc2Deriv + +void d2Tawn(double* t, int* n, double* par, double* par2, double* par3, double* out) //fr PDF +{ + int i=0, T=1; + double t2,t1,t3; + for(i=0; i<*n;i++) + { + ta2(&t[i], &T, par, par2, par3, &t1); //!! + d1ta(&t[i], &T, par, par2, par3, &t2); + d2ta(&t[i], &T, par, par2, par3, &t3); + out[i] = 1.0/(*par) * ( (1.0/(*par)-1.0) * pow(t1,(1.0/(*par)-2)) * pow(t2,2) + pow(t1,(1.0/(*par)-1)) * t3 ); + } +} + +//d2Tawn<-function(t,par,par2,par3) {1/par*((1/par-1)*ta(t,par,par2,par3)^(1/par-2)*d1ta(t,par,par2,par3)^2+ta(t,par,par2,par3)^(1/par-1)*d2ta(t,par,par2,par3))} + +// Ableitung von A nach u +void dA_du(double* u, double* v, int* n, double* par, double* par2, double* par3, double* out) +{ + int i=0, T=1; + double dA, dw, w; + for(i=0; i<*n;i++) + { + w=log(v[i]) / log(u[i]*v[i]); + dw=-log(v[i]) / (u[i]*pow(log(u[i]*v[i]),2.0)); + d1Tawn(&w, &T, par, par2, par3, &dA); + out[i]=dA*dw; + } +} + +//dA_du<-function(u,v,par,par2,par3) {evcBiCopAfuncDeriv(w(u,v),fam,par,par2,par3)*dw_du(u,v)} + +void dA_dv(double* u, double* v, int* n, double* par, double* par2, double* par3, double* out) +{ + int i=0, T=1; + double dA, dw, w; + for(i=0; i<*n;i++) + { + w=log(v[i])/log(u[i]*v[i]); + dw=1.0 / (v[i]*log(u[i]*v[i])) - log(v[i]) / (v[i]*pow(log(u[i]*v[i]),2)); + d1Tawn(&w, &T, par, par2, par3, &dA); + out[i]=dA*dw; + } +} + +void dA_dudv(double* u, double* v, int* n, double* par, double* par2, double* par3, double* out) +{ + int i=0, T=1; + double dA, dw_dv, dw_du, w, d2w_dudv, d2A; + for(i=0; i<*n;i++) + { + w=log(v[i])/log(u[i]*v[i]); + dw_du=-log(v[i])/(u[i]*pow(log(u[i]*v[i]),2)); + dw_dv=1.0 / (v[i]*log(u[i]*v[i])) - log(v[i]) / (v[i]*pow(log(u[i]*v[i]),2)); + d2w_dudv = 2*log(v[i]) / (v[i]*u[i]*pow(log(u[i]*v[i]),3)) - 1.0 / (v[i]*u[i]*pow(log(u[i]*v[i]),2)); + d1Tawn(&w, &T, par, par2, par3, &dA); + d2Tawn(&w, &T, par, par2, par3, &d2A); + out[i]=d2A*dw_dv*dw_du + dA*d2w_dudv; + } +} + +//d2A_dudv<-function(u,v,par,par2,par3) {evcBiCopAfunc2Deriv(w(u,v),fam,par,par2,par3)*dw_dv(u,v)*dw_du(u,v)+evcBiCopAfuncDeriv(w(u,v),fam,par,par2,par3)*d2w_dudv(u,v)} + + +void TawnC(double* u, double* v, int* n, double* par, double* par2, double* par3, double* out) // fr PDF +{ + int i=0, T=1; + double w, A; + for(i=0; i<*n;i++) + { + w=log(v[i])/log(u[i]*v[i]); + Tawn2(&w, &T, par, par2, par3, &A); //!!! + out[i]=pow(u[i]*v[i],A); + } +} + +// Ableitung von C nach u +void dC_du(double* u, double* v, int* n, double* par, double* par2, double* par3, double* out) +{ + int i=0, T=1; + double w, A, C, dA; + for(i=0; i<*n;i++) + { + w=log(v[i])/log(u[i]*v[i]); + Tawn2(&w, &T, par, par2, par3, &A); //!! + TawnC(&u[i], &v[i], &T, par, par2, par3, &C); //!! + dA_du(&u[i], &v[i], &T, par, par2, par3, &dA); + out[i]=C * (1.0 / u[i] * A + log(u[i]*v[i])*dA); + } +} + +//dC_du<-function(u,v,par,par2,par3) {C(u,v,par,par2,par3) * (1/u*evcBiCopAfunc(w(u,v),fam,par,par2,par3)+log(u*v) * dA_du(u,v,par,par2,par3))} + +void TawnPDF(double* u, double* v, int* n, double* par, double* par2, double* par3, double* out) +{ + int i=0, T=1; + double w, A, dC, t3, t4, t1, C, t5, t2; + for(i=0; i<*n;i++) + { + w=log(v[i])/log(u[i]*v[i]); + Tawn2(&w, n, par, par2, par3, &A); + dC_du(&u[i], &v[i], &T, par, par2, par3, &dC); + dA_du(&u[i], &v[i], &T, par, par2, par3, &t3); + dA_dv(&u[i], &v[i], &T, par, par2, par3, &t4); + t1=dC * (1.0/v[i] * A + log(u[i]*v[i]) * t4); + TawnC(&u[i], &v[i], &T, par, par2, par3, &C); + dA_dudv(&u[i], &v[i], &T, par, par2, par3, &t5); + t2=C * (1.0/u[i]*t4 + 1.0/v[i]*t3 + log(u[i]*v[i])*t5); + out[i]=t1+t2; + } +} + + +// d2C_dvdu<-function(u,v,par,par2,par3) +// { +// dC_du(u,v,par,par2,par3)*(1/v*evcBiCopAfunc(w(u,v),fam,par,par2,par3) + log(u*v)*dA_dv(u,v,par,par2,par3))+ +// C(u,v,par,par2,par3)* +// (1/u*dA_dv(u,v,par,par2,par3) + 1/v*dA_du(u,v,par,par2,par3)+log(u*v)*d2A_dudv(u,v,par,par2,par3)) +// } + + +// Ableitung von C nach v (fuer h-function) +void dC_dv(double* u, double* v, int* n, double* par, double* par2, double* par3, double* out) +{ + int i=0, T=1; + double w, A, C, dA; + for(i=0; i<*n;i++) + { + w=log(v[i])/log(u[i]*v[i]); + Tawn2(&w, &T, par, par2, par3, &A); //!! + TawnC(&u[i], &v[i], &T, par, par2, par3, &C); //!! + dA_dv(&u[i], &v[i], &T, par, par2, par3, &dA); + out[i]=C * (1.0 / v[i] * A + log(u[i]*v[i])*dA); + } +} \ No newline at end of file Added: pkg/src/gof.c =================================================================== --- pkg/src/gof.c (rev 0) +++ pkg/src/gof.c 2013-10-10 07:28:40 UTC (rev 28) @@ -0,0 +1,667 @@ +#include "include/vine.h" +#include "include/memoryhandling.h" +#include "include/gof.h" +#include "include/rvinederiv2.h" +#include "include/pit.h" +#include "include/rvine.h" + +///////////////////////////////////////////////////////////////////// +// Code form Daniel Berg, R-package copulaGOF +// AD: Anderson-Darling GOF test +// (Cumulative distribution function test) +// INPUT: +// cdf CDF for which to compute the test +// n Length of cdf +///////////////////////////////////////////////////////////////////// +void ADtest(double* cdf, int* n, double* out) +{ + int j; + double sum=0.0; + for(j=0;j<*n;j++) sum += (2.0*((double)j+1.0)-1.0)*(log(cdf[j])+log(1.0-cdf[*n-1-j])); + *out = -(double)*n-(1.0/(double)*n)*sum; +} + + +/////////////////////////////////////////////////////////////////////////////// +// Code form Daniel Berg, R-package copulaGOF +// Function to compute cumulative distribution function of a uniform vector x ($\hat F(x)$) +/////////////////////////////////////////////////////////////////////////////// +void CumDist(double* x, int* i_n, int* i_m, double* out) +{ + int i,j,n,m; + double *y; + n=*i_n; m=*i_m; + y = malloc(m*sizeof(double)); + for(i=0;imaxdist) maxdist = tmp; + } + *out = sqrt((double)*n)*maxdist; +} + + + +//////////////////////////////////////////////////////// +// Goodness-of-fit test based on White's information equality +// by U. Schepsmeier +/////////////////////////////////////////////////////////// + +void White(int* T, int* d, int* family, int* maxmat, int* matrix, int* condirect, int* conindirect, double* par, double* par2, double* data, double* D, double* V) +{ + int i=0, dd=0, tt=0, k=1, j=0, kk=0, t=0, mm=0, dd2=0; + double *Dprime, *hess, *subhess, *der, *subder, *dat, *hess_red, *der_red; + + for(i=0; i<(*d*(*d));i++) + { + if(family[i]!=0) dd++; + if(family[i]==2) tt++; + } + mm=(dd+tt)*(dd+tt+1)/2; + dd2=*d*(*d-1)/2; + + //Allocate memory + //V = create_matrix((dd+tt)*(dd+tt+1)/2,(dd+tt)*(dd+tt+1)/2); + //D = malloc((dd+tt)*(dd+tt+1)/2*sizeof(double)); + Dprime = malloc((dd+tt)*(dd+tt+1)/2*sizeof(double)); + hess = malloc((dd2+tt)*(dd2+tt)*sizeof(double)); + subhess = malloc((dd2+tt)*(dd2+tt)*sizeof(double)); + der = malloc((dd2+tt)*(dd2+tt)*sizeof(double)); + subder = malloc((dd2+tt)*(dd2+tt)*sizeof(double)); + hess_red = malloc((dd+tt)*(dd+tt)*sizeof(double)); + der_red = malloc((dd+tt)*(dd+tt)*sizeof(double)); + dat = malloc(*d*sizeof(double)); + + // initialisieren + for(i=0;i=*statistic) + *pvalue+=1.0/(*B); + } + + free(f); + free(bdata); +} + + + +/* Equal probability sampling; with-replacement case */ + +void MySample(int *k, int *n, int *y) +{ + int i; + + GetRNGstate(); + for (i = 0; i < *k; i++) + { + y[i] = (int) *n * unif_rand() + 1; + } + PutRNGstate(); +} + + +//////////////////////////////////////////////////////////////// + +// gof-test based on empirical copula process + +void gofECP(int* T, int* d, int* family, int* maxmat, int* matrix, int* conindirect, double* par, double* par2, double* data, double* statistic, int* statisticName) +{ + double *znull, *Chat1, *Chat2; + int T2=1000, i=0, t=0; + znull = malloc(*d*1000*sizeof(double)); + Chat1 = malloc(*T*sizeof(double)); + Chat2 = malloc(*T*sizeof(double)); + + for(t=0;t=*statistic) + *pvalue+=1.0/(*B); + } + + free(f); + free(bdata); +} + + +// n = dim(u)[1] +// m = dim(data)[1] +// Chat vector of length n + +void ChatZj(double* data, double* u, int* n, int* d, int* m, double* Chat) +{ + int i,j,k; + double *helpvar; + helpvar=malloc(*m*sizeof(double)); + + for(j=0;j<*n;j++) + { + Chat[j]=0; + for(k=0;k<*m;k++) + { + helpvar[k]=0; + for(i=0;i<*d;i++) + { + if(data[k+1+(*m*i)-1]<=u[j+1+(*n*i)-1]) + helpvar[k]++; + } + if(helpvar[k]==*d) + Chat[j]++; + } + Chat[j]/=(*m+1); + } + + free(helpvar); +} + +void C_ind(double* data, int* n, int* d, double* C) +{ + int t=0, i=0; + + for(t=0;t<*n;t++) + { + for(i=0;i<*d;i++) + { + if(i==0) + C[t]=data[t+1+(*n*i)-1]; + else + C[t]=C[t] * data[t+1+(*n*i)-1]; + } + + } +} + + + +void gofECP2(int* T, int* d, int* family, int* maxmat, int* matrix, int* condirect, int* conindirect, double* par, double* par2, double* data, + double* vv, double* vv2, int* calcupdate, double* statistic, int* statisticName) +{ + double *udata, *Chat1, *Chat2; + int i=0, t=0; + udata = malloc(*d*(*T)*sizeof(double)); + Chat1 = malloc(*T*sizeof(double)); + Chat2 = malloc(*T*sizeof(double)); + + for(t=0;t<*T;t++) + { + for(i=0;i<*d;i++) + { + udata[t+1+(*T*i)-1]=0; + } + } + for(t=0;t<*T;t++) + { + Chat1[t]=0; + Chat2[t]=1; + } + + RvinePIT(T, d, family, maxmat, matrix, condirect, conindirect, par, par2, data, udata, vv, vv2, calcupdate); + ChatZj(udata, udata, T, d, T, Chat1); + + C_ind(udata,T,d,Chat2); + + *statistic=0; + if(*statisticName==3) //Cramer-von Mises test statistic + { + for(i=0;i<*T;i++) + { + *statistic+=pow(Chat1[i]-Chat2[i],2); + } + } + else if(*statisticName==2) // KS + { + for(i=0;i<*T;i++) + { + *statistic=MAX(fabs(Chat1[i]-Chat2[i]),*statistic); + } + *statistic=*statistic*sqrt(*T); + } + + free(udata); + free(Chat1); + free(Chat2); +} + +void gofECP2_pvalue(int* T, int* d, int* family, int* maxmat, int* matrix, int* condirect, int* conindirect, double* par, double* par2, double* data, + double* vv, double* vv2, int* calcupdate, double* statistic, double* pvalue, int* statisticName, int* B) +{ + int i=0, m=0, t=0, *f; + double *bdata, bstat=0; + + f = malloc(*T*sizeof(int)); + bdata = malloc(*d*(*T)*sizeof(double)); + //Rprintf("%f\n",*statistic); + for(m=0;m<*B;m++) + { + MySample(T, T, f); + for(t=0;t<*T;t++) + { + for(i=0;i<*d;i++) + { + bdata[(t+1)+(*T*i)-1]=data[(f[t]+1)+(*T*i)-1]; + } + } + bstat=0; + gofECP2(T, d, family, maxmat, matrix, condirect, conindirect, par, par2, bdata, vv, vv2, calcupdate, &bstat, statisticName); + //Rprintf("%f ",bstat); + if(bstat>=*statistic) + *pvalue+=1.0/(*B); + } + + free(f); + free(bdata); +} Added: pkg/src/include/evCopula.h =================================================================== --- pkg/src/include/evCopula.h (rev 0) +++ pkg/src/include/evCopula.h 2013-10-10 07:28:40 UTC (rev 28) @@ -0,0 +1,31 @@ +#if !defined(EVCOPULA_H) +#define EVCOPULA_H + +// Some function for the Tawn copula + +//CDF +void ta(double* t, int* n, double* par, double* par2, double* par3, double* out); +void Tawn(double* t, int* n, double* par, double* par2, double* par3, double* out); +void TawnCDF(double* u, double* v, int* n, double* par, double* par2, double* par3, double* out); + +/////////////////////////////////////////////////// +//PDF +void ta2(double* t, int* n, double* par, double* par2, double* par3, double* out); +void d1ta(double* t, int* n, double* par, double* par2, double* par3, double* out); +void d2ta(double* t, int* n, double* par, double* par2, double* par3, double* out); + +void Tawn2(double* t, int* n, double* par, double* par2, double* par3, double* out); +void d1Tawn(double* t, int* n, double* par, double* par2, double* par3, double* out); +void d2Tawn(double* t, int* n, double* par, double* par2, double* par3, double* out); +void dA_du(double* u, double* v, int* n, double* par, double* par2, double* par3, double* out); +void dA_dv(double* u, double* v, int* n, double* par, double* par2, double* par3, double* out); +void dA_dudv(double* u, double* v, int* n, double* par, double* par2, double* par3, double* out); + +void TawnC(double* u, double* v, int* n, double* par, double* par2, double* par3, double* out); +void dC_du(double* u, double* v, int* n, double* par, double* par2, double* par3, double* out); +void TawnPDF(double* u, double* v, int* n, double* par, double* par2, double* par3, double* out); + +// h-function +void dC_dv(double* u, double* v, int* n, double* par, double* par2, double* par3, double* out); + +#endif Added: pkg/src/include/gof.h =================================================================== --- pkg/src/include/gof.h (rev 0) +++ pkg/src/include/gof.h 2013-10-10 07:28:40 UTC (rev 28) @@ -0,0 +1,31 @@ +#if !defined(GOF_H) +#define GOF_H + +void ADtest(double* cdf, int* n, double* out); // Daniel Berg +void CumDist(double* x, int* i_n, int* i_m, double* out); // Daniel Berg +void CvMtest(double* cdf, int* n, double* out); // Daniel Berg +void KStest(double* cdf, int* n, double* out); // Daniel Berg + +void White(int* T, int* d, int* family, int* maxmat, int* matrix, int* condirect, int* conindirect, double* par, double* par2, double* data, double* D, double* V); + +void Bj(int *T, int* d, int* family, int* maxmat, int* matrix, int* condirect, int* conindirect, double* par, double* par2, double* data, + double* out, double* vv, double* vv2, int* calcupdate, int* method, int *alpha); +void SimulateBj(double* S, int *T, int* d, int* B, int* method, int *alpha, double* p); +void gofPIT_AD(int *T, int* d, int* family, int* maxmat, int* matrix, int* condirect, int* conindirect, double* par, double* par2, double* data, + double* statistic, double* vv, double* vv2, int* calcupdate, int* method, int *alpha, int* B, int *statisticName); +void gofPIT_AD_pvalue(int* T, int* d, int* family, int* maxmat, int* matrix, int* condirect, int* conindirect, double* par, double* par2, double* data, + double* statistic, double* vv, double* vv2, int* calcupdate, int* method, int* alpha, int* B, double* pvalue, int *statisticName); + +void MySample(int *k, int *n, int *y); + +void gofECP(int* T, int* d, int* family, int* maxmat, int* matrix, int* conindirect, double* par, double* par2, double* data, double* statistic, int* statisticName); +void gofECP_pvalue(int* T, int* d, int* family, int* maxmat, int* matrix, int* conindirect, double* par, double* par2, double* data, double* statistic, int* statisticName, double* pvalue, int* B); +void gofECP2(int* T, int* d, int* family, int* maxmat, int* matrix, int* condirect, int* conindirect, double* par, double* par2, double* data, + double* vv, double* vv2, int* calcupdate, double* statistic, int* statisticName); +void gofECP2_pvalue(int* T, int* d, int* family, int* maxmat, int* matrix, int* condirect, int* conindirect, double* par, double* par2, double* data, + double* vv, double* vv2, int* calcupdate, double* statistic, double* pvalue,int* statisticName, int* B); + +void ChatZj(double* data, double* u, int* T, int* d, int* m, double* Chat); +void C_ind(double* data, int* n, int* d, double* C); + +#endif Added: pkg/src/include/pit.h =================================================================== --- pkg/src/include/pit.h (rev 0) +++ pkg/src/include/pit.h 2013-10-10 07:28:40 UTC (rev 28) @@ -0,0 +1,5 @@ +// Probability integral transform +void pit(int* n, int* d, int* family, int* type, double* par, double* nu, double* data, double* out); +void RvinePIT(int* T, int* d, int* family, int* maxmat, int* matrix, int* condirect, int* conindirect, double* par, double* par2, double* data, + double* out, double* vv, double* vv2, int* calcupdate); + \ No newline at end of file Added: pkg/src/pit.c =================================================================== --- pkg/src/pit.c (rev 0) +++ pkg/src/pit.c 2013-10-10 07:28:40 UTC (rev 28) @@ -0,0 +1,262 @@ +////////////////////////////////////////////////// +// PIT - Probability integral transform // +// // +// by Ulf Schepsmeier (2012) // +////////////////////////////////////////////////// + +#include "include/vine.h" +#include "include/memoryhandling.h" +#include "include/likelihood.h" +#include "include/pit.h" +#include "include/hfunc.h" + +#define UMAX 1-1e-10 + +#define UMIN 1e-10 + +#define XEPS 1e-4 + +////////////////////////////////////////////////////////////// +// Function to transform a pair-copula construction (vine) +// Input: +// n sample size +// d dimension (>= 2) +// type vine type (1=Canonical vine, 2=D-vine) +// family copula family (1=gaussian, 2=student, 3=clayton, 4=gumbel, 5=frank, 6=joe, 7=BB1) +// par parameter values (at least d*(d-1)/2 parameters) +//////////////////////////////////////////////////////////////// + +void pit(int* T, int* d, int* family, int* type, double* par, double* nu, double* data, double* out) +{ + int i, j, in=1, k, **fam, tt; + double **v, **theta, **z, **ny, **x; + + x = create_matrix(*d+1,*T); + v = create_matrix(*d+1,2*(*d)-1); + theta = create_matrix(*d+1,*d+1); + z = create_matrix(*d+1,*T); + ny = create_matrix(*d+1,*d+1); + fam = create_intmatrix(*d+1,*d+1); + + k = 0; + for(i=0;i<*d;i++) + { + for (tt=0;tt<=*T-1;tt++ ) + { + x[i][tt] = data[k]; + k++; + } + } + + //Initialize dependency parameters + k = 0; + for(i=0;i<*d-1;i++) + { + for(j=0;j<(*d-i-1);j++) + { + fam[i][j] = family[k]; + ny[i][j] = nu[k]; + theta[i][j] = par[k]; + k++; + } + } + + // Transform + if(*type==1) //Canonical vine + { + for(j=0;j<*T;j++) + { + z[0][j] = x[0][j]; + for(i=1;i<*d;i++) + { + z[i][j]=x[i][j]; + for(k=0;k<=(i-1);k++) + { + Hfunc1(&fam[k][i-k-1],&in, &z[i][j],&z[k][j],&theta[k][i-k-1],&ny[k][i-k-1],&z[i][j]); + } + } + } + } + else if(*type==2) //D-vine + { + for(j=0;j<*T;j++) + { + z[0][j] = x[0][j]; + Hfunc1(&fam[0][0],&in, &x[1][j],&x[0][j],&theta[0][0],&ny[0][0],&z[1][j]); + v[1][0] = x[1][j]; + Hfunc2(&fam[0][0],&in, &x[0][j],&x[1][j],&theta[0][0],&ny[0][0],&v[1][1]); + for(i=2;i<*d;i++) + { + Hfunc1(&fam[0][i-1],&in, &x[i][j],&x[i-1][j],&theta[0][i-1],&ny[0][i-1],&z[i][j]); + for(k=1;k<=(i-1);k++) + { + Hfunc1(&fam[k][i-k-1],&in, &z[i][j],&v[i-1][2*(k-1)+1],&theta[k][i-k-1],&ny[k][i-k-1],&z[i][j]); + } + if(i==(*d-1)) + break; + + v[i][0] = x[i][j]; + Hfunc2(&fam[0][i-1],&in, &v[i-1][0],&v[i][0],&theta[0][i-1],&ny[0][i-1],&v[i][1]); + Hfunc1(&fam[0][i-1],&in, &v[i][0],&v[i-1][0],&theta[0][i-1],&ny[0][i-1],&v[i][2]); + if(i>2) + { + for(k=0;k<=(i-3);k++) + { + Hfunc2(&fam[k+1][i-k-2],&in, &v[i-1][2*k+1],&v[i][2*k+2],&theta[k+1][i-k-2],&ny[k+1][i-k-2],&v[i][2*k+3]); + Hfunc1(&fam[k+1][i-k-2],&in, &v[i][2*k+2],&v[i-1][2*k+1],&theta[k+1][i-k-2],&ny[k+1][i-k-2],&v[i][2*k+4]); + } + } + Hfunc2(&fam[i-1][0],&in, &v[i-1][2*i-3],&v[i][2*i-2],&theta[i-1][0],&ny[i-1][0],&v[i][2*i-1]); + } + } + } + + //Write to output vector: + k = 0; + for(i=0;i<*d;i++) + { + for(j=0;j<*T;j++) + { + out[k] = z[i][j]; + k ++; + } + } + + //Free memory: + free_matrix(x,*d+1); free_matrix(v,*d+1); free_matrix(theta,*d+1); free_matrix(ny,*d+1); free_intmatrix(fam,*d+1); free_matrix(z,*d+1); +} + + + +void RvinePIT(int* T, int* d, int* family, int* maxmat, int* matrix, int* condirect, int* conindirect, double* par, double* par2, double* data, + double* out, double* vv, double* vv2, int* calcupdate) +{ + int i, j, k, t, m, **fam; + double **x, **theta, **nu, ***vdirect, ***vindirect, **z; + + //Allocate memory + x = create_matrix(*d,*T); + vdirect = create_3darray(*d,*d,*T); + vindirect = create_3darray(*d,*d,*T); + theta=create_matrix(*d,*d); + nu=create_matrix(*d,*d); + fam=create_intmatrix(*d,*d); + z = create_matrix(*d,*T); + + //Initialize + k=0; + for(i=0;i<(*d);i++) + { + for (t=0;t<*T;t++ ) + { + x[i][t] = data[k]; + k++; + } + } + + k=0; + for(i=0;i<(*d);i++) + { + for(j=0;j<(*d);j++) + { + theta[i][j]=par[(i+1)+(*d)*j-1] ; + nu[i][j]=par2[(i+1)+(*d)*j-1] ; + fam[i][j]=family[(i+1)+(*d)*j-1] ; + for(t=0;t<*T;t++ ) + { + vdirect[i][j][t]=vv[(i+1)+(*d)*j+(*d)*(*d)*t-1]; + vindirect[i][j][t]=vv2[(i+1)+(*d)*j+(*d)*(*d)*t-1]; + } + } + } + + for(i=0;i<(*d);i++) + { + for(t=0;t<*T;t++ ) [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/vinecopula -r 28 From noreply at r-forge.r-project.org Fri Oct 11 09:46:50 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 11 Oct 2013 09:46:50 +0200 (CEST) Subject: [Vinecopula-commits] r29 - in pkg: inst man Message-ID: <20131011074650.8C97C185C25@r-forge.r-project.org> Author: ulf Date: 2013-10-11 09:46:49 +0200 (Fri, 11 Oct 2013) New Revision: 29 Modified: pkg/inst/ChangeLog pkg/man/BiCopCDF.Rd pkg/man/VineCopula-package.Rd Log: Hier ein Vorschlag von Eike und mir f?\195?\188r die Benennung der beiden Tawn copula Typen und deren Beschreibung (VineCopula-package.Rd). Modified: pkg/inst/ChangeLog =================================================================== --- pkg/inst/ChangeLog 2013-10-10 07:28:40 UTC (rev 28) +++ pkg/inst/ChangeLog 2013-10-11 07:46:49 UTC (rev 29) @@ -12,9 +12,12 @@ * BetaMatrix Matrix of empirical Blomqvist's beta values * BiCopPar2Beta Blomqvist's beta value of a bivariate copula * RVinePar2Beta Blomqvist's beta values of an R-vine copula model - * New copula familes for most of the BiCop as well as for the RVine-functions: The Tawn copula has be definition three parameters. We fixed the second or the third parameter to one to stay consitent with the notation used so far. -The families 104,114,124,134 denote the Tawn copula and their rotated versions in the case that the third parameter is fixed to 1. -The families 204,214,224,234 denote the Tawn copula and their rotated versions in the case that the second parameter is fixed to 1. + * New copula familes for most of the BiCop as well as for the RVine-functions: As an asymmetric extension of the Gumbel copula, the Tawn copula with three parameters is now also included in the package. +Both the Gumbel and the Tawn copula are extreme-value copulas, which can be defined in terms of their corresponding Pickands dependence functions. +For simplicity, we implemented two versions of the Tawn copula with two parameters each. +Each type has one of the asymmetry parameters fixed to 1, so that the corresponding Pickands dependence is either left- or right-skewed. In the manual we will call these two new copulas "Tawn type 1" and "Tawn type 2". +The families 104,114,124,134 denote the Tawn copula and their rotated versions in the case of left skewness (Tawn type 1). +The families 204,214,224,234 denote the Tawn copula and their rotated versions in the case of right skewness (Tawn type 2). - Bug fix: * RVineStructureSelect: Corrected code for the igraph package Modified: pkg/man/BiCopCDF.Rd =================================================================== --- pkg/man/BiCopCDF.Rd 2013-10-10 07:28:40 UTC (rev 28) +++ pkg/man/BiCopCDF.Rd 2013-10-11 07:46:49 UTC (rev 29) @@ -15,11 +15,11 @@ \item{u1,u2}{Numeric vectors of equal length with values in [0,1].} \item{family}{An integer defining the bivariate copula family: \cr \code{0} = independence copula \cr - \code{1} = Gaussian copula \cr - \code{3} = Clayton copula \cr - \code{4} = Gumbel copula \cr - \code{5} = Frank copula \cr - \code{6} = Joe copula \cr + \code{1} = Gaussian copula \cr + \code{3} = Clayton copula \cr + \code{4} = Gumbel copula \cr + \code{5} = Frank copula \cr + \code{6} = Joe copula \cr \code{7} = BB1 copula \cr \code{8} = BB6 copula \cr \code{9} = BB7 copula \cr @@ -45,17 +45,17 @@ \code{38} = rotated BB6 copula (270 degrees) \cr \code{39} = rotated BB7 copula (270 degrees) \cr \code{40} = rotated BB8 copula (270 degrees) \cr - \code{104} = Tawn copula with fixed third parameter \cr - \code{114} = rotated Tawn copula (180 degrees) with fixed third parameter \cr - \code{124} = rotated Tawn copula (90 degrees) with fixed third parameter \cr - \code{134} = rotated Tawn copula (270 degrees) with fixed third parameter \cr - \code{204} = Tawn copula with fixed second parameter \cr - \code{214} = rotated Tawn copula (180 degrees) with fixed second parameter \cr - \code{224} = rotated Tawn copula (90 degrees) with fixed second parameter \cr - \code{234} = rotated Tawn copula (270 degrees) with fixed second parameter \cr + \code{104} = Tawn type 1 copula \cr + \code{114} = rotated Tawn type 1 copula (180 degrees) \cr + \code{124} = rotated Tawn type 1 copula (90 degrees) \cr + \code{134} = rotated Tawn type 1 copula (270 degrees) \cr + \code{204} = Tawn type 2 copula \cr + \code{214} = rotated Tawn type 2 copula (180 degrees) \cr + \code{224} = rotated Tawn type 2 copula (90 degrees) \cr + \code{234} = rotated Tawn type 2 copula (270 degrees) \cr } \item{par}{Copula parameter.} - \item{par2}{Second parameter for bivariate copulas with two parameters (t, BB1, BB6, BB7, BB8; default: \code{par2 = 0}). \code{par2} should be an positive integer for the Students's t copula \code{family=2}.} + \item{par2}{Second parameter for bivariate copulas with two parameters (t, BB1, BB6, BB7, BB8, Tawn type 1 and type 2; default: \code{par2 = 0}). \code{par2} should be an positive integer for the Students's t copula \code{family=2}.} } \value{ Modified: pkg/man/VineCopula-package.Rd =================================================================== --- pkg/man/VineCopula-package.Rd 2013-10-10 07:28:40 UTC (rev 28) +++ pkg/man/VineCopula-package.Rd 2013-10-11 07:46:49 UTC (rev 29) @@ -28,6 +28,11 @@ in particular, if BB6, BB7 and BB8 copulas are close to the Joe copula which is a boundary case of these three copula families. In general, the user should be careful with extreme parameter choices. +As an asymmetric extension of the Gumbel copula, the Tawn copula with three parameters is now also included in the package. +Both the Gumbel and the Tawn copula are extreme-value copulas, which can be defined in terms of their corresponding Pickands dependence functions. +For simplicity, we implemented two versions of the Tawn copula with two parameters each. +Each type has one of the asymmetry parameters fixed to 1, so that the corresponding Pickands dependence is either left- or right-skewed. In the manual we will call these two new copulas "Tawn type 1" and "Tawn type 2". + The following table shows the parameter ranges of bivariate copula families with parameters \code{par} and \code{par2}: \tabular{lll}{ Copula family \tab \code{par} \tab \code{par2} \cr @@ -48,6 +53,8 @@ Rotated Joe-Gumbel (90 and 270 degrees) \tab \eqn{(-\infty,-1]} \tab \eqn{(-\infty,-1]} \cr Rotated Joe-Clayton (90 and 270 degrees) \tab \eqn{(-\infty,-1]} \tab \eqn{(-\infty,0)} \cr Rotated Joe-Frank (90 and 270 degrees) \tab \eqn{(-\infty,-1]} \tab \eqn{[-1,0)} \cr +(Survival) Tawn type 1 and type 2 \tab \eqn{[1,\infty)} \tab \eqn{[0,1]} \cr +Rotated Tawn type 1 and type 2 (90 and 270 degrees) \tab \eqn{(-\infty,-1]} \tab \eqn{[0,1]} \cr } } From noreply at r-forge.r-project.org Fri Oct 11 15:35:50 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 11 Oct 2013 15:35:50 +0200 (CEST) Subject: [Vinecopula-commits] r30 - / pkg/R pkg/man Message-ID: <20131011133550.2C1A3184ECD@r-forge.r-project.org> Author: ulf Date: 2013-10-11 15:35:49 +0200 (Fri, 11 Oct 2013) New Revision: 30 Added: pkg.pdf Modified: pkg/R/BiCopName.r pkg/man/BiCopDeriv.Rd pkg/man/BiCopDeriv2.Rd pkg/man/BiCopEst.Rd pkg/man/BiCopHfunc.Rd pkg/man/BiCopHfuncDeriv.Rd pkg/man/BiCopHfuncDeriv2.Rd pkg/man/BiCopMetaContour.Rd pkg/man/BiCopName.Rd pkg/man/BiCopPDF.Rd pkg/man/BiCopPar2Beta.Rd pkg/man/BiCopPar2TailDep.Rd pkg/man/BiCopPar2Tau.Rd pkg/man/BiCopSelect.Rd pkg/man/BiCopSim.Rd pkg/man/BiCopVuongClarke.Rd pkg/man/C2RVine.Rd pkg/man/D2RVine.Rd pkg/man/RVineCopSelect.Rd pkg/man/RVineGofTest.Rd pkg/man/RVineGrad.Rd pkg/man/RVineHessian.Rd pkg/man/RVineMLE.Rd pkg/man/RVineMatrix.Rd pkg/man/RVinePIT.Rd pkg/man/VineCopula-package.Rd Log: Alle helpfiles erneuert bzgl Tawn. @Eike: Ich habe auch noch eine paar Referenzen auf den neusten Stand gebracht, bin aber nicht alle durchgegangen. Ev. siehst du da noch was. Ferner w?\195?\188rde ich dich bitten dir die Formeln f?\195?\188r tau und die tail dependence anzuschauen. Danke. Modified: pkg/R/BiCopName.r =================================================================== --- pkg/R/BiCopName.r 2013-10-11 07:46:49 UTC (rev 29) +++ pkg/R/BiCopName.r 2013-10-11 13:35:49 UTC (rev 30) @@ -92,14 +92,14 @@ else if(family==51) fam="Rotated 1-parametric asymmetric 180 degree" else if(family==61) fam="Rotated 1-parametric asymmetric 90 degree" else if(family==71) fam="Rotated 1-parametric asymmetric 270 degree" - else if(family==104) fam="Tawn" - else if(family==114) fam="Rotated Tawn 180 degrees" - else if(family==124) fam="Rotated Tawn 90 degrees" - else if(family==134) fam="Rotated Tawn 270 degrees" - else if(family==204) fam="Tawn2" - else if(family==214) fam="Rotated Tawn2 180 degrees" - else if(family==224) fam="Rotated Tawn2 90 degrees" - else if(family==234) fam="Rotated Tawn2 270 degrees" + else if(family==104) fam="Tawn type 1" + else if(family==114) fam="Rotated Tawn type 1 180 degrees" + else if(family==124) fam="Rotated Tawn type 1 90 degrees" + else if(family==134) fam="Rotated Tawn type 1 270 degrees" + else if(family==204) fam="Tawn type 2" + else if(family==214) fam="Rotated Tawn type 2 180 degrees" + else if(family==224) fam="Rotated Tawn type 2 90 degrees" + else if(family==234) fam="Rotated Tawn type 2 270 degrees" else stop("Family not implemented.") } } @@ -141,14 +141,14 @@ else if(family=="1-par AS180" || family=="Rotated 1-parametric asymmetric 180 degree") fam=51 else if(family=="1-par AS90" || family=="Rotated 1-parametric asymmetric 90 degree") fam=61 else if(family=="1-par AS270" || family=="Rotated 1-parametric asymmetric 270 degree") fam=71 - else if(family=="Tawn") fam=104 - else if(family=="Tawn180" || family=="Rotated Tawn 180 degrees") fam=114 - else if(family=="Tawn90" || family=="Rotated Tawn 90 degrees") fam=124 - else if(family=="Tawn270" || family=="Rotated Tawn 270 degrees") fam=134 - else if(family=="Tawn2") fam=204 - else if(family=="Tawn2_180" || family=="Rotated Tawn2 180 degrees") fam=214 - else if(family=="Tawn2_90" || family=="Rotated Tawn2 90 degrees") fam=224 - else if(family=="Tawn2_270" || family=="Rotated Tawn2 270 degrees") fam=234 + else if(family=="Tawn" || family=="Tawn type 1") fam=104 + else if(family=="Tawn180" || family=="Rotated Tawn type 1 180 degrees") fam=114 + else if(family=="Tawn90" || family=="Rotated Tawn type 1 90 degrees") fam=124 + else if(family=="Tawn270" || family=="Rotated Tawn type 1 270 degrees") fam=134 + else if(family=="Tawn2" || family=="Tawn type 2") fam=204 + else if(family=="Tawn2_180" || family=="Rotated Tawn type 2 180 degrees") fam=214 + else if(family=="Tawn2_90" || family=="Rotated Tawn type 2 90 degrees") fam=224 + else if(family=="Tawn2_270" || family=="Rotated Tawn type 2 270 degrees") fam=234 else stop("Family not implemented.") } Modified: pkg/man/BiCopDeriv.Rd =================================================================== --- pkg/man/BiCopDeriv.Rd 2013-10-11 07:46:49 UTC (rev 29) +++ pkg/man/BiCopDeriv.Rd 2013-10-11 13:35:49 UTC (rev 30) @@ -52,8 +52,8 @@ \references{ Schepsmeier, U. and J. Stoeber (2012). Derivatives and Fisher information of bivariate copulas. -Submitted for publication. -\url{http://mediatum.ub.tum.de/node?id=1106541}. +Statistical Papers. +\url{http://link.springer.com/article/10.1007/s00362-013-0498-x}. } \seealso{\code{\link{RVineGrad}}, \code{\link{RVineHessian}}, \code{\link{BiCopDeriv2}}, \code{\link{BiCopHfuncDeriv}}} Modified: pkg/man/BiCopDeriv2.Rd =================================================================== --- pkg/man/BiCopDeriv2.Rd 2013-10-11 07:46:49 UTC (rev 29) +++ pkg/man/BiCopDeriv2.Rd 2013-10-11 13:35:49 UTC (rev 30) @@ -53,8 +53,8 @@ \references{ Schepsmeier, U. and J. Stoeber (2012). Derivatives and Fisher information of bivariate copulas. -Submitted for publication. -\url{http://mediatum.ub.tum.de/node?id=1106541}. +Statistical Papers. +\url{http://link.springer.com/article/10.1007/s00362-013-0498-x}. } \author{Ulf Schepsmeier, Jakob Stoeber} Modified: pkg/man/BiCopEst.Rd =================================================================== --- pkg/man/BiCopEst.Rd 2013-10-11 07:46:49 UTC (rev 29) +++ pkg/man/BiCopEst.Rd 2013-10-11 13:35:49 UTC (rev 30) @@ -47,7 +47,15 @@ \code{37} = rotated BB1 copula (270 degrees) \cr \code{38} = rotated BB6 copula (270 degrees) \cr \code{39} = rotated BB7 copula (270 degrees) \cr - \code{40} = rotated BB8 copula (270 degrees) + \code{40} = rotated BB8 copula (270 degrees) \cr + \code{104} = Tawn type 1 copula \cr + \code{114} = rotated Tawn type 1 copula (180 degrees) \cr + \code{124} = rotated Tawn type 1 copula (90 degrees) \cr + \code{134} = rotated Tawn type 1 copula (270 degrees) \cr + \code{204} = Tawn type 2 copula \cr + \code{214} = rotated Tawn type 2 copula (180 degrees) \cr + \code{224} = rotated Tawn type 2 copula (90 degrees) \cr + \code{234} = rotated Tawn type 2 copula (270 degrees) \cr } \item{method}{Character indicating the estimation method: either maximum likelihood estimation (\code{method = "mle"}; default) or inversion of Kendall's tau (\code{method = "itau"}).\cr Modified: pkg/man/BiCopHfunc.Rd =================================================================== --- pkg/man/BiCopHfunc.Rd 2013-10-11 07:46:49 UTC (rev 29) +++ pkg/man/BiCopHfunc.Rd 2013-10-11 13:35:49 UTC (rev 30) @@ -45,10 +45,18 @@ \code{37} = rotated BB1 copula (270 degrees) \cr \code{38} = rotated BB6 copula (270 degrees) \cr \code{39} = rotated BB7 copula (270 degrees) \cr - \code{40} = rotated BB8 copula (270 degrees) + \code{40} = rotated BB8 copula (270 degrees) \cr + \code{104} = Tawn type 1 copula \cr + \code{114} = rotated Tawn type 1 copula (180 degrees) \cr + \code{124} = rotated Tawn type 1 copula (90 degrees) \cr + \code{134} = rotated Tawn type 1 copula (270 degrees) \cr + \code{204} = Tawn type 2 copula \cr + \code{214} = rotated Tawn type 2 copula (180 degrees) \cr + \code{224} = rotated Tawn type 2 copula (90 degrees) \cr + \code{234} = rotated Tawn type 2 copula (270 degrees) \cr } \item{par}{Copula parameter.} - \item{par2}{Second parameter for bivariate copulas with two parameters (t, BB1, BB6, BB7, BB8; default: \code{par2 = 0}).} + \item{par2}{Second parameter for bivariate copulas with two parameters (t, BB1, BB6, BB7, BB8, Tawn type 1 and type 2; default: \code{par2 = 0}).} } \details{ Modified: pkg/man/BiCopHfuncDeriv.Rd =================================================================== --- pkg/man/BiCopHfuncDeriv.Rd 2013-10-11 07:46:49 UTC (rev 29) +++ pkg/man/BiCopHfuncDeriv.Rd 2013-10-11 13:35:49 UTC (rev 30) @@ -47,8 +47,8 @@ \references{ Schepsmeier, U. and J. Stoeber (2012). Derivatives and Fisher information of bivariate copulas. -Submitted for publication. -\url{http://mediatum.ub.tum.de/node?id=1106541}. +Statistical Papers. +\url{http://link.springer.com/article/10.1007/s00362-013-0498-x}. } \author{Ulf Schepsmeier} Modified: pkg/man/BiCopHfuncDeriv2.Rd =================================================================== --- pkg/man/BiCopHfuncDeriv2.Rd 2013-10-11 07:46:49 UTC (rev 29) +++ pkg/man/BiCopHfuncDeriv2.Rd 2013-10-11 13:35:49 UTC (rev 30) @@ -50,8 +50,8 @@ \references{ Schepsmeier, U. and J. Stoeber (2012). Derivatives and Fisher information of bivariate copulas. -Submitted for publication. -\url{http://mediatum.ub.tum.de/node?id=1106541}. +Statistical Papers. +\url{http://link.springer.com/article/10.1007/s00362-013-0498-x}. } \author{Ulf Schepsmeier, Jakob Stoeber} Modified: pkg/man/BiCopMetaContour.Rd =================================================================== --- pkg/man/BiCopMetaContour.Rd 2013-10-11 07:46:49 UTC (rev 29) +++ pkg/man/BiCopMetaContour.Rd 2013-10-11 13:35:49 UTC (rev 30) @@ -58,10 +58,18 @@ \code{37} = rotated BB1 copula (270 degrees) \cr \code{38} = rotated BB6 copula (270 degrees) \cr \code{39} = rotated BB7 copula (270 degrees) \cr - \code{40} = rotated BB8 copula (270 degrees) + \code{40} = rotated BB8 copula (270 degrees) \cr + \code{104} = Tawn type 1 copula \cr + \code{114} = rotated Tawn type 1 copula (180 degrees) \cr + \code{124} = rotated Tawn type 1 copula (90 degrees) \cr + \code{134} = rotated Tawn type 1 copula (270 degrees) \cr + \code{204} = Tawn type 2 copula \cr + \code{214} = rotated Tawn type 2 copula (180 degrees) \cr + \code{224} = rotated Tawn type 2 copula (90 degrees) \cr + \code{234} = rotated Tawn type 2 copula (270 degrees) \cr } \item{par}{Copula parameter; if empirical contour plot, \code{par = NULL} or \code{0} (default).} - \item{par2}{Second copula parameter for t-, BB1, BB6, BB7 and BB8 copulas (default: \code{par2 = 0}).} + \item{par2}{Second copula parameter for t-, BB1, BB6, BB7, BB8, Tawn type 1 and type 2 copulas (default: \code{par2 = 0}).} \item{PLOT}{Logical; whether the results are plotted. If \code{PLOT = FALSE}, the values \code{x}, \code{y} and \code{z} are returned (see below; default: \code{PLOT = TRUE}).} \item{margins}{Character; margins for the bivariate copula contour plot. Possible margins are:\cr Modified: pkg/man/BiCopName.Rd =================================================================== --- pkg/man/BiCopName.Rd 2013-10-11 07:46:49 UTC (rev 29) +++ pkg/man/BiCopName.Rd 2013-10-11 13:35:49 UTC (rev 30) @@ -47,6 +47,14 @@ \code{38} \tab \code{"BB6_270"} \tab \code{"Rotated Joe-Gumbel 270 degrees"} \cr \code{39} \tab \code{"BB7_270"} \tab \code{"Rotated Joe-Clayton 270 degrees"} \cr \code{40} \tab \code{"BB8_270"} \tab \code{"Rotated Frank-Joe 270 degrees"} \cr +\code{104} \tab \code{"Tawn"} \tab \code{"Tawn type 1"} \cr +\code{114} \tab \code{"Tawn180"} \tab \code{"Rotated Tawn type 1 180 degrees"} \cr +\code{124} \tab \code{"Tawn90"} \tab \code{"Rotated Tawn type 1 90 degrees"} \cr +\code{134} \tab \code{"Tawn270"} \tab \code{"Rotated Tawn type 1 270 degrees"} \cr +\code{204} \tab \code{"Tawn2"} \tab \code{"Tawn type 2"} \cr +\code{214} \tab \code{"Tawn2_180"} \tab \code{"Rotated Tawn type 2 180 degrees"} \cr +\code{224} \tab \code{"Tawn2_90"} \tab \code{"Rotated Tawn type 2 90 degrees"} \cr +\code{234} \tab \code{"Tawn2_270"} \tab \code{"Rotated Tawn type 2 270 degrees"} \cr } } \item{short}{Logical; if the number of a bivariate copula family is used and \code{short = TRUE} (default), Modified: pkg/man/BiCopPDF.Rd =================================================================== --- pkg/man/BiCopPDF.Rd 2013-10-11 07:46:49 UTC (rev 29) +++ pkg/man/BiCopPDF.Rd 2013-10-11 13:35:49 UTC (rev 30) @@ -45,10 +45,18 @@ \code{37} = rotated BB1 copula (270 degrees) \cr \code{38} = rotated BB6 copula (270 degrees) \cr \code{39} = rotated BB7 copula (270 degrees) \cr - \code{40} = rotated BB8 copula (270 degrees) + \code{40} = rotated BB8 copula (270 degrees) \cr + \code{104} = Tawn type 1 copula \cr + \code{114} = rotated Tawn type 1 copula (180 degrees) \cr + \code{124} = rotated Tawn type 1 copula (90 degrees) \cr + \code{134} = rotated Tawn type 1 copula (270 degrees) \cr + \code{204} = Tawn type 2 copula \cr + \code{214} = rotated Tawn type 2 copula (180 degrees) \cr + \code{224} = rotated Tawn type 2 copula (90 degrees) \cr + \code{234} = rotated Tawn type 2 copula (270 degrees) \cr } \item{par}{Copula parameter.} - \item{par2}{Second parameter for bivariate copulas with two parameters (t, BB1, BB6, BB7, BB8; default: \code{par2 = 0}).} + \item{par2}{Second parameter for the two parameter t-, BB1, BB6, BB7, BB8, Tawn type 1 and type 2 copulas (default: \code{par2 = 0}).} } \value{ Modified: pkg/man/BiCopPar2Beta.Rd =================================================================== --- pkg/man/BiCopPar2Beta.Rd 2013-10-11 07:46:49 UTC (rev 29) +++ pkg/man/BiCopPar2Beta.Rd 2013-10-11 13:35:49 UTC (rev 30) @@ -44,10 +44,18 @@ \code{37} = rotated BB1 copula (270 degrees) \cr \code{38} = rotated BB6 copula (270 degrees) \cr \code{39} = rotated BB7 copula (270 degrees) \cr - \code{40} = rotated BB8 copula (270 degrees) + \code{40} = rotated BB8 copula (270 degrees) \cr + \code{104} = Tawn type 1 copula \cr + \code{114} = rotated Tawn type 1 copula (180 degrees) \cr + \code{124} = rotated Tawn type 1 copula (90 degrees) \cr + \code{134} = rotated Tawn type 1 copula (270 degrees) \cr + \code{204} = Tawn type 2 copula \cr + \code{214} = rotated Tawn type 2 copula (180 degrees) \cr + \code{224} = rotated Tawn type 2 copula (90 degrees) \cr + \code{234} = rotated Tawn type 2 copula (270 degrees) \cr } \item{par}{Copula parameter.} - \item{par2}{Second parameter for the two parameter BB1, BB6, BB7 and BB8 copulas (default: \code{par2 = 0}).} + \item{par2}{Second parameter for the two parameter BB1, BB6, BB7, BB8, Tawn type 1 and type 2 copulas (default: \code{par2 = 0}).} } Modified: pkg/man/BiCopPar2TailDep.Rd =================================================================== --- pkg/man/BiCopPar2TailDep.Rd 2013-10-11 07:46:49 UTC (rev 29) +++ pkg/man/BiCopPar2TailDep.Rd 2013-10-11 13:35:49 UTC (rev 30) @@ -44,10 +44,18 @@ \code{37} = rotated BB1 copula (270 degrees) \cr \code{38} = rotated BB6 copula (270 degrees) \cr \code{39} = rotated BB7 copula (270 degrees) \cr - \code{40} = rotated BB8 copula (270 degrees) + \code{40} = rotated BB8 copula (270 degrees) \cr + \code{104} = Tawn type 1 copula \cr + \code{114} = rotated Tawn type 1 copula (180 degrees) \cr + \code{124} = rotated Tawn type 1 copula (90 degrees) \cr + \code{134} = rotated Tawn type 1 copula (270 degrees) \cr + \code{204} = Tawn type 2 copula \cr + \code{214} = rotated Tawn type 2 copula (180 degrees) \cr + \code{224} = rotated Tawn type 2 copula (90 degrees) \cr + \code{234} = rotated Tawn type 2 copula (270 degrees) \cr } \item{par}{Copula parameter.} - \item{par2}{Second parameter for the two parameter t-, BB1, BB6, BB7 and BB8 copulas (default: \code{par2 = 0}).} + \item{par2}{Second parameter for the two parameter t-, BB1, BB6, BB7, BB8, Tawn type 1 and type 2 copulas (default: \code{par2 = 0}).} } \value{ @@ -94,6 +102,10 @@ \code{28, 38} \tab - \tab - \cr \code{29, 39} \tab - \tab - \cr \code{30, 40} \tab - \tab - \cr +\code{104, 204} \tab - \tab \eqn{\Psi_1+\Psi_2-2((0.5\Psi_1)^{\theta}+(0.5\Psi_2)^{\theta})^{1/\theta}} \cr +\code{114, 214} \tab \eqn{\Psi_1+\Psi_2-2((0.5\Psi_1)^{\theta}+(0.5\Psi_2)^{\theta})^{1/\theta}} \tab - \cr +\code{124, 224} \tab - \tab - \cr +\code{134, 234} \tab - \tab - \cr } } Modified: pkg/man/BiCopPar2Tau.Rd =================================================================== --- pkg/man/BiCopPar2Tau.Rd 2013-10-11 07:46:49 UTC (rev 29) +++ pkg/man/BiCopPar2Tau.Rd 2013-10-11 13:35:49 UTC (rev 30) @@ -44,10 +44,18 @@ \code{37} = rotated BB1 copula (270 degrees) \cr \code{38} = rotated BB6 copula (270 degrees) \cr \code{39} = rotated BB7 copula (270 degrees) \cr - \code{40} = rotated BB8 copula (270 degrees) + \code{40} = rotated BB8 copula (270 degrees) \cr + \code{104} = Tawn type 1 copula \cr + \code{114} = rotated Tawn type 1 copula (180 degrees) \cr + \code{124} = rotated Tawn type 1 copula (90 degrees) \cr + \code{134} = rotated Tawn type 1 copula (270 degrees) \cr + \code{204} = Tawn type 2 copula \cr + \code{214} = rotated Tawn type 2 copula (180 degrees) \cr + \code{224} = rotated Tawn type 2 copula (90 degrees) \cr + \code{234} = rotated Tawn type 2 copula (270 degrees) \cr } \item{par}{Copula parameter.} - \item{par2}{Second parameter for the two parameter BB1, BB6, BB7 and BB8 copulas (default: \code{par2 = 0}). + \item{par2}{Second parameter for the two parameter t-, BB1, BB6, BB7, BB8, Tawn type 1 and type 2 copulas (default: \code{par2 = 0}). Note that the degrees of freedom parameter of the t-copula does not need to be set, because the theoretical Kendall's tau value of the t-copula is independent of this choice.} } @@ -77,6 +85,11 @@ \code{29, 39} \tab \eqn{-1-4\int_0^1 ( (1-(1-t)^{-\theta})^{\delta} - )/( -\theta\delta(1-t)^{-\theta-1}(1-(1-t)^{-\theta})^{\delta-1} ) dt} \cr \code{30, 40} \tab \eqn{-1-4\int_0^1 -\log \left( ((1+t\delta)^{-\theta}-1)/((1+\delta)^{-\theta}-1) \right)} \cr \tab \eqn{* (1+t\delta-(1+t\delta)^{\theta}-(1+t\delta)^{\theta}t\delta)/(\theta\delta) dt} \cr + \code{104,114,204,214} \tab \eqn{\int_0^1 \frac{t(1-t)A^{\prime\prime}(t)}{A(t)^2}dt} \cr + \tab with \eqn{A(t) = (1-\Psi_2)(1-t)+(1-\Psi_1)t+[(\Psi_1(1-t))^{\theta}+(\Psi_2t)^{\theta}]^{1/\theta}} \cr + \code{124,134,224,234} \tab \eqn{-\int_0^1 \frac{t(1-t)A^{\prime\prime}(t)}{A(t)^2}dt} \cr + \tab with \eqn{A(t) = (1-\Psi_2)(1-t)+(1-\Psi_1)t+[(\Psi_1(1-t))^{-\theta}+(\Psi_2t)^{-\theta}]^{-1/\theta}} \cr + } } Modified: pkg/man/BiCopSelect.Rd =================================================================== --- pkg/man/BiCopSelect.Rd 2013-10-11 07:46:49 UTC (rev 29) +++ pkg/man/BiCopSelect.Rd 2013-10-11 13:35:49 UTC (rev 30) @@ -51,7 +51,15 @@ \code{37} = rotated BB1 copula (270 degrees) \cr \code{38} = rotated BB6 copula (270 degrees) \cr \code{39} = rotated BB7 copula (270 degrees) \cr - \code{40} = rotated BB8 copula (270 degrees) + \code{40} = rotated BB8 copula (270 degrees) \cr + \code{104} = Tawn type 1 copula \cr + \code{114} = rotated Tawn type 1 copula (180 degrees) \cr + \code{124} = rotated Tawn type 1 copula (90 degrees) \cr + \code{134} = rotated Tawn type 1 copula (270 degrees) \cr + \code{204} = Tawn type 2 copula \cr + \code{214} = rotated Tawn type 2 copula (180 degrees) \cr + \code{224} = rotated Tawn type 2 copula (90 degrees) \cr + \code{234} = rotated Tawn type 2 copula (270 degrees) \cr } \item{selectioncrit}{Character indicating the criterion for bivariate copula selection. Possible choices: \code{selectioncrit = "AIC"} (default) or \code{"BIC"}.} \item{indeptest}{Logical; whether a hypothesis test for the independence of \code{u1} and \code{u2} is performed before bivariate copula selection Modified: pkg/man/BiCopSim.Rd =================================================================== --- pkg/man/BiCopSim.Rd 2013-10-11 07:46:49 UTC (rev 29) +++ pkg/man/BiCopSim.Rd 2013-10-11 13:35:49 UTC (rev 30) @@ -45,10 +45,18 @@ \code{37} = rotated BB1 copula (270 degrees) \cr \code{38} = rotated BB6 copula (270 degrees) \cr \code{39} = rotated BB7 copula (270 degrees) \cr - \code{40} = rotated BB8 copula (270 degrees) + \code{40} = rotated BB8 copula (270 degrees) \cr + \code{104} = Tawn type 1 copula \cr + \code{114} = rotated Tawn type 1 copula (180 degrees) \cr + \code{124} = rotated Tawn type 1 copula (90 degrees) \cr + \code{134} = rotated Tawn type 1 copula (270 degrees) \cr + \code{204} = Tawn type 2 copula \cr + \code{214} = rotated Tawn type 2 copula (180 degrees) \cr + \code{224} = rotated Tawn type 2 copula (90 degrees) \cr + \code{234} = rotated Tawn type 2 copula (270 degrees) \cr } \item{par}{Copula parameter.} - \item{par2}{Second parameter for bivariate copulas with two parameters (t, BB1,BB6, BB7, BB8; default: \code{par2 = 0}).} + \item{par2}{Second parameter for the two parameter BB1, BB6, BB7, BB8, Tawn type 1 and type 2 copulas (default: \code{par2 = 0}).} } \value{ Modified: pkg/man/BiCopVuongClarke.Rd =================================================================== --- pkg/man/BiCopVuongClarke.Rd 2013-10-11 07:46:49 UTC (rev 29) +++ pkg/man/BiCopVuongClarke.Rd 2013-10-11 13:35:49 UTC (rev 30) @@ -50,7 +50,15 @@ \code{37} = rotated BB1 copula (270 degrees) \cr \code{38} = rotated BB6 copula (270 degrees) \cr \code{39} = rotated BB7 copula (270 degrees) \cr - \code{40} = rotated BB8 copula (270 degrees) + \code{40} = rotated BB8 copula (270 degrees) \cr + \code{104} = Tawn type 1 copula \cr + \code{114} = rotated Tawn type 1 copula (180 degrees) \cr + \code{124} = rotated Tawn type 1 copula (90 degrees) \cr + \code{134} = rotated Tawn type 1 copula (270 degrees) \cr + \code{204} = Tawn type 2 copula \cr + \code{214} = rotated Tawn type 2 copula (180 degrees) \cr + \code{224} = rotated Tawn type 2 copula (90 degrees) \cr + \code{234} = rotated Tawn type 2 copula (270 degrees) \cr } \item{correction}{Correction for the number of parameters. Possible choices: \code{correction = FALSE} (no correction; default), \code{"Akaike"} and \code{"Schwarz"}.} Modified: pkg/man/C2RVine.Rd =================================================================== --- pkg/man/C2RVine.Rd 2013-10-11 07:46:49 UTC (rev 29) +++ pkg/man/C2RVine.Rd 2013-10-11 13:35:49 UTC (rev 30) @@ -45,10 +45,18 @@ \code{37} = rotated BB1 copula (270 degrees) \cr \code{38} = rotated BB6 copula (270 degrees) \cr \code{39} = rotated BB7 copula (270 degrees) \cr - \code{40} = rotated BB8 copula (270 degrees) + \code{40} = rotated BB8 copula (270 degrees) \cr + \code{104} = Tawn type 1 copula \cr + \code{114} = rotated Tawn type 1 copula (180 degrees) \cr + \code{124} = rotated Tawn type 1 copula (90 degrees) \cr + \code{134} = rotated Tawn type 1 copula (270 degrees) \cr + \code{204} = Tawn type 2 copula \cr + \code{214} = rotated Tawn type 2 copula (180 degrees) \cr + \code{224} = rotated Tawn type 2 copula (90 degrees) \cr + \code{234} = rotated Tawn type 2 copula (270 degrees) \cr } \item{par}{A d*(d-1)/2 vector of pair-copula parameters.} - \item{par2}{A d*(d-1)/2 vector of second pair-copula parameters (optional; default:\cr \code{par2 = rep(0,length(family))}), necessary for the t-, BB1, BB6, BB7 and BB8 copulas.} + \item{par2}{A d*(d-1)/2 vector of second pair-copula parameters (optional; default:\cr \code{par2 = rep(0,length(family))}), necessary for the t-, BB1, BB6, BB7, BB8, Tawn type 1 and type 2 copulas.} } \value{ Modified: pkg/man/D2RVine.Rd =================================================================== --- pkg/man/D2RVine.Rd 2013-10-11 07:46:49 UTC (rev 29) +++ pkg/man/D2RVine.Rd 2013-10-11 13:35:49 UTC (rev 30) @@ -45,11 +45,19 @@ \code{37} = rotated BB1 copula (270 degrees) \cr \code{38} = rotated BB6 copula (270 degrees) \cr \code{39} = rotated BB7 copula (270 degrees) \cr - \code{40} = rotated BB8 copula (270 degrees) + \code{40} = rotated BB8 copula (270 degrees) \cr + \code{104} = Tawn type 1 copula \cr + \code{114} = rotated Tawn type 1 copula (180 degrees) \cr + \code{124} = rotated Tawn type 1 copula (90 degrees) \cr + \code{134} = rotated Tawn type 1 copula (270 degrees) \cr + \code{204} = Tawn type 2 copula \cr + \code{214} = rotated Tawn type 2 copula (180 degrees) \cr + \code{224} = rotated Tawn type 2 copula (90 degrees) \cr + \code{234} = rotated Tawn type 2 copula (270 degrees) \cr } \item{par}{A d*(d-1)/2 vector of pair-copula parameters.} \item{par2}{A d*(d-1)/2 vector of second pair-copula parameters (optional; default:\cr \code{par2 = rep(0,length(family))}), - necessary for the t-, BB1, BB6, BB7 and BB8 copulas.} + necessary for the t-, BB1, BB6, BB7, BB8, Tawn type 1 and type 2 copulas.} } \value{ Modified: pkg/man/RVineCopSelect.Rd =================================================================== --- pkg/man/RVineCopSelect.Rd 2013-10-11 07:46:49 UTC (rev 29) +++ pkg/man/RVineCopSelect.Rd 2013-10-11 13:35:49 UTC (rev 30) @@ -67,7 +67,15 @@ \code{37} = rotated BB1 copula (270 degrees) \cr \code{38} = rotated BB6 copula (270 degrees) \cr \code{39} = rotated BB7 copula (270 degrees) \cr - \code{40} = rotated BB8 copula (270 degrees) + \code{40} = rotated BB8 copula (270 degrees) \cr + \code{104} = Tawn type 1 copula \cr + \code{114} = rotated Tawn type 1 copula (180 degrees) \cr + \code{124} = rotated Tawn type 1 copula (90 degrees) \cr + \code{134} = rotated Tawn type 1 copula (270 degrees) \cr + \code{204} = Tawn type 2 copula \cr + \code{214} = rotated Tawn type 2 copula (180 degrees) \cr + \code{224} = rotated Tawn type 2 copula (90 degrees) \cr + \code{234} = rotated Tawn type 2 copula (270 degrees) \cr } \item{par}{Estimated pair-copula parameter matrix.} \item{par2}{Estimated second pair-copula parameter matrix with parameters of pair-copula families with two parameters.} Modified: pkg/man/RVineGofTest.Rd =================================================================== --- pkg/man/RVineGofTest.Rd 2013-10-11 07:46:49 UTC (rev 29) +++ pkg/man/RVineGofTest.Rd 2013-10-11 13:35:49 UTC (rev 30) @@ -1,164 +1,164 @@ -\name{RVineGofTest} -\alias{RVineGofTest} - -\title{Goodness-of-fit tests for R-vine copula models} - -\description{ -This function performs a goodness-of-fit test for R-vine copula models. There are 15 different goodness-of-fit tests implemented, described in Schepsmeier (2013). -} - -\usage{ -RVineGofTest(data,RVM,method="White",statistic="CvM",B=200,alpha=2) -} - -\arguments{ - \item{data}{An N x d data matrix (with uniform margins).} - \item{RVM}{\code{\link{RVineMatrix}} objects of the R-vine model under the null hypothesis.} - \item{method}{A string indicating the goodness-of-fit method:\cr - \code{"White"} = goodness-of-fit test based on White's information matrix equality (default) \cr - \code{"IR"} = goodness-of-fit test based on the information ratio \cr - \code{"Breymann"} = goodness-of-fit test based on the probability integral transform (PIT) and the aggregation to univariate data by Breymann et al. (2003). \cr - \code{"Berg"} = goodness-of-fit test based on the probability integral transform (PIT) and the aggregation to univariate data by Berg and Bakken (2007). \cr - \code{"Berg2"} = second goodness-of-fit test based on the probability integral transform (PIT) and the aggregation to univariate data by Berg and Bakken (2007). \cr - \code{"ECP"} = goodness-of-fit test based on the empirical copula process (ECP) \cr - \code{"ECP2"} = goodness-of-fit test based on the combination of probability integral transform (PIT) and empirical copula process (ECP) (Genest et al. 2009) \cr - } - \item{statistic}{A string indicating the goodness-of-fit test statistic type:\cr - \code{"CvM"} = Cramer-von Mises test statistic (univariate for \code{"Breymann"}, \code{"Berg"} and \code{"Berg2"}, multivariate for \code{"ECP"} and \code{"ECP2"}) \cr - \code{"KS"} = Kolmogorov-Smirnov test statistic (univariate for \code{"Breymann"}, \code{"Berg"} and \code{"Berg2"}, multivariate for \code{"ECP"} and \code{"ECP2"}) \cr - \code{"AD"} = Anderson-Darling test statistic (only univariate for \code{"Breymann"}, \code{"Berg"} and \code{"Berg2"}) - } - \item{B}{an integer for the number of bootstrap steps (default \code{B=200})\cr - For \code{B = 0} the asymptotic p-value is returned if available, otherwise only the the test statistic is returned.\cr - WARNING: If \code{B} is chosen too large, computations will take very long.} - \item{alpha}{an integer of the set \code{2,4,6,...} for the \code{"Berg2"} goodness-of-fit test (default \code{alpha=2})} -} - -\value{ - For \code{method="White"}: - \item{White}{test statistic} - \item{p.value}{p-value, either asymptotic for \code{B=0} or bootstrapped for \code{B>0}} - For \code{method="IR"}: - \item{IR}{test statistic} - \item{p.value}{So far no p-value is returned nigher a asymptotic nor a bootstrapped one. How to calculated a bootstrapped p-value is explained in Schepsmeier (2013)} - For \code{method="Breymann"}, \code{method="Berg"} and \code{method="Berg2"}: - \item{CvM, KS, AD}{test statistic according to the choice of \code{statistic}} - \item{p.value}{p-value, either asymptotic for \code{B=0} or bootstrapped for \code{B>0}. - A asymptotic p-value is only available for the Anderson-Darling test statistic if the R-package \code{ADGofTest} is loaded. \cr - Furthermore, a asymptotic p-value can be calculated for the Kolmogorov-Smirnov test statistic. For the Cramer-von Mises no asymptotic p-value is available so far.} - For \code{method="ECP"} and \code{method="ECP2"}: - \item{CvM, KS}{test statistic according to the choice of \code{statistic}} - \item{p.value}{bootstrapped p-value} -} - - -\details{ -\code{method="White"}: \cr -This goodness-of fit test uses the information matrix equality of White (1982) and was original investigated by Wanling and Prokhorov (2011) for copulas. \cr -Schepsmeier (2012) enhanced their approach to the vine copula case. \cr -The main contribution is that under correct model specification the Fisher Information can be equivalently calculated as minus the expected Hessian matrix or as the expected outer product of the score function. -The null hypothesis is -\deqn{ - H_0: \boldsymbol{H}(\theta) + \boldsymbol{C}(\theta) = 0 -} -against the alternative -\deqn{ - H_0: \boldsymbol{H}(\theta) + \boldsymbol{C}(\theta) \neq 0 , -} -where \eqn{\boldsymbol{H}(\theta)} is the expected Hessian matrix and \eqn{\boldsymbol{C}(\theta)} is the expected outer product of the score function. \cr -For the calculation of the test statistic we use the consistent maximum likelihood estimator \eqn{\hat{\theta}} and the sample counter parts of \eqn{\boldsymbol{H}(\theta)} and \eqn{\boldsymbol{C}(\theta)}. \cr -The correction of the Covariance-Matrix in the test statistic for the uncertainty in the margins is skipped. The implemented tests assumes that where is no uncertainty in the margins. The correction can be found in Wanling and Prokhorov (2011) for bivariate copulas and in Schepsmeier (2013) for vine copulas. It involves multi-dimensional integrals. \cr - -\code{method="IR"}: \cr -As the White test the information matrix ratio test is based on the expected Hessian matrix \eqn{\boldsymbol{H}(\theta)} and the expected outer product of the score function \eqn{\boldsymbol{C}(\theta)}. \cr -\deqn{ - H_0: -\boldsymbol{H}(\theta)^{-1}\boldsymbol{C}(\theta) = I_{p} -} -against the alternative -\deqn{ - H_0: -\boldsymbol{H}(\theta)^{-1}\boldsymbol{C}(\theta) \neq I_{p} . -} -The test statistic can then be calculated as -\deqn{ - IR_n:=tr(\Phi(\theta)/p -} -with \eqn{\Phi(\theta)=-\boldsymbol{H}(\theta)^{-1}\boldsymbol{C}(\theta)}, p is the number of parameters, i.e. the length of \eqn{\theta}, and tr(A) is the trace of the matrix A \cr -For details see Schepsmeier (2013) \cr - -\code{method="Breymann"}, \code{method="Berg"} and \code{method="Berg2"}: \cr -These tests are based on the multivariate probability integral transform (PIT) applied in \code{\link{RVinePIT}}. The multivariate data \eqn{y_{i}} returned form the PIT are aggregated to univariate data by different aggregation functions \eqn{\Gamma(\cdot)} in the sum -\deqn{ - s_t=\sum_{i=1}^d \Gamma(y_{it}), t=1,...,n -} -In Breymann et al. (2003) the weight function is suggested as \eqn{\Gamma(\cdot)=\Phi^{-1}(\cdot)^2}, while in Berg and Bakken (2007) the weight function is either \eqn{\Gamma(\cdot)=|\cdot-0.5|} (\code{method="Berg"}) or \eqn{\Gamma(\cdot)=(\cdot-0.5)^{\alpha},\alpha=2,4,6,...} (\code{method="Berg2"}). \cr -Furthermore, the \code{"Berg"} and \code{"Berg2"} test are based on the order statistics of the PIT returns. \cr -See Berg and Bakken (2007) or Schepsmeier (2013) for details. \cr - -\code{method="ECP"} and \code{method="ECP2"}: \cr -Both tests are test for \eqn{H_0: C \in C_0} against \eqn{H_1: C \notin C_0} -where C denotes the (vine) copula distribution function and \eqn{C_0} is a class of parametric -(vine) copulas with \eqn{\Theta\subseteq R^p} being the parameter space of dimension p. -They are based on the empirical copula process (ECP) -\deqn{ - \hat{C}_n(u)-C_{\hat{\theta}_n}(u), -} -with \eqn{u=(u_1,\ldots,u_d)\in[0,1]^d} and \eqn{\hat{C}_n(u) = \frac{1}{n+1}\sum_{t=1}^n \boldsymbol{1}_{\{U_{t1}\leq u_1,\ldots,U_{td}\leq u_d \}} }. -The ECP is utilized in a multivariate Cramer-von Mises (CvM) or multivariate Kolmogorov-Smirnov (KS) based test statistic. -An extension of the ECP-test is the -combination of the multivariate PIT approach with the ECP. The general idea is that -the transformed data of a multivariate PIT should be "close" to the independence -copula Genest et al. (2009). Thus a distance of CvM or KS type between them -is considered. This approach is called ECP2. Again we refer to Schepsmeier (2013) for details. -} - -\author{Ulf Schepsmeier} - -\references{ -Berg, D. and H. Bakken (2007) -A copula goodness-of-fit apprach based on the conditional probability integral transformation. -\url{http://www.danielberg.no/publications/Btest.pdf} - -Breymann, W., A. Dias and P. Embrechts (2003) -Dependence structures for multivariate high-frequence data in finance. -Quantitative Finance 3, 1-14 - -Genest, C., B. Remillard, and D. Beaudoin (2009) -Goodness-of-fit tests for copulas: a review and power study. -Insur. Math. Econ. 44, 199-213. - -Schepsmeier, U. (2013) -A goodness-of-fit test for regular vine copula models. -Preprint -\url{http://arxiv.org/abs/1306.0818} - -Schepsmeier, U. (2013) [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/vinecopula -r 30 From noreply at r-forge.r-project.org Fri Oct 11 16:32:58 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 11 Oct 2013 16:32:58 +0200 (CEST) Subject: [Vinecopula-commits] r31 - / pkg/man Message-ID: <20131011143258.31A2A185F71@r-forge.r-project.org> Author: ulf Date: 2013-10-11 16:32:57 +0200 (Fri, 11 Oct 2013) New Revision: 31 Modified: pkg.pdf pkg/man/BiCopPar2TailDep.Rd pkg/man/BiCopPar2Tau.Rd Log: Ich hoffe jetzt stimmen die Formeln in tau und tail dependence Modified: pkg/man/BiCopPar2TailDep.Rd =================================================================== --- pkg/man/BiCopPar2TailDep.Rd 2013-10-11 13:35:49 UTC (rev 30) +++ pkg/man/BiCopPar2TailDep.Rd 2013-10-11 14:32:57 UTC (rev 31) @@ -102,8 +102,8 @@ \code{28, 38} \tab - \tab - \cr \code{29, 39} \tab - \tab - \cr \code{30, 40} \tab - \tab - \cr -\code{104, 204} \tab - \tab \eqn{\Psi_1+\Psi_2-2((0.5\Psi_1)^{\theta}+(0.5\Psi_2)^{\theta})^{1/\theta}} \cr -\code{114, 214} \tab \eqn{\Psi_1+\Psi_2-2((0.5\Psi_1)^{\theta}+(0.5\Psi_2)^{\theta})^{1/\theta}} \tab - \cr +\code{104,204} \tab - \tab \eqn{\delta+1-(\delta^{\theta}+1)^{1/\theta}} \cr +\code{114, 214} \tab \eqn{1+\delta-(\delta^{\theta}+1)^{1/\theta}} \tab - \cr \code{124, 224} \tab - \tab - \cr \code{134, 234} \tab - \tab - \cr } Modified: pkg/man/BiCopPar2Tau.Rd =================================================================== --- pkg/man/BiCopPar2Tau.Rd 2013-10-11 13:35:49 UTC (rev 30) +++ pkg/man/BiCopPar2Tau.Rd 2013-10-11 14:32:57 UTC (rev 31) @@ -85,10 +85,14 @@ \code{29, 39} \tab \eqn{-1-4\int_0^1 ( (1-(1-t)^{-\theta})^{\delta} - )/( -\theta\delta(1-t)^{-\theta-1}(1-(1-t)^{-\theta})^{\delta-1} ) dt} \cr \code{30, 40} \tab \eqn{-1-4\int_0^1 -\log \left( ((1+t\delta)^{-\theta}-1)/((1+\delta)^{-\theta}-1) \right)} \cr \tab \eqn{* (1+t\delta-(1+t\delta)^{\theta}-(1+t\delta)^{\theta}t\delta)/(\theta\delta) dt} \cr - \code{104,114,204,214} \tab \eqn{\int_0^1 \frac{t(1-t)A^{\prime\prime}(t)}{A(t)^2}dt} \cr - \tab with \eqn{A(t) = (1-\Psi_2)(1-t)+(1-\Psi_1)t+[(\Psi_1(1-t))^{\theta}+(\Psi_2t)^{\theta}]^{1/\theta}} \cr - \code{124,134,224,234} \tab \eqn{-\int_0^1 \frac{t(1-t)A^{\prime\prime}(t)}{A(t)^2}dt} \cr - \tab with \eqn{A(t) = (1-\Psi_2)(1-t)+(1-\Psi_1)t+[(\Psi_1(1-t))^{-\theta}+(\Psi_2t)^{-\theta}]^{-1/\theta}} \cr + \code{104,114} \tab \eqn{\int_0^1 \frac{t(1-t)A^{\prime\prime}(t)}{A(t)}dt} \cr + \tab with \eqn{A(t) = (1-\delta)t+[(\delta(1-t))^{\theta}+t^{\theta}]^{1/\theta}} \cr + \code{204,214} \tab \eqn{\int_0^1 \frac{t(1-t)A^{\prime\prime}(t)}{A(t)}dt} \cr + \tab with \eqn{A(t) = (1-\delta)(1-t)+[(1-t)^{-\theta}+(\delta t)^{-\theta}]^{-1/\theta}} \cr + \code{124,134} \tab \eqn{-\int_0^1 \frac{t(1-t)A^{\prime\prime}(t)}{A(t)}dt} \cr + \tab with \eqn{A(t) = (1-\delta)t+[(\delta(1-t))^{-\theta}+t^{-\theta}]^{-1/\theta}} \cr + \code{224,234} \tab \eqn{-\int_0^1 \frac{t(1-t)A^{\prime\prime}(t)}{A(t)}dt} \cr + \tab with \eqn{A(t) = (1-\delta)(1-t)+[(1-t)^{-\theta}+(\delta t)^{-\theta}]^{-1/\theta}} \cr } } Modified: pkg.pdf =================================================================== --- pkg.pdf 2013-10-11 13:35:49 UTC (rev 30) +++ pkg.pdf 2013-10-11 14:32:57 UTC (rev 31) @@ -2968,22 +2968,33 @@ /ProcSet [ /PDF /Text ] >> endobj 714 0 obj << -/Length 1982 +/Length 1868 /Filter /FlateDecode >> stream -xZKs6Wi"XN4I:m➒5EE)$ږ_c\~]췻 @&Nz/rXbS8J *ъYr2J|;y -I%"N!s49@ v20?L_gsf/2րJ9+e,/lU+b -O]^y6eӬ}gI6[˝MΜlVo1gday=}1S -3*+uK b8~`` V̔_)^&͍W»2 -DKH"/ӟN."1*IIb!&F?X:)bN&x "pڛ84fU?Yğr5]=F84f+4ѵ! RP: r+{ssF.(H(MF}̶&*D/ݸs24JNE5מ~~'?ە5?ʋ25%xM\_ǹ5хlI t|^dll](c -aTDL@*JY>gNOJQP[fזV -8o, -~=si0^uz_Wy,a$iٴPG-pz*=xk_< c8\#ׄuo`ʮq@‘cԉՕsy^hzJW(&cdYYl/FYKq>dΪ*}2$&2W^ -c~ jdi{klȠB/BY@k^l"^6|dVmɿ.CHDRۨAk>Rd32Ik$ɥ8OE bhka]Aq|33bV&Ů􏡠?uUjXkF=è`szu@6 QXFĚІ0r`Hk" he~85T\Fn-&;?Bm=dͬAPƑ iX}{oc otG}`v 5?knTݚ4Ҵ֮8|,~yz.\=DlToKDu]{Q/m - Vr*:Tfȋ EQZKD}ԞPΡ7ἉUFRZ?Č 1xGR\Wcx{ޚTpmV8VfZͶVjy)~ClGJ8n!!C1mP_#_}Ш{LvD`&,f+JfM6?bX<[\MΎu{"JnvdQ%˖("9,az ]NH__~p-@|u\{,[VHmtB2SٝIP}Jik_7E7Jl<ށ!ոw[P]ڣ.T ]T.U]WUu3 mnS.ЛVAè}ˎlX!q_=㠉2`T6T]3;XRDNb!K͵-ewn 5n.=ۻNڝbfjj_2%@qM @āÅ@1TG!@X Fuˍ/IXm|NѕwPx{oPqWpT^ -\ Hܰ#uǠl}QN=h_ gUNs$ūqB˛ >Ywlk3iB>^NWQ6]`n>rZz -ln8zM>Q>#;%|w7}!w_޳ +4ԗ:׾Mf;7@ȈS[?>܎~v$h09ISDHGGբ)֮fH>f +N!Pv|رv.y CpW:&PtBvΰvO){1w5 +aWljFw͖|]k8(&b0NADƅ-ȿ*M#ib$$8ݽ!N֓?ֵxq}lM}cJͽiaq҇f2D6H`\pEjrq]άQcq?MAVl^3|<7$)- bXzDw!) 7Vbأ ڻx>Vyinv~ݟ~^dPNVߧ +?NjLoaUn߯l[ŝ'D +\E?@W endstream endobj 713 0 obj << @@ -3066,46 +3077,34 @@ /ProcSet [ /PDF /Text ] >> endobj 730 0 obj << -/Length 3135 +/Length 3099 /Filter /FlateDecode >> stream -x\[s۸~[剅ai:촻dtGrmI}. -Hm$->˳*, -TqyS0J Њɡ.>L9xoem^. -̞Sg4=@)HM,0n#2W9Ga[.Owp;4 -_K'燲|, -2FQ<0;c"'&@A'(_}X"]nc:6+` ?-j~5 \\1L+ǵ=E{; 7c\\8FX\.W%$[ --9Val Q&<{@ T2)MdX=|9!OsIa>[գ$Ze~=MP}5XS!ص6dT~Z5K׻f\8%sx'X.DORxx\罉`Ԋr hF0l!U'fG~C@Գc:+oڜJ"J2) -!,fOp@pƨ~YgBV:K -W)b))ER]`x$ XCٿϜ+UhIPS\}9# -­)_ -[wog 'в@J<V% -WE)m6# -:N9 -8VA9P&70`dPܰ=cWkz9[FF` zXV38[˪ˈ""\;fiJ7BaZ7QcN^=jޯyW],׈!<>QD7r Hpb03g` ¯\1CW"у 3*TC/}=a3U%ƇϻO6l֡h/##%dD -D*կSfQq -S~+j{L#`q8e0FrZjá -&*Nn_?ҟՙ '=)k -mͻhke{56B[ IݕWqUـ،jmLlCEmWd -*SumRZ@("}*o"yFr*†člSMVZBqa|?(P>0fq -h^Zwv8gw\ao҇[48>P>\?pPۘʮF[!NT JdngNXGPGR'[X|SH^ -gs +b>n|묃OZԔ0jsk*کzA > Fw2ΌLn -{$ݦIh>^Qyg2[̉x e#mqbC-99/-01n&^q^!Q45Lc۹43K\Z|rzp߽^A6S$DQc^,`0k -@Ȭu㛔fƏ:NFIlWg+lII~ :f^q(!swVt0oc;4ꥃbhX ^H Vjy_ӆ0<-`W 5 M#^M(X U"^ b̈2BZbB?ĈʾG9AU@|7?tIg2ֿ)h7ʫFÒV!YFq8"6A'V9vBއdsԎDZnÛX= -#Ҩ*?ӝno}̈Nk6;tALu}1?a -Akj^^nFھhݕ0,*%+9L`YFv0a~dGxvpϖAlKcf4c^Ld0S# +x\Ks8Wr%B{rL6[[5;K&ŢcU9צ7ɿƃA)ɲ3( +@ɧ ٫w\M, +j(%\VHxNH.X&p?Ι=uFZ4 +3fRJ!ys|N,˛7*\\onw*)h, +Gڧ,1F'={c?A.Zp|Y;"\atm6x 6HjQ$5G`݃G=x8Qڧ{ +"HLBVA>8\ݹSһnd$+.+-XZ 3-prt]^bQX}+]_xՖecHbsG'*T;A⢸rnʿftЍx$NG.rKd#N#Lh;e]Fjy).EC˜U +o-֟o娈12hQ&bVk0Xպ V7t|Xs9/ϛ]Q./7/N9sb*1z?7z~S,:hPߖs(nqbU\^B-CH?Mfp7(HX T)mmy!hjէpKCD]qnr^գIx[ߛ6F_kcMe6hc7 QY5,w trJ'pk"^N\=;pw_罉8Ԋ2Ќ`xٱCP1%(70jUQ鮼is*P*eNy٪ps|ܬLN17Fą6YtʯO)1{ad`ܸzv‰88]9I:ahJ0a&j&Npk&_Z/Ûog'Ю@%# oD+ ^b6ӜP]Yg D d<ܒ*daz @Lj62mo:0AmU/ e)N2]Q,B 1Ld"rhJBaZ7ƶY@DPQ~ţmvX.~P,'QD7#1&Қ>{Yo1pLE +Ё1nquãzF)gvq +KdόkU´&C8&Nhț1 +8iM +:O9 g9 (nXv6 +u 1)>~Y9߆CiշĨ( _S'4th9֑bd0Im"J>y-Q1BN3JBC[:.h[=5Kߤm3'_o; =u5`i9\TSBn\Α +j㷘_=.zP澸jUۯzb{ohS Lzî)jAmͬ*5 +EpBT%ʯ9 +XzJ=K<ݬa50G3o)IIYTZFpȨnڵZ&kHŪT"a*U"eM1e̶64-IW5H e] +:6?;]Y~0Bo_7lۛFas][M%D[/˹i{t3Sq mI^ hk3@/!^"75M2qQN~RqB3wd'T_2MYԧ;w]$`ʠOR1>vȱG{pI3`b&&z0C4w9v@Sr黁7DK;Es Ѯ"BT \}4SBTӓJ:62]vxA4벿8XtrT!?Z :lWa>,c>ʤE 846gb\HOu+Zitwt#6N8x&R6l&z0ޕ3Vً +D5i`%wJS4I3Ð4݁5'ݻPˏ +q"9&82l\ +=qn&ǑAa{Z٨JZ[̝}°"bOSz>x̵_mfc^6/4MhT=j+yXA)b`a#`T潭aF$PL;X$LhRx0}h +gJ޴*/b+=1opQ=(/nu4̘$آ{ߍxCh:aUa!y0w,d`?75G'?d#}wcvƯk` endstream endobj 729 0 obj << @@ -3129,20 +3128,23 @@ /ProcSet [ /PDF /Text ] >> endobj 738 0 obj << -/Length 1113 +/Length 1566 /Filter /FlateDecode >> stream -xڝVn:+t#1KRY$NӢmU-6*QmүÇlq%aΙ3ag`|1x{NbNbxY[\n(0}Kԑ p6蝝3=cr6 -mYn 0zX}`HM(@][^59t -a| -I"͛<'WdFIH[UI1[Z0rųY2 ^b(i%6߲*gŁWe?e* f$D/[PH9;Ǯ'=v% -3QqRLhWAmnLlR@)r&Ei1ʵs0%˭(}JGȭ2+K3rnY !]%e+DaOew(M` Ћe]s,kʣةL22opZ/> -*{:XY[ -ևYqii*KJ˪1\`l@$ȩBt`u:)>ƖYѬ:7%KI3QG Q^, AN>/&&D_:)aD@|r{ Kb>;>2̹i9V }"9ݼ )Jb /!MaVjw_y&^xu\*b96i-*-V(wXlg-L\Lz`cUZ)qAk!Ue@u] -Q6U(A&Ye-R^& -ɟMQu0J\qdTɚ"{ m?{. Y˦y!_VZzRB]- =@KJeY7]xz־{u%ŭM;t at gfIΊΩr-_oOiж-^|Cdo"юipu1'y7d}z :ŵl! -i4}șٿW{#:؛͗<{Ytp ]#SHsx4zd4z,t4~ +xXKs6Wp&jb!x3#1(>> INS/H.w}`q~f1y3GY1b\8R`1,VΝ&gO1ё @Y-|-2V3cD!"3Rb~D֨"bD1oT] K<{x@ CJu:|AMzRb.4(kxȴޱVc)/7݉hDL a];`@dYr᎜'cIJ []/G!2 "<,{ R$6(`?2-"J;f)$ 3"_P 7P r; +a}>u!  1`{ +18.ɞCݯ79Aa#*W>ھOjUҺ=s8~]{?in,Dh1;z\&{GZZ4q8E^}bva +:|ÜЅ0]cOFiP əU9o3!ajC- NN2q+]Rjmz!Zй׈m&{ɚ15䈂N;Go9~#gsj!Z3e[,.]%i%/npW$aCkT@&6 H˰?fᅱ> +/'pTqM~?AehoUf+wa҈<,6%Az҇ -߲tp haRm(jWʴ ͗ߋǮ}j-RўRLh)M%Ub) +hesQFIPFՑ͚DS⹡5}RD<]-ʰ[ff +6H769Dm ewGƯ3햽CƔmhm^E6XQǝ|4Ϻz`Sg|-~ +} ]|@(P&bta4YUQD02UqO ,4 +r +Շ#2[@i\>˯CA3xW5qQ<~ٳ.b3]`%oS٫~8a0":yФznZuQvf{m`{9/S[ի2uX,hW;bF,}XʙӞgͳv|l !h<- +ðh endstream endobj 737 0 obj << @@ -3157,50 +3159,56 @@ /Type /Annot /Subtype /Link /Border[0 0 0]/H/I/C[1 0 0] -/Rect [117.35 591.422 179.119 601.653] +/Rect [117.35 524.455 179.119 534.686] /A << /S /GoTo /D (Rfn.BiCopTau2Par) >> >> endobj 291 0 obj << /D [737 0 R /XYZ 99.346 773.487 null] >> endobj 739 0 obj << -/D [737 0 R /XYZ 100.346 744.525 null] +/D [737 0 R /XYZ 100.346 675.693 null] >> endobj 740 0 obj << -/D [737 0 R /XYZ 100.346 698.729 null] +/D [737 0 R /XYZ 100.346 630.607 null] >> endobj 741 0 obj << -/D [737 0 R /XYZ 100.346 624.879 null] +/D [737 0 R /XYZ 100.346 557.76 null] >> endobj 742 0 obj << -/D [737 0 R /XYZ 100.346 579.083 null] +/D [737 0 R /XYZ 100.346 512.674 null] >> endobj 390 0 obj << -/D [737 0 R /XYZ 100.346 430.377 null] +/D [737 0 R /XYZ 100.346 367.273 null] >> endobj 78 0 obj << -/D [737 0 R /XYZ 100.346 430.377 null] +/D [737 0 R /XYZ 100.346 367.273 null] >> endobj 743 0 obj << -/D [737 0 R /XYZ 100.346 382.735 null] +/D [737 0 R /XYZ 100.346 320.962 null] >> endobj 744 0 obj << -/D [737 0 R /XYZ 100.346 324.985 null] +/D [737 0 R /XYZ 100.346 263.921 null] >> endobj 745 0 obj << -/D [737 0 R /XYZ 100.346 279.189 null] +/D [737 0 R /XYZ 100.346 218.836 null] >> endobj 736 0 obj << -/Font << /F43 281 0 R /F36 226 0 R /F35 225 0 R /F22 227 0 R /F44 283 0 R >> +/Font << /F43 281 0 R /F36 226 0 R /F11 330 0 R /F8 329 0 R /F14 328 0 R /F13 614 0 R /F10 401 0 R /F7 403 0 R /F22 227 0 R /F1 404 0 R /F12 734 0 R /F35 225 0 R /F44 283 0 R >> /ProcSet [ /PDF /Text ] >> endobj 751 0 obj << -/Length 985 +/Length 903 /Filter /FlateDecode >> stream -xڽMs8]}Yg*MfkN[j/;sp@ L,A\Rë~zz5\]?% ay 2/fD{OacŀFM=e囿xPqފPƕ>+qncȉi!?smLML2;Y"(2ȹLK1Ӄe\k+bmDL(Bl1&۪ezIG9JM~fi/I,kg7^r]z;=#ܼ'7s.NzrNKÞ)7To]19F}Jy -qܓ8n5}qJtAC78P8#9oLZ7^ڣ|OMԅ? 5Iڜɇ^{b7~{j2|{~)"慘#ͳI5|@qG!+Q""kXQLuV~Ww.Ñ4ROZ+n-nýIڽIZmh%A&\ղܑcXAXArHu5KTF3+n)4F̉O`yd/gsPGg(lbZ[27,0O{G"q3f}R?i١DBo>xxnpjftM [@W"/T2g,2ڍ 1] qQUmWW6>*]v]vHԑzF0*WXTBg,lzVleg862=OWؾnK)&c6ښI6[QF"_i+oOٮ)(5,×_AٯPzeju槪$( tޢ)GX6>[dbkD^c5P@O&H +xڽMs0 +홠V;=4Sazi{p@$LfL}%$ Dծb{wzC=M=! {!&rHLC@YO̮C=->1<҆dFBC10gce1_5q#cƝ7ԿK98 +Ԃ=j[a uk*FS֯4 +yˉ\{蕫Y0,ep̨7DT}("J3] 07g]E6wLqahm{i櫴66TD^"z5Ƒ:SĢjg@&?E2>X:u?[H8 endstream endobj 750 0 obj << @@ -3215,111 +3223,101 @@ /Type /Annot /Subtype /Link /Border[0 0 0]/H/I/C[1 0 0] -/Rect [117.35 188.185 159.193 198.417] +/Rect [117.35 111.754 159.193 121.986] /A << /S /GoTo /D (Rfn.BiCopCDF) >> >> endobj 747 0 obj << /Type /Annot /Subtype /Link /Border[0 0 0]/H/I/C[1 0 0] -/Rect [162.182 188.185 213.988 198.417] +/Rect [162.182 111.754 213.988 121.986] /A << /S /GoTo /D (Rfn.BiCopHfunc) >> >> endobj 748 0 obj << /Type /Annot /Subtype /Link /Border[0 0 0]/H/I/C[1 0 0] -/Rect [216.977 188.185 258.82 198.417] +/Rect [216.977 111.754 258.82 121.986] /A << /S /GoTo /D (Rfn.BiCopSim) >> >> endobj 752 0 obj << /D [750 0 R /XYZ 99.346 773.487 null] >> endobj 753 0 obj << -/D [750 0 R /XYZ 100.346 314.201 null] +/D [750 0 R /XYZ 100.346 248.386 null] >> endobj 754 0 obj << -/D [750 0 R /XYZ 100.346 267.976 null] +/D [750 0 R /XYZ 100.346 197.457 null] >> endobj 755 0 obj << -/D [750 0 R /XYZ 100.346 221.752 null] +/D [750 0 R /XYZ 100.346 146.529 null] >> endobj -756 0 obj << -/D [750 0 R /XYZ 100.346 175.528 null] ->> endobj 749 0 obj << /Font << /F36 226 0 R /F43 281 0 R /F22 227 0 R /F35 225 0 R >> /ProcSet [ /PDF /Text ] >> endobj -759 0 obj << -/Length 1370 +758 0 obj << +/Length 1420 /Filter /FlateDecode >> stream -xڵXIs6WprfLvt8LcH$L(\J^oJip3\+vdnQB 0 2kXy[E*fqlx:aGɀ " -iUîؕMjK6`~ ~(xIa>fX |Gֳ6,AbG4P4 RZrV|3{M4} S)7CITj\8;k( Y)W۔m۩V -G#'b}Ȧq<7yK+ͩs3Vej1)5a`2WL/&MQda|?Q\;7YNuhq(yиL"Xp!p{VVEj (1rPbZsW"lbMY:FoVW0h yۂm-g5T's}_Va=~wݕ>;a2O -Hw׿4!R$1o6\, -OAbpMƾ.&y]k,LN 4b|)Y]n*QlxTzgΰFG@pm&MTS="(ْsےjpک. * g@S]} ?F^3ֶaZ˜mnIcϲ2MCDpleG2M"7S+3U'\[P&:s,ۀ:z#:%*ď+M,jVX .TRW1jʧ-Jw"Zvzhcћ§A/]vtv2a/{nv2'ࢸq=qN?b|`Z.,^¹& Rs. +șp pd/p. +xڵWIs6Wpҋ4c2ؙdR+8>",a.b )Iq/·|xY YggKϵb'H`-z]bf~ o/ݠ!S&3d2߳MB].Ӵ84$Ċ9^C']뷅#4xZ3/TϨ-yy$1rb?!RBkԃO 9IAK`vb@Ghvf^msoTCTlu]s7!']ff;F8r7tvsA|Ǎ#QYFd zϋPX ([C$k{ /q<6!xNDOR8_Rm+XT5OS^{w'vWgk \p +!T4bˋ{:;VK^3LUEȐiq> endobj 292 0 obj << -/D [758 0 R /XYZ 99.346 773.487 null] +/D [757 0 R /XYZ 99.346 773.487 null] >> endobj +759 0 obj << +/D [757 0 R /XYZ 100.346 744.525 null] +>> endobj 493 0 obj << -/D [758 0 R /XYZ 100.346 679.45 null] +/D [757 0 R /XYZ 100.346 618.559 null] >> endobj 82 0 obj << -/D [758 0 R /XYZ 100.346 679.45 null] +/D [757 0 R /XYZ 100.346 618.559 null] >> endobj 760 0 obj << -/D [758 0 R /XYZ 100.346 621.792 null] +/D [757 0 R /XYZ 100.346 561.25 null] >> endobj 761 0 obj << -/D [758 0 R /XYZ 100.346 552.105 null] +/D [757 0 R /XYZ 100.346 491.865 null] >> endobj 762 0 obj << -/D [758 0 R /XYZ 100.346 494.372 null] +/D [757 0 R /XYZ 100.346 434.436 null] >> endobj -757 0 obj << -/Font << /F43 281 0 R /F36 226 0 R /F22 227 0 R /F44 283 0 R /F35 225 0 R >> +756 0 obj << +/Font << /F43 281 0 R /F36 226 0 R /F35 225 0 R /F22 227 0 R /F44 283 0 R >> /ProcSet [ /PDF /Text ] >> endobj 766 0 obj << -/Length 2199 +/Length 2129 /Filter /FlateDecode >> stream -xY[o۸~0$cc7R>fѢ(b>(U$CͿ?3$u5٤8j7\BgW3:՛3f1WfZQ ->;_ -$}͙B1"}̚evZnyjp+xsW@X{XNdv! -ItmN) *<4\SN, 4aٓB8 LI2HgI9ԓDX/"$yKBDOG</#O'z<31M -<{suwq }HSPOTDIz< - `?3rDIM|bI$S6RV*MkhE∷8$Ujj`1 -b&+sIwM 3$|,ٜ -T-wq'e]gyrSf>؆2"?}8}ՄQ{W:30.o2K0wK\vy8_ -*[I…mSyFO DpIJ`F>< %Ymߘ#Kc;3#C -Ծ*/=2$JV\@9IR=#ago]a 4X3tB2pktG))`*j 3-X1̴2ok7)ps`M! Sddtن9(;psU -L;=#(rw~{l]WJ9Ԋ|f$lp?6n,Z`#!%ɸ^a5JhAK49cݦզV)`y04Ym.괲jJp";pyHtM$#7CJ]H4 72DX16 YaMYMętIꞑ`܁/(FAQnŇ#CPYl;B,@l< -@'&B,¿z4V:']ۇ]=6es^ԈÑp - -6#U -Zv9Q>Ï]gyv+ra4#Ƅ* D3@Ȅz8i^lqnehe -h1 k6ejF,nnT -R8Ud,UvU7U f-̪,lVڥinsm;vƼgfƾqKYaN܄%Xc`S,8CQTmʌz%tܨEd^KNya#1,A k!J$Fߓ)0`JfGd{ηs$H?]=; Fz-Pc|8㱣TOJ8\R0.I]yT$,q-\)PͰ2Tڧ_)CDd_}du[J"9mUp`T9*s/tۋ :u;q#K6hgo0 - u6mᖍ2ֿlĬ2;zu9[q.&tˇay`a-CHf'w - M%lc$GNM+Ggv=D;1?fdo9/G&^w6Ž*֦"4s~ uU *!Y*f -L\fӘeA1!=)l6-2dTA!Pv9iQF` wO^PdIhRe-[oj!K4J9qU1F,?1/|b|b/Iyqj)N^cpH,8lD &HPf KޙAHJ8V95 2\& RP$ysgXƂAOTd at Th\*7uSŕ]˜bom -s*At Bȹǽ[]_Tm}^.6nmӪ}i}ko[nsb,|{Ee(?AtjhR94-َ$v-DO)Ζܠy!.?ǡŠ=;]NPF@yF]q +xYKo۸W]ɸ5˗H)Eqn3HQY 0b3ZE2$9|e&ͳŠ@MQ|< ~{<YRArF0FŌ׳?"N|{`$1`3fT/PV~oO)|B hHi?.0B4Q]YclcUEf_qSlk5'qjEx* BP|)eHĽT<ܣ_G_{2O/CznS8&xUi0چ(M6U8uڼvlCϪ\gHr\sG?Y)pM!)UpRnE[^w8Omqt,a^ߙ.\c0(\) X )== AIV@ q=m{6)x"2+7<)><_q–A)d" w O!9O?}b‘}cP%Z6 Ty\p*Nb3+Z06xsV*]ߥYQ¶.K!qQά,ֶ/\_s3 +B!yzgmMŘ& Dl?{lݘMYgtӒSnaH5p`Zwً5)`~vͶml2Sz~`4H7T:k]4j[#+:n<9)tU-(Ѭ +K9Tž$VsSksbꞶr[,ꞵ&2XZĞ\Ng'oL qԪi-PE8,:km'a6z /2sBUg=vѾW_>nEvՂSWhzSH!v;QJ>xʋ\5GZ +zQP Wა"IOBxfs,C/^f7$HxlUw7cw>Vʴ`q}˥ZR3C3*'5-lo*mVgUMVZ4M>d;a~yIt[ +r%uxss,{7yJSmW0jRC'O<m,1r Y@<{-0U +`r;6PKjpN" ä>9:@#e'Bv +̠L&j +8E:湓/[m*lji'܍' endstream endobj 765 0 obj << @@ -3334,114 +3332,115 @@ /Type /Annot /Subtype /Link /Border[0 0 0]/H/I/C[1 0 0] -/Rect [194.331 485.749 256.1 496.653] +/Rect [194.331 422.783 256.1 433.686] /A << /S /GoTo /D (Rfn.BiCopIndTest) >> >> endobj 767 0 obj << /D [765 0 R /XYZ 99.346 773.487 null] >> endobj 768 0 obj << -/D [765 0 R /XYZ 100.346 434.669 null] +/D [765 0 R /XYZ 100.346 367.793 null] >> endobj -769 0 obj << -/D [765 0 R /XYZ 100.346 184.732 null] ->> endobj 764 0 obj << /Font << /F36 226 0 R /F43 281 0 R /F22 227 0 R /F35 225 0 R /F11 330 0 R /F10 401 0 R /F8 329 0 R /F29 506 0 R /F14 328 0 R /F1 404 0 R /F7 403 0 R >> /ProcSet [ /PDF /Text ] >> endobj -776 0 obj << -/Length 1597 +775 0 obj << +/Length 1691 /Filter /FlateDecode >> stream -xWKs6Wh9P3 -x:#I4c)!&! c>4$.i/bہ\_\ uHFb A4#ᆾGgbL:놟oO.hG$'>lx13e4yWwzOhGxאr^&C?:R ej܍z.LK߬ZFWUN -'C/tnY^w.Ya3L F{55;Džj^7*b{!0!(< p9\uxamE%n i* ezriñ/33a:v+p&>Pꡫ^H\uy @ J#9 -GN&ɾFUw[>EKl>Ga3R*uT -VUT$=BH7tuHu=Xj -%WV24]Ac2.kx6a@П'8vpd %3Nh"u9v4HݲnD-4ԐcٲTU5[@kbڴ-~(Wuklp(^`gѲ -ZuiF5VȝLmr"W_K#gyHb~#)<<:ͺnJ%,ZS -IIGC(]aYMeoXO -K[̦euji90dʴْC3PtJs_=pAtAkl)wVNNJ֥q듟M~8IxoE?9@㞺W+(4u ;7Sۑ~pD _SŦu ,>l o ~1ݲ@~:iVZt>C_&[Үe -W^N!0^)vɖ#WQϲ"]Z5ooR)7 _*UU>۬:czu at n&pQ>g4{vVqpnbo}x \:u֭}6?4u#`13 nxL^[{?*L}p}y ~U0dt4F&߱꧟.3VI}b\S -&-zoK}wt>08օ*crsџ.S"a?B5#ٿPYM(Zō&x۵xߴj6{ڏbBA <<"Zݝfvsd+o\g87Nk/9G< A>u&C_I=B@Ԣ1EP(B(P(DB47 L9 +xڥXYo8~0>Ȁ] Xĩmw-bo#1$rFiLp6ER/D4Z,G1Q1/h>9S}^PY7xwrG{Gƽ8~6 + F6ܣuY#ǩpdQ'Ǔ !&<^12YRDz#/MDbƮZT_7z,BFˎz)$Ηcw$@Idß%<"{#OWZw34wҐEMVǮ7̲VSebURA^irE%c徯ad|V<%a2jn +_1V窱qoYsr5s(EGG`\R^t!1q7ljR ٌyܪ#+c7rq  '|wc CΥܴt`k/̭3ԕUP̲zSur) s}&< + +!B>tut)oTap +<|wr(" +E  +ir뢑ݎ}"7,\E|hn=.E +#92 +n֍S +mwni,hnnpK{62٪ָ'H/ iTH0[ٚ}81&ʼn1yL8r6é4[ջS OlfCV ~SKHM\| Author: ulf Date: 2013-10-17 15:14:59 +0200 (Thu, 17 Oct 2013) New Revision: 32 Modified: pkg/R/RVineTreePlot.r pkg/man/RVineGofTest.Rd Log: Fehler behoben in der RVineTreePlot.r und die Familien definiert bei den GOF Modified: pkg/R/RVineTreePlot.r =================================================================== --- pkg/R/RVineTreePlot.r 2013-10-11 14:32:57 UTC (rev 31) +++ pkg/R/RVineTreePlot.r 2013-10-17 13:14:59 UTC (rev 32) @@ -141,12 +141,16 @@ for(j in 1:(d-2)) edgelist[[2]][j,] = c(paste(edges[[2]][j,1,],collapse=","),paste(edges[[2]][j,2,],collapse=",")) # separate conditioned and conditioning sets - for(i in 3:(d-1)){ - for(j in 1:(d-i)){ - edgelist[[i]][j,1] = paste(paste(edges[[i]][j,1,1:2],collapse=","),paste(edges[[i]][j,1,3:i],collapse=","),sep="|") - edgelist[[i]][j,2] = paste(paste(edges[[i]][j,2,1:2],collapse=","),paste(edges[[i]][j,2,3:i],collapse=","),sep="|") - } - } + if(d>3) + { + for(i in 3:(d-1)){ + for(j in 1:(d-i)) + { + edgelist[[i]][j,1] = paste(paste(edges[[i]][j,1,1:2],collapse=","),paste(edges[[i]][j,1,3:i],collapse=","),sep="|") + edgelist[[i]][j,2] = paste(paste(edges[[i]][j,2,1:2],collapse=","),paste(edges[[i]][j,2,3:i],collapse=","),sep="|") + } + } + } Modified: pkg/man/RVineGofTest.Rd =================================================================== --- pkg/man/RVineGofTest.Rd 2013-10-11 14:32:57 UTC (rev 31) +++ pkg/man/RVineGofTest.Rd 2013-10-17 13:14:59 UTC (rev 32) @@ -13,7 +13,8 @@ \arguments{ \item{data}{An N x d data matrix (with uniform margins).} - \item{RVM}{\code{\link{RVineMatrix}} objects of the R-vine model under the null hypothesis.} + \item{RVM}{\code{\link{RVineMatrix}} objects of the R-vine model under the null hypothesis. \cr + Note that the pair-copula families in the R-vine Matrix object have to be a member of the vector \code{(0,1:6,13,14,16,23,24,26,33,34,36)}} \item{method}{A string indicating the goodness-of-fit method:\cr \code{"White"} = goodness-of-fit test based on White's information matrix equality (default) \cr \code{"IR"} = goodness-of-fit test based on the information ratio \cr From noreply at r-forge.r-project.org Fri Oct 18 13:36:55 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 18 Oct 2013 13:36:55 +0200 (CEST) Subject: [Vinecopula-commits] r33 - / pkg/R pkg/inst pkg/man Message-ID: <20131018113655.1DD21185C45@r-forge.r-project.org> Author: ulf Date: 2013-10-18 13:36:53 +0200 (Fri, 18 Oct 2013) New Revision: 33 Added: VineCopula_1.2.zip Modified: pkg.pdf pkg/R/BiCopSelect.r pkg/R/RVineAIC.r pkg/R/RVineClarkeTest.R pkg/R/RVineStructureSelect.r pkg/R/RVineVuongTest.R pkg/inst/ChangeLog pkg/man/BiCopPar2Beta.Rd pkg/man/RVineGofTest.Rd pkg/man/RVinePar2Beta.Rd pkg/man/RVineStructureSelect.Rd pkg/man/RvineMatrixCheck.Rd Log: Tobias hatte noch ein paar kleine Fehler gefunden im Code als auch in der Dokumentation. Ich hoffe ich habe jetzt alle Stellen erwischt, in der die Tawn copula einen Einfluss hat. Added: VineCopula_1.2.zip =================================================================== (Binary files differ) Property changes on: VineCopula_1.2.zip ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: pkg/R/BiCopSelect.r =================================================================== --- pkg/R/BiCopSelect.r 2013-10-17 13:14:59 UTC (rev 32) +++ pkg/R/BiCopSelect.r 2013-10-18 11:36:53 UTC (rev 33) @@ -22,7 +22,7 @@ }else{ - if(!is.na(familyset[1]) && (!any(c(1,2,5,23,24,26:30,33,34,36:40) %in% familyset) || !any(c(1:10,13,14,16:20) %in% familyset))) stop("'familyset' has to include at least one bivariate copula family for positive and one for negative dependence.") + if(!is.na(familyset[1]) && (!any(c(1,2,5,23,24,26:30,33,34,36:40,104,114,204,214) %in% familyset) || !any(c(1:10,13,14,16:20,124,134,224,234) %in% familyset))) stop("'familyset' has to include at least one bivariate copula family for positive and one for negative dependence.") emp_tau = fasttau(data1,data2,weights) Modified: pkg/R/RVineAIC.r =================================================================== --- pkg/R/RVineAIC.r 2013-10-17 13:14:59 UTC (rev 32) +++ pkg/R/RVineAIC.r 2013-10-18 11:36:53 UTC (rev 33) @@ -13,8 +13,8 @@ if(n != dim(RVM)) stop("Dimensions of 'data' and 'RVM' do not match.") if(!is(RVM,"RVineMatrix")) stop("'RVM' has to be an RVineMatrix object.") - npar = sum(RVM$family >= 1, na.rm=TRUE) + sum(RVM$family %in% c(2,7:10,17:20,27:30,37:40),na.rm=TRUE) - npar_pair = (RVM$family>=1)+(RVM$family%in%c(2,7:10,17:20,27:30,37:40)) + npar = sum(RVM$family >= 1, na.rm=TRUE) + sum(RVM$family %in% c(2,7:10,17:20,27:30,37:40,104,114,124,134,204,214,224,234),na.rm=TRUE) + npar_pair = (RVM$family>=1)+(RVM$family%in%c(2,7:10,17:20,27:30,37:40,104,114,124,134,204,214,224,234)) like = RVineLogLik(data,RVM) @@ -38,8 +38,8 @@ if(n != dim(RVM)) stop("Dimensions of 'data' and 'RVM' do not match.") if(is(RVM) != "RVineMatrix") stop("'RVM' has to be an RVineMatrix object.") - npar = sum(RVM$family >= 1, na.rm=TRUE) + sum(RVM$family %in% c(2,7:10,17:20,27:30,37:40),na.rm=TRUE) - npar_pair = (RVM$family>=1)+(RVM$family%in%c(2,7:10,17:20,27:30,37:40)) + npar = sum(RVM$family >= 1, na.rm=TRUE) + sum(RVM$family %in% c(2,7:10,17:20,27:30,37:40,104,114,124,134,204,214,224,234),na.rm=TRUE) + npar_pair = (RVM$family>=1)+(RVM$family%in%c(2,7:10,17:20,27:30,37:40,104,114,124,134,204,214,224,234)) like = RVineLogLik(data,RVM) Modified: pkg/R/RVineClarkeTest.R =================================================================== --- pkg/R/RVineClarkeTest.R 2013-10-17 13:14:59 UTC (rev 32) +++ pkg/R/RVineClarkeTest.R 2013-10-18 11:36:53 UTC (rev 33) @@ -11,8 +11,8 @@ Model1.ll = RVineLogLik(data,RVM1,separate=TRUE)$loglik Model2.ll = RVineLogLik(data,RVM2,separate=TRUE)$loglik - anz.1 = sum(RVM1$family >= 1, na.rm=TRUE) + sum(RVM1$family %in% c(2,7:10,17:20,27:30,37:40),na.rm=TRUE) - anz.2 = sum(RVM2$family >= 1, na.rm=TRUE) + sum(RVM2$family %in% c(2,7:10,17:20,27:30,37:40),na.rm=TRUE) + anz.1 = sum(RVM1$family >= 1, na.rm=TRUE) + sum(RVM1$family %in% c(2,7:10,17:20,27:30,37:40, 104,114,124,134,204,214,224,234),na.rm=TRUE) + anz.2 = sum(RVM2$family >= 1, na.rm=TRUE) + sum(RVM2$family %in% c(2,7:10,17:20,27:30,37:40, 104,114,124,134,204,214,224,234),na.rm=TRUE) B = sum(Model1.ll-Model2.ll > 0) B.Schwarz = sum(Model1.ll-Model2.ll-(anz.1-anz.2)*log(N)/(2*N) > 0) Modified: pkg/R/RVineStructureSelect.r =================================================================== --- pkg/R/RVineStructureSelect.r 2013-10-17 13:14:59 UTC (rev 32) +++ pkg/R/RVineStructureSelect.r 2013-10-18 11:36:53 UTC (rev 33) @@ -11,7 +11,7 @@ if(d<2) stop("Dimension has to be at least 2.") if(any(data>1) || any(data<0)) stop("Data has be in the interval [0,1].") - if(!is.na(familyset[1])) for(i in 1:length(familyset)) if(!(familyset[i] %in% c(0,1:10,13,14,16:20,23,24,26:30,33,34,36:40))) stop("Copula family not implemented.") + if(!is.na(familyset[1])) for(i in 1:length(familyset)) if(!(familyset[i] %in% c(0,1:10,13,14,16:20,23,24,26:30,33,34,36:40, 104,114,124,134,204,214,224,234))) stop("Copula family not implemented.") if(selectioncrit != "AIC" && selectioncrit != "BIC") stop("Selection criterion not implemented.") if(level < 0 & level > 1) stop("Significance level has to be between 0 and 1.") Modified: pkg/R/RVineVuongTest.R =================================================================== --- pkg/R/RVineVuongTest.R 2013-10-17 13:14:59 UTC (rev 32) +++ pkg/R/RVineVuongTest.R 2013-10-18 11:36:53 UTC (rev 33) @@ -11,8 +11,8 @@ Model1.ll = RVineLogLik(data,RVM1,separate=TRUE)$loglik Model2.ll = RVineLogLik(data,RVM2,separate=TRUE)$loglik - anz.1 = sum(RVM1$family >= 1, na.rm=TRUE) + sum(RVM1$family %in% c(2,7,8,9,10,17,18,19,20,27,28,29,30,37,38,39,40),na.rm=TRUE) - anz.2 = sum(RVM2$family >= 1, na.rm=TRUE) + sum(RVM2$family %in% c(2,7,8,9,10,17,18,19,20,27,28,29,30,37,38,39,40),na.rm=TRUE) + anz.1 = sum(RVM1$family >= 1, na.rm=TRUE) + sum(RVM1$family %in% c(2,7,8,9,10,17,18,19,20,27,28,29,30,37,38,39,40, 104,114,124,134,204,214,224,234),na.rm=TRUE) + anz.2 = sum(RVM2$family >= 1, na.rm=TRUE) + sum(RVM2$family %in% c(2,7,8,9,10,17,18,19,20,27,28,29,30,37,38,39,40, 104,114,124,134,204,214,224,234),na.rm=TRUE) if(all(Model1.ll-Model2.ll==0)){ # models are the same V = 0 Modified: pkg/inst/ChangeLog =================================================================== --- pkg/inst/ChangeLog 2013-10-17 13:14:59 UTC (rev 32) +++ pkg/inst/ChangeLog 2013-10-18 11:36:53 UTC (rev 33) @@ -21,6 +21,7 @@ - Bug fix: * RVineStructureSelect: Corrected code for the igraph package + * RVineTreePlot: Now a 3-dimensional R-vine can be plotted too. - Documentation update Modified: pkg/man/BiCopPar2Beta.Rd =================================================================== --- pkg/man/BiCopPar2Beta.Rd 2013-10-17 13:14:59 UTC (rev 32) +++ pkg/man/BiCopPar2Beta.Rd 2013-10-18 11:36:53 UTC (rev 33) @@ -15,7 +15,6 @@ \item{family}{An integer defining the bivariate copula family:\cr \code{0} = independence copula \cr \code{1} = Gaussian copula \cr - \code{2} = Student t copula (t-copula) \cr \code{3} = Clayton copula \cr \code{4} = Gumbel copula \cr \code{5} = Frank copula \cr @@ -53,6 +52,7 @@ \code{214} = rotated Tawn type 2 copula (180 degrees) \cr \code{224} = rotated Tawn type 2 copula (90 degrees) \cr \code{234} = rotated Tawn type 2 copula (270 degrees) \cr + Note that the Student's t-copula is not allowed since the CDF of the t-copula is not implemented (see \code{\link{BiCopCDF}}). } \item{par}{Copula parameter.} \item{par2}{Second parameter for the two parameter BB1, BB6, BB7, BB8, Tawn type 1 and type 2 copulas (default: \code{par2 = 0}).} Modified: pkg/man/RVineGofTest.Rd =================================================================== --- pkg/man/RVineGofTest.Rd 2013-10-17 13:14:59 UTC (rev 32) +++ pkg/man/RVineGofTest.Rd 2013-10-18 11:36:53 UTC (rev 33) @@ -14,7 +14,24 @@ \arguments{ \item{data}{An N x d data matrix (with uniform margins).} \item{RVM}{\code{\link{RVineMatrix}} objects of the R-vine model under the null hypothesis. \cr - Note that the pair-copula families in the R-vine Matrix object have to be a member of the vector \code{(0,1:6,13,14,16,23,24,26,33,34,36)}} + Only the following copula families are allowed in \code{RVM$family} due to restrictions in \code{\link{RVineGrad}} and \code{\link{RVineHessian}} \cr + \code{0} = independence copula \cr + \code{1} = Gaussian copula \cr + \code{2} = Student t copula (t-copula)\cr + \code{3} = Clayton copula \cr + \code{4} = Gumbel copula \cr + \code{5} = Frank copula \cr + \code{6} = Joe copula \cr + \code{13} = rotated Clayton copula (180 degrees; ``survival Clayton'') \cr + \code{14} = rotated Gumbel copula (180 degrees; ``survival Gumbel'') \cr + \code{16} = rotated Joe copula (180 degrees; ``survival Joe'') \cr + \code{23} = rotated Clayton copula (90 degrees) \cr + \code{24} = rotated Gumbel copula (90 degrees) \cr + \code{26} = rotated Joe copula (90 degrees) \cr + \code{33} = rotated Clayton copula (270 degrees) \cr + \code{34} = rotated Gumbel copula (270 degrees) \cr + \code{36} = rotated Joe copula (270 degrees) \cr + } \item{method}{A string indicating the goodness-of-fit method:\cr \code{"White"} = goodness-of-fit test based on White's information matrix equality (default) \cr \code{"IR"} = goodness-of-fit test based on the information ratio \cr @@ -30,7 +47,7 @@ \code{"AD"} = Anderson-Darling test statistic (only univariate for \code{"Breymann"}, \code{"Berg"} and \code{"Berg2"}) } \item{B}{an integer for the number of bootstrap steps (default \code{B=200})\cr - For \code{B = 0} the asymptotic p-value is returned if available, otherwise only the the test statistic is returned.\cr + For \code{B = 0} the asymptotic p-value is returned if available, otherwise only the test statistic is returned.\cr WARNING: If \code{B} is chosen too large, computations will take very long.} \item{alpha}{an integer of the set \code{2,4,6,...} for the \code{"Berg2"} goodness-of-fit test (default \code{alpha=2})} } @@ -68,7 +85,7 @@ } where \eqn{\boldsymbol{H}(\theta)} is the expected Hessian matrix and \eqn{\boldsymbol{C}(\theta)} is the expected outer product of the score function. \cr For the calculation of the test statistic we use the consistent maximum likelihood estimator \eqn{\hat{\theta}} and the sample counter parts of \eqn{\boldsymbol{H}(\theta)} and \eqn{\boldsymbol{C}(\theta)}. \cr -The correction of the Covariance-Matrix in the test statistic for the uncertainty in the margins is skipped. The implemented tests assumes that where is no uncertainty in the margins. The correction can be found in Wanling and Prokhorov (2011) for bivariate copulas and in Schepsmeier (2013) for vine copulas. It involves multi-dimensional integrals. \cr +The correction of the Covariance-Matrix in the test statistic for the uncertainty in the margins is skipped. The implemented test assumes that there is no uncertainty in the margins. The correction can be found in Wanling and Prokhorov (2011) for bivariate copulas and in Schepsmeier (2013) for vine copulas. It involves multi-dimensional integrals. \cr \code{method="IR"}: \cr As the White test the information matrix ratio test is based on the expected Hessian matrix \eqn{\boldsymbol{H}(\theta)} and the expected outer product of the score function \eqn{\boldsymbol{C}(\theta)}. \cr Modified: pkg/man/RVinePar2Beta.Rd =================================================================== --- pkg/man/RVinePar2Beta.Rd 2013-10-17 13:14:59 UTC (rev 32) +++ pkg/man/RVinePar2Beta.Rd 2013-10-18 11:36:53 UTC (rev 33) @@ -1,51 +1,52 @@ -\name{RVinePar2Beta} -\alias{RVinePar2Beta} - -\title{Blomqvist's beta values of an R-vine copula model} - -\description{ -This function computes the values of Blomqvist's beta corresponding to the parameters of an R-vine copula model. -} - -\usage{ -RVinePar2Beta(RVM) -} - -\arguments{ - \item{RVM}{An \code{\link{RVineMatrix}} object.} -} - -\value{ -Matrix with the same structure as the family and parameter matrices of the \code{\link{RVineMatrix}} object \code{RVM} where the entries -are values of Blomqvist's beta corresponding to the families and parameters of the R-vine copula model given by \code{RVM}. -} - -\author{Jeffrey Dissmann} - -\seealso{\code{\link{RVineMatrix}}, \code{\link{BiCopPar2Beta}}} - -\examples{ -# define 5-dimensional R-vine tree structure matrix -Matrix = c(5,2,3,1,4,0,2,3,4,1,0,0,3,4,1,0,0,0,4,1,0,0,0,0,1) -Matrix = matrix(Matrix,5,5) - -# define R-vine pair-copula family matrix -family = c(0,1,3,4,4,0,0,3,4,1,0,0,0,4,1,0,0,0,0,3,0,0,0,0,0) -family = matrix(family,5,5) - -# define R-vine pair-copula parameter matrix -par = c(0,0.2,0.9,1.5,3.9,0,0,1.1,1.6,0.9,0,0,0,1.9,0.5, - 0,0,0,0,4.8,0,0,0,0,0) -par = matrix(par,5,5) - -# define second R-vine pair-copula parameter matrix -par2 = matrix(0,5,5) - -# define RVineMatrix object -RVM = RVineMatrix(Matrix=Matrix,family=family,par=par,par2=par2, - names=c("V1","V2","V3","V4","V5")) - -# compute the Blomqvist's beta values -BlomBeta = RVinePar2Beta(RVM) -} - +\name{RVinePar2Beta} +\alias{RVinePar2Beta} + +\title{Blomqvist's beta values of an R-vine copula model} + +\description{ +This function computes the values of Blomqvist's beta corresponding to the parameters of an R-vine copula model. +} + +\usage{ +RVinePar2Beta(RVM) +} + +\arguments{ + \item{RVM}{An \code{\link{RVineMatrix}} object. \cr + Note that the Student's t-copula is not allowed since the CDF of the t-copula is not implemented (see \code{\link{BiCopCDF}} and \code{\link{BiCopPar2Beta}}).} +} + +\value{ +Matrix with the same structure as the family and parameter matrices of the \code{\link{RVineMatrix}} object \code{RVM} where the entries +are values of Blomqvist's beta corresponding to the families and parameters of the R-vine copula model given by \code{RVM}. +} + +\author{Ulf Schepsmeier} + +\seealso{\code{\link{RVineMatrix}}, \code{\link{BiCopPar2Beta}}} + +\examples{ +# define 5-dimensional R-vine tree structure matrix +Matrix = c(5,2,3,1,4,0,2,3,4,1,0,0,3,4,1,0,0,0,4,1,0,0,0,0,1) +Matrix = matrix(Matrix,5,5) + +# define R-vine pair-copula family matrix +family = c(0,1,3,4,4,0,0,3,4,1,0,0,0,4,1,0,0,0,0,3,0,0,0,0,0) +family = matrix(family,5,5) + +# define R-vine pair-copula parameter matrix +par = c(0,0.2,0.9,1.5,3.9,0,0,1.1,1.6,0.9,0,0,0,1.9,0.5, + 0,0,0,0,4.8,0,0,0,0,0) +par = matrix(par,5,5) + +# define second R-vine pair-copula parameter matrix +par2 = matrix(0,5,5) + +# define RVineMatrix object +RVM = RVineMatrix(Matrix=Matrix,family=family,par=par,par2=par2, + names=c("V1","V2","V3","V4","V5")) + +# compute the Blomqvist's beta values +BlomBeta = RVinePar2Beta(RVM) +} + Modified: pkg/man/RVineStructureSelect.Rd =================================================================== --- pkg/man/RVineStructureSelect.Rd 2013-10-17 13:14:59 UTC (rev 32) +++ pkg/man/RVineStructureSelect.Rd 2013-10-18 11:36:53 UTC (rev 33) @@ -50,7 +50,15 @@ \code{37} = rotated BB1 copula (270 degrees) \cr \code{38} = rotated BB6 copula (270 degrees) \cr \code{39} = rotated BB7 copula (270 degrees) \cr - \code{40} = rotated BB8 copula (270 degrees) + \code{40} = rotated BB8 copula (270 degrees) \cr + \code{104} = Tawn type 1 copula \cr + \code{114} = rotated Tawn type 1 copula (180 degrees) \cr + \code{124} = rotated Tawn type 1 copula (90 degrees) \cr + \code{134} = rotated Tawn type 1 copula (270 degrees) \cr + \code{204} = Tawn type 2 copula \cr + \code{214} = rotated Tawn type 2 copula (180 degrees) \cr + \code{224} = rotated Tawn type 2 copula (90 degrees) \cr + \code{234} = rotated Tawn type 2 copula (270 degrees) \cr } \item{type}{Type of the vine model to be specified:\cr \code{0} or \code{"RVine"} = R-vine (default)\cr Modified: pkg/man/RvineMatrixCheck.Rd =================================================================== --- pkg/man/RvineMatrixCheck.Rd 2013-10-17 13:14:59 UTC (rev 32) +++ pkg/man/RvineMatrixCheck.Rd 2013-10-18 11:36:53 UTC (rev 33) @@ -12,7 +12,7 @@ \arguments{ \item{M}{A dxd vine matrix: only lower triangle is used; -For the check, M is assumed to be in natural order, i.e. 1:d on diagonal. +For the check, M is assumed to be in natural order, i.e. d:1 on diagonal. Further M[j-1,j]=j-1 and M[j,j]=j } } Modified: pkg.pdf =================================================================== --- pkg.pdf 2013-10-17 13:14:59 UTC (rev 32) +++ pkg.pdf 2013-10-18 11:36:53 UTC (rev 33) @@ -310,13 +310,11 @@ stream xYr6+4x|tLc+qSOfv0 KIB!!ݯ/@4h! 88` `pzz8  1 -W$q"8"8a5[i)aJ\oJ;m'ء1H4q2[CJ^Am`GՅ,Ʊ8bm (bD5ߝfb -RBisB -qwHpSU"gSWu@WzqCa^8M+d=I|xQGv3?Ͳ0 !y,!3iѫFcVM(^:<ۊ 8c׆ -P__[Uc֌ն{|Uvy qla86ȭ:gVGӣ ҳe`Rkc{?@_`3uю!@Q)|+r;_YݨZ6e֫-P咷 Q̦b~ZfJFǬVdp:YֆFnDM+_<*3,w=]d3f6E7oץl͝Y0lլkE[5?3bt)r{ʙ \ -׭j64,LLs>kCrP+ӆZi2P}.Q 7iИm?= ->͘[\sqa7<yi}2{cp'?ɸCWBACtxN{!Mϣ|G ZqH|9q(尧~E_CKվ G_Or -O?t6[BOB'|49'xŽ,ޔ`tB?ceñYl{S at 1?M^ S +W$q"8"8a5[i)aJ\oJ;m'ء1H4q2[CJ^A c )Ycc)Dq0QJ4&wk;3'> +sf( %J'B"Ļ+DDJx܁(Fh[yf;a>p›Vz,>-fL=e +aBXBfҖWSFd3Qһtx_q{Ǯ +$C'ƬmbuZixɛqm[uD􇏦G @g8(~jS/6g| 6B}oCR'W@kw|ՍeSX6lyuY.ylA]<)M/jv*hnjpzڼkHIvh ӚhmiF=Թq)klw;:JrӥMv: nX+m#^t㸉v]ʆ)ٛS̶XʻV/U33#6H..woIͅ~~ݪfMs4Jp3ѸV:$ Z?mxţ,]=Lԅ8nEltTŖXZ^_FGT;hV\Kk4[lK^n +^8dz~ +wcS jJ͞L1<@le9\zOCEv11p;BÉY_ۡnܶ>5F#-:-di/ghjG6qcd7LbT(Sh֝ED1gG^H:")[BIC@<7#%8+&'oe}oPCӣcьkEx;g֌~C'7wrs{<{<}%.>}t9dO'74><ʧ|}ܟ;RX{W>$AT;pd!'@tM`%$9$1|"χ+M{m] y L ;M Fȟ/83V]L 8:[G1` tkѿWZ endstream endobj 202 0 obj << @@ -442,23 +440,23 @@ /ProcSet [ /PDF /Text ] >> endobj 280 0 obj << -/Length 1372 +/Length 1371 /Filter /FlateDecode >> stream -xKw6,Bx,;I3g2'&J4;6HHHB߽\] Yf% KBZG#AhE!(*l|]}8 ΃&T= - ->/m-K#fH7%'T@$s5ˢ)q)' I ؅ت䭊~YwnL7Ϫ.{ ;? -(zp'Ou|j -;nG(dWNl&:na=u0u뀙Fw#/.8 - '/yqIb$0 UbG!=GX}m ʼnݖ;Jey](Ҽx&mO셒u. rE3ֺZ;~*muQ]y_n7~\ä,;Ⱦz"{P " WV7@IGZoKVpH#O~xw{j +xKw6,Bx,;I3g2g:t +( i_+$;6HHHB߽\] Yf% KBZ;G#AhE!(*pv =L"{"[|^nۜ[>{.͐nMK.N(H$U=j +ESRDmOA@ yU[r51A60gػr"0HoG 3 +cGcWxGqؓ_wbCT,88!=׵`a?|laM%\w"Dhk>oHS?ՆnM# 81ixḱ4MbMFx2{Abl1θc~ڧ$Gze<ɉ0¯\Njn  ƅ7bǏ&*cs$#r}~ٌ"\> +/A << /S /GoTo /D (page.65) >> >> endobj 261 0 obj << /Type /Annot @@ -613,8 +611,8 @@ /Type /Annot /Subtype /Link /Border[0 0 0]/H/I/C[1 0 0] -/Rect [501.13 492.371 513.085 501.217] -/A << /S /GoTo /D (page.68) >> +/Rect [501.13 492.251 513.085 501.217] +/A << /S /GoTo /D (page.69) >> >> endobj 263 0 obj << /Type /Annot @@ -705,7 +703,7 @@ /Subtype /Link /Border[0 0 0]/H/I/C[1 0 0] /Rect [501.13 336.834 513.085 345.8] -/A << /S /GoTo /D (page.89) >> +/A << /S /GoTo /D (page.90) >> >> endobj 276 0 obj << /Type /Annot @@ -751,11 +749,11 @@ FA @^IH,͎C yى@ʊ >z(_!/.t/$0R:OU]*DzؘfO^&aQ:7>D\uqXsek*4$ :P)9-3bk%ϱY \`R=&>]w+MITXWs!alLj\T"@6ui(M4Y$+HBa8й6 "!mlo7ݽM*j]ꨮ"'m04x=I._/q=}S !^fLjP9q׫2Ýo%=Hޣ;rg!w (I4:^ۋNjP~NrQ4' -9H~G/ Dm'Ƕ=~@K,'Х~?rp}_ wya쩢ȏdnו=UvוĽpZ +9H~G/ Gm'Ƕ=~@K,'Х~?rp}_ wya쩢ȏdnו=UvוĽpZ ]!Ym̾,b/WK#Qe4)| Ih][= nnM8Ufb?cstY{y_\@sG/y0sg>c)s:8;w’8 75/6" =qPm/EW8_]؅5#rE1?ÈcvU\L\:#*w{ -H}yK#~F_"n?̸>i#e{H%^1tD6G6د?_j[s +H}yK#~F_"n?̸>i#e{H%^1tD6G6د?_[[r endstream endobj 323 0 obj << @@ -781,7 +779,7 @@ /D [323 0 R /XYZ 100.346 510.652 null] >> endobj 333 0 obj << -/D [323 0 R /XYZ 100.346 279.09 null] +/D [323 0 R /XYZ 100.346 279.1 null] >> endobj 322 0 obj << /Font << /F43 281 0 R /F36 226 0 R /F35 225 0 R /F14 328 0 R /F8 329 0 R /F11 330 0 R /F22 227 0 R >> @@ -792,33 +790,27 @@ /Filter /FlateDecode >> stream -xYYsܸ~ӆSHvNy$yW.U$yS3ÿ~ -!ʲJ6/i}| -yG#ݫ7σ(sXG7# s@Gpy0"uE$]YK9V.Ǜ4$dTD3+cWWwzJۋ̣Q$L)ďeT >;U -^Mpy,wU Oİg3$}vWm'go_h #,31'd,FsQi/0M_|c4ߴ]8o`}6^zaB\7YY7JJșC7KD@3oDD%<f8bF?xрn -3%8 v|OƉөRC|Wxg[; -1@]EW'è uG mAG -MGu]+)̝Iě i7*psNcFBbQ[u"4seWN 5,X. ?i8ZZ's/X7GzpjnQ -]-p6kթ^ v"E740 -3]ݘ" i`UxB9OKRS7翨#y M^FCBɢrzOCY.H!]CbL+$7DQP@*kѲZę]"ZW9e6e95NG5$2UR$ʒlU*d )Үx0LM1MF`f -c`]4=NDd.fh"N ߬v5Q%a2W)wZyo(\-g8ˈGbp4Sa~ ;xB7K6nsݝ. -3q`ΰ!|IE -LloO-$}~{;(u˖Rr:תښc0mݱEn I~[xRK-YX(lQ+(%2m' -=$d -\๹5eSީfm -?T\rUN*UlFRdpה#g&ni~R.$-(mM?fI/t~`(s}/"/+)3LN1A2)ΕVkգǡ󮗖r.b\pL 6BE`lCH[T~ 4FȤu^0eTYBgZMayހe6^}ѠIty?VeIulurN5'ٲY&r4VrZHX֖Oerx ;}dʎ'MkU(qTJ}!L"<ڪn&C\P|^CpnZ-逛膞p. zL]{ gC٪-ME˷ -֯VUзJŀgڿkPe\0F}]:e˸5icQCF/Uj&3TSu/b ӏRm:Ҿҩ&C v@ܗ#jcQ`Bmpj{=rP(V!y{Њzmx n˝؅.~ -X=<bgv.y֑UhrDHp&TsGXL({vr^զ o[2Yӣ^wG`ik!>>`b՞_ĮͿD87 \c2DZQ -|+Ҡh^v$8 48l9_L *! @3N!1ᄁ iͫ_ +xYYo6~_᧬EΞ= +lOy`KZjbՇ干.}1Ru*:8= +^xuPf ScY~%gjh6CUܩ[{f;e&00IHr.^exJ=M=="ڿ8eʔRDݶZw(ήRF~g(D{9?K-O$!vU)OS`3y=ݓ/yz4ED << q^Xn۽a^4uLѪ_1x $ѬۡVI~^h? V9\imuiԷ`TzժuKmh%Lc]Z{ߨimT4u<)|7CG))ĩc`5˟uѓF`yh/t{!f zO@Y.?H]c +L+$7DQP@575ޕ b΢ksj,jH})2UQ$t/.U ).yL5M[3MF`f-c`n]4wOy'(Uw7Mf4qJoNQ[K0YjH`FMyo$}-:˄GFrt4Sa"heE~pϗy+c5 Gݴ +.a"uKR0ԓޞZY?"w&."V-:M1u5OFqaSi L$DŽn2.oQe;j%bPD&vòU۸Abk3 27KeǕrpzZ)&3#T"|й*޿V~y( +XY΀-3B‡Tk +}z0L!dhpH_zS][b dU{'6+_9"O>8P,07hy[*سz$rѬ7jxd_o h=5xUaCj+F2}`ImvBvX&r:Nr:HXΕOerx +;}dʞ'm2k]jqTJ}&b<ڪi&c +sAhAND7 Fh7zp6F~_ZԴ|<`̯tKsLjU 8ZKQƥAPkDu o}; >̠b,~bɑwޚ[uɌD앺#Db=ȩX2 EGU:|(7vD-|7L +N|G5+UHgsQm[%%er[Wh*#V"N.piN$+ +#Y%t#պL +A$ـI $tOuLYî^l$QچTG>[\ +6Nj،-n*`@#дPt +f)COF1ǔ`T:Aj wKVdGi>NqY +PaA ͊VIҶJKf;5ϧau><*vcx sL)k;[LX8/H#{4`Єp0Eck][$l[#iLml={+r3ΰb&PJ=vHR264l@_ϙEo;L,5lu/8j!q~GHwUo=>b țҦO-K}\Qj? e|_Y'ď=$ccp/1a;9A$ZTڈTFm|/mCp<צ %=Q~OzB48pУ4@X/^7B;+D34};G`νK7X < ĹɁ 0qFLĚ;ΧD# KzXw׽Uf6&"}`roml_{-vޞ ˢ-DKU{Ǐ]czV9`ށ_R0{"6Ҳ" +H `s;H:oVp +x>2<:u$ XÄbӠFh^v$8 88_,l۩1 @3N!1ᄁ y-_ endstream endobj 338 0 obj << @@ -832,41 +824,41 @@ 334 0 obj << /Type /Annot /Border[0 0 0]/H/I/C[0 1 1] -/Rect [396.522 229.332 513.085 240.236] +/Rect [396.522 229.331 513.085 240.235] /Subtype/Link/A<> >> endobj 345 0 obj << /Type /Annot /Border[0 0 0]/H/I/C[0 1 1] -/Rect [117.35 219.085 209.006 228.092] +/Rect [117.35 219.114 209.006 228.08] /Subtype/Link/A<> >> endobj 335 0 obj << /Type /Annot /Border[0 0 0]/H/I/C[0 1 1] -/Rect [406.485 189.421 513.085 200.325] +/Rect [406.485 189.42 513.085 200.364] /Subtype/Link/A<> >> endobj 346 0 obj << /Type /Annot /Border[0 0 0]/H/I/C[0 1 1] -/Rect [117.35 177.889 179.119 188.18] +/Rect [117.35 177.888 179.119 188.169] /Subtype/Link/A<> >> endobj 340 0 obj << /D [338 0 R /XYZ 99.346 773.487 null] >> endobj 341 0 obj << -/D [338 0 R /XYZ 100.346 642.803 null] +/D [338 0 R /XYZ 100.346 642.794 null] >> endobj 342 0 obj << -/D [338 0 R /XYZ 100.346 525.641 null] +/D [338 0 R /XYZ 100.346 525.634 null] >> endobj 343 0 obj << -/D [338 0 R /XYZ 100.346 432.389 null] +/D [338 0 R /XYZ 100.346 432.384 null] >> endobj 344 0 obj << -/D [338 0 R /XYZ 100.346 386.959 null] +/D [338 0 R /XYZ 100.346 386.955 null] >> endobj 337 0 obj << /Font << /F36 226 0 R /F43 281 0 R /F8 329 0 R /F14 328 0 R /F11 330 0 R /F35 225 0 R /F22 227 0 R >> @@ -906,7 +898,7 @@ 336 0 obj << /Type /Annot /Border[0 0 0]/H/I/C[0 1 1] -/Rect [178.769 717.945 384.996 728.365] +/Rect [178.769 717.955 384.996 728.365] /Subtype/Link/A<> >> endobj 347 0 obj << @@ -924,13 +916,13 @@ 354 0 obj << /Type /Annot /Border[0 0 0]/H/I/C[0 1 1] -/Rect [117.35 499.698 243.876 509.989] +/Rect [117.35 499.698 243.876 509.979] /Subtype/Link/A<> >> endobj 349 0 obj << /Type /Annot /Border[0 0 0]/H/I/C[0 1 1] -/Rect [117.35 470.93 268.782 481.221] +/Rect [117.35 470.93 268.782 481.211] /Subtype/Link/A<> >> endobj 350 0 obj << @@ -968,20 +960,21 @@ /ProcSet [ /PDF /Text ] >> endobj 366 0 obj << -/Length 1192 +/Length 1221 /Filter /FlateDecode >> stream -xڵWIo6W2kHJ9d 0mɁ[GK}ԣKFVҋ)Rnki|:tr+tBθ5}(!q+]fM֝ӯ<%r"EҒ#bo]4w&,ЇxF=|Lҹ*:[8šPpaTYx|a_;zwV -G.)z Dɢe.Z M3U>+e.cJ 7LYOc2,VE-+q2.6jD0kB>M+2X] 0 -5 xm}'$U\8jFo<*J<[T2I:U, #Σt 3^/D -J!Y\d{J8ot;Yyi ?GSQh%w;[t:'ٌ͂oEkF+mB}'0^̷]&tDj"a;rw8:^x0{jwQ -GSYE$cTKܞ*.b̆hQ%3PTpO{'9A7:= @ &;g^WWAׇZ.Eukʕ*~7sՋ"xo=>؛} U>v׃A}hb oѼÁ˛ŇGbK}> +xڵWKo6W2k)9Y`M%c3P==PC)ge%"5EE/Ӆǭ 9r q<ƭ5_Z76ο~`^GENlsv~%'Ĩ~ʬ3>ěW^SW*]wQX3W8\q<?No^lS?sYAyҺ˜#xMmƘ [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/vinecopula -r 33 From noreply at r-forge.r-project.org Fri Oct 18 16:15:52 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 18 Oct 2013 16:15:52 +0200 (CEST) Subject: [Vinecopula-commits] r34 - in pkg: R man Message-ID: <20131018141553.12AD618446A@r-forge.r-project.org> Author: ulf Date: 2013-10-18 16:15:51 +0200 (Fri, 18 Oct 2013) New Revision: 34 Modified: pkg/R/RVineMLE.R pkg/man/RvineMatrixCheck.Rd Log: Noch ein Fehler in der RVineMLE.R fuer Tawn. Ferner war die Dokumentation von RVineMatrixCheck nicht konsistent. Danke Tobias. @Eike: Wenn du nach deiner Verteidigung mal wieder Zeit hast koenntest du da mal einen Blick drauf werfen? Ich bin mir immer noch nicht sicher mit den Permutationssachen (code=-2). Modified: pkg/R/RVineMLE.R =================================================================== --- pkg/R/RVineMLE.R 2013-10-18 11:36:53 UTC (rev 33) +++ pkg/R/RVineMLE.R 2013-10-18 14:15:51 UTC (rev 34) @@ -51,6 +51,15 @@ if ((RVM$family[i,j]==104 || RVM$family[i,j]==114 || RVM$family[i,j]==204 || RVM$family[i,j]==214) && (start2[i,j]<0 || start2[i,j]>1)) stop("Please choose 'par2' of the Tawn copula in [0,1].") if ((RVM$family[i,j]==124 || RVM$family[i,j]==134 || RVM$family[i,j]==224 || RVM$family[i,j]==234) && start[i,j]>-1) stop("Please choose 'par' of the Tawn copula in (-oo,-1].") if ((RVM$family[i,j]==124 || RVM$family[i,j]==134 || RVM$family[i,j]==224 || RVM$family[i,j]==234) && (start2[i,j]<0 || start2[i,j]>1)) stop("Please choose 'par2' of the Tawn copula in [0,1].") + + if(grad==TRUE) + { + if(RVM$family[i,j]%in%c(7:10,17:20,27:30,37:40,104,114,124,134,204,214,224,234)) + { + message("The combination 'grad=TRUE' and a copula family of the vector (7:10,17:20,27:30,37:40,104,114,124,134,204,214,224,234) is not possible. The algorithm will continue with 'grad=FALSE'.") + grad=FALSE + } + } } } } @@ -154,7 +163,7 @@ }else if(Copula.Types[i] %in% c(43,44)){ #double Clayton, Gumbel lb[i] = -0.9999 ub[i] = 0.9999 - }else if(Copula.Types[i] %in% c(104,114,2014,214)){ #Tawn + }else if(Copula.Types[i] %in% c(104,114,204,214)){ #Tawn lb[i] = 1.001 ub[i] = 20 }else if(Copula.Types[i] %in% c(124,134,224,234)){ #Tawn @@ -167,41 +176,39 @@ if(nParams2 > 0){ todo = which(Copula.Types %in% c(2,7:10,17:20,27:30,37:40,104,114,124,134,204,214,224,234)) - for(i in 1:nParams2){ - if(Copula.Types[todo[i]]==2){ #t - lb[nParams+i] = 2.001 - ub[nParams+i] = max.df - }else if(Copula.Types[todo[i]] %in% c(7,17)){ #bb1 - lb[nParams+i] = 1.001 - ub[nParams+i] = max.BB$BB1[2] - }else if(Copula.Types[todo[i]] %in% c(8,18)){ #bb6 - lb[nParams+i] = 1.001 - ub[nParams+i] = max.BB$BB6[2] - }else if(Copula.Types[todo[i]] %in% c(9,19)){ #bb7 - lb[nParams+i] = 0.001 - ub[nParams+i] = max.BB$BB7[2] - }else if(Copula.Types[todo[i]] %in% c(10,20)){ #bb8 - lb[nParams+i] = 0.001 - ub[nParams+i] = max.BB$BB1[2] - }else if(Copula.Types[todo[i]] %in% c(27,37)){ #rotated bb1 - lb[nParams+i] = -max.BB$BB1[2] - ub[nParams+i] = -1.001 - }else if(Copula.Types[todo[i]] %in% c(28,38)){ #rotated bb6 - lb[nParams+i] = -max.BB$BB6[2] - ub[nParams+i] = -1.001 - }else if(Copula.Types[todo[i]] %in% c(29,39)){ #rotated bb7 - lb[nParams+i] = -max.BB$BB7[2] - ub[nParams+i] = -1.001 - }else if(Copula.Types[todo[i]] %in% c(30,40)){ #rotated bb8 - lb[nParams+i] = -max.BB$BB8[2] - ub[nParams+i] = -0.001 - }else if(Copula.Types[i] %in% c(104,114,2014,214)){ #Tawn - lb[nParams+i] = 0.001 - ub[nParams+i] = 0.99 - }else if(Copula.Types[i] %in% c(124,134,224,234)){ #Tawn - lb[nParams+i] = -0.99 - ub[nParams+i] = -0.001 - } + for(i in 1:nParams2) + { + if(Copula.Types[todo[i]]==2){ #t + lb[nParams+i] = 2.001 + ub[nParams+i] = max.df + }else if(Copula.Types[todo[i]] %in% c(7,17)){ #bb1 + lb[nParams+i] = 1.001 + ub[nParams+i] = max.BB$BB1[2] + }else if(Copula.Types[todo[i]] %in% c(8,18)){ #bb6 + lb[nParams+i] = 1.001 + ub[nParams+i] = max.BB$BB6[2] + }else if(Copula.Types[todo[i]] %in% c(9,19)){ #bb7 + lb[nParams+i] = 0.001 + ub[nParams+i] = max.BB$BB7[2] + }else if(Copula.Types[todo[i]] %in% c(10,20)){ #bb8 + lb[nParams+i] = 0.001 + ub[nParams+i] = max.BB$BB1[2] + }else if(Copula.Types[todo[i]] %in% c(27,37)){ #rotated bb1 + lb[nParams+i] = -max.BB$BB1[2] + ub[nParams+i] = -1.001 + }else if(Copula.Types[todo[i]] %in% c(28,38)){ #rotated bb6 + lb[nParams+i] = -max.BB$BB6[2] + ub[nParams+i] = -1.001 + }else if(Copula.Types[todo[i]] %in% c(29,39)){ #rotated bb7 + lb[nParams+i] = -max.BB$BB7[2] + ub[nParams+i] = -1.001 + }else if(Copula.Types[todo[i]] %in% c(30,40)){ #rotated bb8 + lb[nParams+i] = -max.BB$BB8[2] + ub[nParams+i] = -0.001 + }else if(Copula.Types[i] %in% c(104,114,124,134,204,214,224,234)){ #Tawn + lb[nParams+i] = 0.001 + ub[nParams+i] = 0.99 + } } } @@ -294,9 +301,14 @@ { pscale[i] = ifelse(Copula.Types[i] %in% c(1,2,43,44), 0.01, 1) } - pscale=c(pscale,rep(1,nParams2)) + pscale2=numeric() + for(i in 1:nParams2) + { + pscale2[i] = ifelse(Copula.Types[i] %in% c(104,114,124,134,204,214,224,234), 0.05, 1) + } + pscale=c(pscale,pscale2) - if(!exists("factr")) # Toleranz etwas hoch setzen (grber) + if(!exists("factr")) # Toleranz etwas hoch setzen (groeber) factr=1e8 if(all(Copula.Types %in% c(0,1,2,3:6,13,14,16,23,24,26,33,34,36,43,44)) && grad==TRUE) @@ -332,6 +344,12 @@ } else { + #print("startpar1") + #print(startpar1) + #print("lower") + #print(lb) + #print("upper") + #print(ub) out1 = optim(par=startpar1,fn=optim_LL, data=data,posParams=posParams,posParams2=posParams2,Copula.Types=Copula.Types,start=start,start2=start2,RVM=RVM, calcupdate=NA, method="L-BFGS-B",control=list(fnscale=-1,maxit=maxit,trace=1,parscale=pscale,factr=factr,...),lower=lb,upper=ub) Modified: pkg/man/RvineMatrixCheck.Rd =================================================================== --- pkg/man/RvineMatrixCheck.Rd 2013-10-18 11:36:53 UTC (rev 33) +++ pkg/man/RvineMatrixCheck.Rd 2013-10-18 14:15:51 UTC (rev 34) @@ -13,21 +13,21 @@ \arguments{ \item{M}{A dxd vine matrix: only lower triangle is used; For the check, M is assumed to be in natural order, i.e. d:1 on diagonal. -Further M[j-1,j]=j-1 and M[j,j]=j +Further M[j+1,j]=d-j and M[j,j]=d-j } } \value{ \item{code}{ \code{1} for OK; \cr - \code{-3} diagonal can not be put in order 1:d; \cr - \code{-2} for not permutation of 1:j in column d-j; \cr + \code{-3} diagonal can not be put in order d:1; \cr + \code{-2} for not permutation of j:d in column d-j; \cr \code{-1} if cannot find proper binary array from array in natural order. } } \note{ -The matrix M do not have to be given in natural order or the diagonal in order 1:d. The test checks if it can be done in order to be a valid R-vine matrix. \cr +The matrix M do not have to be given in natural order or the diagonal in order d:1. The test checks if it can be done in order to be a valid R-vine matrix. \cr If a function in this package needs the natural order the \code{RVineMatrix} object is automatically "normalized". \cr The function \code{\link{RVineMatrix}} automatically checks if the given R-vine matrix is valid. } From noreply at r-forge.r-project.org Wed Oct 30 09:24:34 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 30 Oct 2013 09:24:34 +0100 (CET) Subject: [Vinecopula-commits] r35 - pkg/R Message-ID: <20131030082434.DE4CC1861B8@r-forge.r-project.org> Author: ulf Date: 2013-10-30 09:24:34 +0100 (Wed, 30 Oct 2013) New Revision: 35 Modified: pkg/R/RVineStructureSelect.r Log: An einer Stelle hatte ich noch vergessen die neuen Copulas einzufuegen. Modified: pkg/R/RVineStructureSelect.r =================================================================== --- pkg/R/RVineStructureSelect.r 2013-10-18 14:15:51 UTC (rev 34) +++ pkg/R/RVineStructureSelect.r 2013-10-30 08:24:34 UTC (rev 35) @@ -368,11 +368,11 @@ { out=BiCopSelect(u1,u2,familyset,selectioncrit,indeptest,level,weights=weights) - if(out$family%in%c(23,24,26:30)) + if(out$family%in%c(23,24,26:30,124,224)) { out$family=out$family+10 } - else if(out$family%in%c(33,34,36:40)) + else if(out$family%in%c(33,34,36:40,134,234)) { out$family=out$family-10 } From noreply at r-forge.r-project.org Wed Oct 30 10:32:44 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 30 Oct 2013 10:32:44 +0100 (CET) Subject: [Vinecopula-commits] r36 - in pkg: R src Message-ID: <20131030093244.CC5DB18431D@r-forge.r-project.org> Author: ulf Date: 2013-10-30 10:32:41 +0100 (Wed, 30 Oct 2013) New Revision: 36 Modified: pkg/R/BiCopSelect.r pkg/R/RVineStructureSelect.r pkg/src/hfunc.c Log: Tobias und ich haben noch eine Fehler bei Tawn gefunden. In der Hfunc.c hatte sich bei den rotierten Versionen ein Fehler eingeschlichen durch Copy und paste. Modified: pkg/R/BiCopSelect.r =================================================================== --- pkg/R/BiCopSelect.r 2013-10-30 08:24:34 UTC (rev 35) +++ pkg/R/BiCopSelect.r 2013-10-30 09:32:41 UTC (rev 36) @@ -25,6 +25,7 @@ if(!is.na(familyset[1]) && (!any(c(1,2,5,23,24,26:30,33,34,36:40,104,114,204,214) %in% familyset) || !any(c(1:10,13,14,16:20,124,134,224,234) %in% familyset))) stop("'familyset' has to include at least one bivariate copula family for positive and one for negative dependence.") emp_tau = fasttau(data1,data2,weights) + if(indeptest == TRUE){ out$p.value.indeptest = BiCopIndTest(data1,data2)$p.value Modified: pkg/R/RVineStructureSelect.r =================================================================== --- pkg/R/RVineStructureSelect.r 2013-10-30 08:24:34 UTC (rev 35) +++ pkg/R/RVineStructureSelect.r 2013-10-30 09:32:41 UTC (rev 36) @@ -30,6 +30,7 @@ RVine$Tree[[1]] = VineTree RVine$Graph[[1]] = g oldVineGraph = VineTree + for(i in 2:(n-1)){ Modified: pkg/src/hfunc.c =================================================================== --- pkg/src/hfunc.c 2013-10-30 08:24:34 UTC (rev 35) +++ pkg/src/hfunc.c 2013-10-30 09:32:41 UTC (rev 36) @@ -1,1273 +1,1273 @@ -/* -** hfunc.c - C code of the package CDRVine -** -** with contributions from Carlos Almeida, Aleksey Min, -** Ulf Schepsmeier, Jakob Stoeber and Eike Brechmann -** -** A first version was based on code -** from Daniel Berg -** provided by personal communication. -** -*/ - -#include "include/vine.h" -#include "include/hfunc.h" -#include "include/evCopula.h" - -#define UMAX 1-1e-10 - -#define UMIN 1e-10 - -#define XEPS 1e-4 - - -// h-func for BB1 - -void pcondbb1(double* u, double* v, int* n, double* param, double* out) -{ - int i; - double th, de; - double t1, t2, t3, t16, t17, t4, t5, t6, t7, t9, t10, t12, t13, t20; - - th = param[0]; - de = param[1]; - for(i=0;i<*n;i++) - { - t1 = pow(u[i],-th); - t2 = t1-1.; - t3 = pow(t2,de); - t16 = 1./u[i]; - t17 = 1./t2; - t4 = pow(v[i],-th); - t5 = t4-1.; - t6 = pow(t5,de); - t7 = t3+t6; - t9 = pow(t7,1/de); - t10 = 1.0+t9; - t12 = pow(t10,-1/th); - t13 = t12*t9; - t20 = 1./t10; - out[i] = t13*t3*t1*t16*t17/t7*t20; - } - -} - - - -void pcondbb6(double* u, double* v, int* n, double* param, double* out) -{ - int i; - double th, de; - double t1, t2, t3, t4, t5, t12, t16, t6, t7, t8, t9, t10, t11, t13, t14, t15, t17; - - th = param[0]; - de = param[1]; - - for(i=0;i<*n;i++) - { - t1 = 1.0-u[i]; - t2 = pow(t1,th); - t3 = 1.0-t2; - t4 = log(t3); - t5 = pow(-t4,de); - t12 = 1/de; - t16 = 1/th; - t6 = 1.0-v[i]; - t7 = pow(t6,th); - t8 = 1.0-t7; - t9 = log(t8); - t10 = pow(-t9,de); - t11 = t5+t10; - t13 = pow(t11,t12); - t14 = exp(-t13); - t15 = 1.0-t14; - t17 = pow(t15,t16); - - out[i] = -t17*t13*t5*t2/t1/t3/t4/t11*t14/t15; - } - -} - - -void pcondbb7(double* u, double* v, int* n, double* param, double* out) -{ - int i; - double th, de; - double t1, t2, t3, t4, t6, t8, t9, t11, t12, t14; - - th = param[0]; - de = param[1]; - - for(i=0;i<*n;i++) - { - t1 = 1.0-u[i]; - t2 = pow(t1,1.0*th); - t3 = 1.0-t2; - t4 = pow(t3,-1.0*de); - t6 = pow(1.0-v[i],1.0*th); - t8 = pow(1.0-t6,-1.0*de); - t9 = t4+t8-1.0; - t11 = pow(t9,-1.0/de); - t12 = 1.0-t11; - t14 = pow(t12,1.0/th); - - out[i] = t14*t11*t4*t2/t1/t3/t9/t12; - } - -} - - -void pcondbb8(double* u, double* v, int* n, double* param, double* out) -{ - int i; - double th, de; - double t2, t3, t12, t16, t6, t7, t8, t10, t11, t13, t15, t17; - - th = param[0]; - de = param[1]; - - for(i=0;i<*n;i++) - { - t2 = 1.0-de*u[i]; - t3 = pow(t2,th); - t10 = 1.0-de; - t11 = pow(t10,th); - t12 = 1.0-t11; - t13 = 1/t12; - t16 = 1/th; - t6 = 1.0-de*v[i]; - t7 = pow(t6,th); - t8 = 1.0-t7; - t15 = 1.0-(1.0-t3)*t8*t13; - t17 = pow(t15,t16); - - out[i] = t17*t3/t2*t8*t13/t15; - } - -} - - - - -// Since the h function is not symmetric in case of double Gumbel and double Clayton we have two implement both separately, -// i.e. Hfunc1 and Hfunc2 -void Hfunc1(int* family,int* n,double* u,double* v,double* theta,double* nu,double* out) -{ - double *negv, *negu; - negv = (double *) malloc(*n* sizeof(double)); - negu = (double *) malloc(*n*sizeof(double)); - double ntheta, nnu; - int nfamily, j, T=1; - ntheta = -*theta; - nnu = -*nu; - - for(int i=0;i<*n;i++) - { - if(u[i]UMAX) u[i]=UMAX; - if(v[i]UMAX) v[i]=UMAX; - } - - if((*family==43)) - { - nfamily=3; - if(*theta > 0){ - ntheta=2*(*theta)/(1-*theta); - Hfunc(&nfamily, n, u, v, &ntheta, &nnu, out); - }else{ - ntheta=-2*(*theta)/(1+*theta); - for (int i = 0; i < *n; ++i) {negv[i]=1 - v[i];} - Hfunc(&nfamily, n, u, negv, &ntheta, &nnu, out); - } - }else if((*family==44)) - { - nfamily=4; - if(*theta > 0){ - ntheta=1/(1-*theta); - Hfunc (&nfamily, n, u, v, &ntheta, &nnu, out); - }else{ - ntheta=1/(1+*theta); - for (int i = 0; i < *n; ++i) {negv[i]=1 - v[i];} - Hfunc (&nfamily, n, u, negv, &ntheta, &nnu, out); - } - }else{ - - if(((*family==23) | (*family==24) | (*family==26) | (*family==27) | (*family==28) | (*family==29) | (*family==30) | (*family==61) )) - { - nfamily=(*family)-20; - for (int i = 0; i < *n; ++i) {negv[i]=1 - v[i];} - Hfunc (&nfamily, n, u, negv, &ntheta, &nnu, out); - } - else if(((*family==33) | (*family==34) | (*family==36) | (*family==37) | (*family==38) | (*family==39) | (*family==40) | (*family==71) )) - { - nfamily=(*family)-30; - for (int i = 0; i < *n; ++i) {negu[i]=1 - u[i];} - Hfunc(&nfamily, n, negu, v, &ntheta, &nnu, out); - for (int i = 0; i < *n; i++) {out[i]=1-out[i];}; - } - else if(*family==104) - { - double par3=1; - dC_du(v,u,n,theta,nu,&par3,out); // u und v kommen aus BiCopHfunc vertauscht hier an. Dreh zurck. NOch testen, wie sich das auf die anderen Funktione auswirkt - } - else if(*family==114) - { - double par3=1; - for(j=0;j<*n;j++) - { - negv[j]= 1-v[j]; - negu[j]= 1-u[j]; - dC_dv(&negu[j],&negv[j],&T,theta,nu,&par3,&out[j]); - out[j]= 1-out[j]; - } - } - else if(*family==124) - { - double par3=1; - for(j=0;j<*n;j++) - { - negv[j]= 1-v[j]; - dC_dv(&u[j],&negv[j],&T,&ntheta,nu,&par3,&out[j]); - } - } - else if(*family==134) - { - double par3=1; - for(j=0;j<*n;j++) - { - negu[j]= 1-u[j]; - dC_dv(&negu[j],&v[j],&T,&ntheta,nu,&par3,&out[j]); - out[j]=1-out[j]; - } - } - else if(*family==204) - { - double par3=*nu; - double par2=1; - dC_du(v,u,n,theta,&par2,&par3,out); - } - else if(*family==214) - { - double par3=*nu; - double par2=1; - for(j=0;j<*n;j++) - { - negv[j]= 1-v[j]; - negu[j]= 1-u[j]; - dC_dv(&negu[j],&negv[j],&T,theta,&par2,&par3,&out[j]); - out[j]= 1-out[j]; - } - } - else if(*family==124) - { - double par3=*nu; - double par2=1; - for(j=0;j<*n;j++) - { - negv[j]= 1-v[j]; - dC_dv(&u[j],&negv[j],&T,&ntheta,&par2,&par3,&out[j]); - } - } - else if(*family==134) - { - double par3=*nu; - double par2=1; - for(j=0;j<*n;j++) - { - negu[j]= 1-u[j]; - dC_dv(&negu[j],&v[j],&T,&ntheta,&par2,&par3,&out[j]); - out[j]=1-out[j]; - } - } - else { - Hfunc (family, n, u, v, theta, nu, out); - } - } - free(negv); - free(negu); -} - -void Hfunc2(int* family,int* n,double* v,double* u,double* theta,double* nu,double* out) -{ - double *negv, *negu; - negv = (double *) malloc(*n * sizeof(double)); - negu = (double *) malloc(*n * sizeof(double)); - double ntheta, nnu; - int nfamily; - ntheta = -*theta; - nnu = -*nu; - - for(int i=0;i<*n;i++) - { - if(u[i]UMAX) u[i]=UMAX; - if(v[i]UMAX) v[i]=UMAX; - } - - if((*family==43)) - { - nfamily=3; - if(*theta > 0){ - ntheta=2*(*theta)/(1-*theta); - Hfunc (&nfamily, n, v, u, &ntheta, &nnu, out); - }else{ - ntheta=-2*(*theta)/(1+*theta); - for (int i = 0; i < *n; ++i) {negv[i]=1 - v[i];} - Hfunc(&nfamily, n, negv, u, &ntheta, &nnu, out); - for (int i = 0; i < *n; i++) {out[i]=1-out[i];}; - } - }else if((*family==44)) - { - nfamily=4; - if(*theta > 0){ - ntheta=1/(1-*theta); - Hfunc (&nfamily, n, v, u, &ntheta, &nnu, out); - }else{ - ntheta=1/(1+*theta); - for (int i = 0; i < *n; ++i) {negv[i]=1 - v[i];} - Hfunc(&nfamily, n, negv, u, &ntheta, &nnu, out); - for (int i = 0; i < *n; i++) {out[i]=1-out[i];}; } - }else{ - - if(((*family==23) | (*family==24) | (*family==26) | (*family==27) | (*family==28) | (*family==29) | (*family==30) | (*family==61) )) - { - nfamily=(*family)-20; - for (int i = 0; i < *n; ++i) {negv[i]=1 - v[i];} - Hfunc(&nfamily, n, negv, u, &ntheta, &nnu, out); - for (int i = 0; i < *n; i++) {out[i]=1-out[i];}; - } - else if(((*family==33) | (*family==34) | (*family==36) | (*family==37) | (*family==38) | (*family==39) | (*family==40) | (*family==71) )) - { - nfamily=(*family)-30; - for (int i = 0; i < *n; ++i) {negu[i]=1 - u[i];} - Hfunc(&nfamily, n, v, negu, &ntheta, &nnu, out); - } - // else if(*family==104 | *family==204 | *family==114 | *family==214) - // { - // u und v vertauschen (Unsauber, aber so sollte es funktionieren in unserer bisherigen Notation) - // Hfunc(family,n,u,v,theta,nu,out); - // } - else if((*family==124) | (*family==224)) - { - nfamily=(*family)-20; - for (int i = 0; i < *n; ++i) {negv[i]=1 - v[i];} - Hfunc(&nfamily, n, negv, u, &ntheta, nu, out); - for (int i = 0; i < *n; i++) {out[i]=1-out[i];}; - } - else if((*family==134) | (*family==234)) - { - nfamily=(*family)-30; - for (int i = 0; i < *n; ++i) {negu[i]=1 - u[i];} - Hfunc(&nfamily, n, v, negu, &ntheta, nu, out); - } - else - { - Hfunc(family, n, v, u, theta, nu, out); - } - } - free(negv); - free(negu); -} - - - -////////////////////////////////////////////////////////////// -// Function to compute h-function for vine simulation and estimation -// Input: -// family copula family (0=independent, 1=gaussian, 2=student, 3=clayton, 4=gumbel, 5=frank, 6=joe, 7=BB1, 8=BB7) -// n number of iterations -// u variable for which h-function computes conditional distribution function -// v variable on which h-function conditions -// theta parameter for the copula family -// nu degrees-of-freedom for the students copula -// out output -////////////////////////////////////////////////////////////// -void Hfunc(int* family, int* n, double* u, double* v, double* theta, double* nu, double* out) -{ - int j; - double *h; - h = Calloc(*n,double); - double x; - - /*for(int i=0;i<*n;i++) - { - if(u[i]UMAX) u[i]=UMAX; - if(v[i]UMAX) v[i]=UMAX; - }*/ -//Rprintf("family in Hfunc: %d\n", *family); -//Rprintf("theta=par1 in Hfunc: %f\n", *theta); -//Rprintf("nu=par2 in Hfunc: %f\n", *nu); - for(j=0;j<*n;j++) - { - if((v[j]==0) | ( u[j]==0)) h[j] = 0; - else if (v[j]==1) h[j] = u[j]; - else - { - if(*family==0) //independent - { - h[j] = u[j]; - } - else if(*family==1) //gaussian - { - x = (qnorm(u[j],0.0,1.0,1,0) - *theta*qnorm(v[j],0.0,1.0,1,0))/sqrt(1.0-pow(*theta,2.0)); - if (isfinite(x)) - h[j] = pnorm(x,0.0,1.0,1,0); - else if ((qnorm(u[j],0.0,1.0,1,0) - *theta*qnorm(v[j],0.0,1.0,1,0)) < 0) - h[j] = 0; - else - h[j] = 1; - } - else if(*family==2) //student - { - double t1, t2, mu, sigma2; - t1 = qt(u[j],*nu,1,0); t2 = qt(v[j],*nu,1,0); mu = *theta*t2; sigma2 = ((*nu+t2*t2)*(1.0-*theta*(*theta)))/(*nu+1.0); - h[j] = pt((t1-mu)/sqrt(sigma2),*nu+1.0,1,0); - } - else if(*family==3) //clayton - { - if(*theta == 0) h[j] = u[j] ; - if(*theta < XEPS) h[j] = u[j] ; - else - { - x = pow(u[j],-*theta)+pow(v[j],-*theta)-1.0 ; - h[j] = pow(v[j],-*theta-1.0)*pow(x,-1.0-1.0/(*theta)); - if(*theta < 0) - { - if(x < 0) h[j] = 0; - } - } - } - else if(*family==4) //gumbel - { - if(*theta == 1) h[j] = u[j] ; - else - { - h[j] = -(exp(-pow(pow(-log(v[j]),*theta)+pow(-log(u[j]),*theta),1.0/(*theta)))*pow(pow(-log(v[j]),*theta)+pow(-log(u[j]),*theta),1.0/(*theta)-1.0)*pow(-log(v[j]),*theta))/(v[j]*log(v[j])); - } - } - else if(*family==5) //frank - { - if(*theta==0) h[j]=u[j]; - else - { - h[j] = -(exp(*theta)*(exp(*theta*u[j])-1.0))/(exp(*theta*v[j]+*theta*u[j])-exp(*theta*v[j]+*theta)-exp(*theta*u[j]+*theta)+exp(*theta)); - } - } - else if(*family==6) //joe - { - if(*theta==1) h[j]=u[j]; - else - { - h[j] = pow(pow(1.0-u[j],*theta) + pow(1.0-v[j],*theta) - pow(1.0-u[j],*theta)*pow(1.0-v[j],*theta),1.0/(*theta)-1) * pow(1.0-v[j],*theta-1.0)*(1-pow(1-u[j],*theta)); - } - } - else if(*family==7) //BB1 - { - double* param; - param = Calloc(2,double); - param[0]=*theta; - param[1]=*nu; - int T=1; - if(*nu==1) - { - if(*theta==0) h[j]=u[j]; - else h[j]=pow(pow(u[j],-*theta)+pow(v[j],-*theta)-1,-1/(*theta)-1)*pow(v[j],-*theta-1); - } - else if(*theta==0) - { - h[j]=-(exp(-pow(pow(-log(v[j]),*nu)+pow(-log(u[j]),*nu),1.0/(*nu)))*pow(pow(-log(v[j]),*nu)+pow(-log(u[j]),*nu),1.0/(*nu)-1.0)*pow(-log(v[j]),*nu))/(v[j]*log(v[j])); - } - else - { - pcondbb1(&v[j],&u[j],&T,param,&h[j]); - } - Free(param); - } - else if(*family==8) //BB6 - { - double* param; - param = Calloc(2,double); - param[0]=*theta; - param[1]=*nu; - int T=1; - if(*theta==1) - { - if(*nu==1) h[j]=u[j]; - else h[j]=-(exp(-pow(pow(-log(v[j]),*nu)+pow(-log(u[j]),*nu),1.0/(*nu)))*pow(pow(-log(v[j]),*nu)+pow(-log(u[j]),*nu),1.0/(*nu)-1.0)*pow(-log(v[j]),*nu))/(v[j]*log(v[j])); - } - else if(*nu==1) - { - h[j]=pow(pow(1.0-u[j],*theta) + pow(1.0-v[j],*theta) - pow(1.0-u[j],*theta)*pow(1.0-v[j],*theta),1.0/(*theta)-1) * pow(1.0-v[j],*theta-1.0)*(1-pow(1-u[j],*theta)); - } - else - { - pcondbb6(&v[j],&u[j],&T,param,&h[j]); - } - Free(param); - } - else if(*family==9) //BB7 - { - double* param; - param = Calloc(2,double); - param[0]=*theta; - param[1]=*nu; - int T=1; - if(*theta==1) - { - if(*nu==0) h[j]=u[j]; - else h[j]=pow(pow(u[j],-*nu)+pow(v[j],-*nu)-1,-1/(*nu)-1)*pow(v[j],-*nu-1); - } - else if(*nu==0) - { - h[j] = pow(pow(1.0-u[j],*theta) + pow(1.0-v[j],*theta) - pow(1.0-u[j],*theta)*pow(1.0-v[j],*theta),1.0/(*theta)-1) * pow(1.0-v[j],*theta-1.0)*(1-pow(1-u[j],*theta)); - } - else - { - pcondbb7(&v[j],&u[j],&T,param,&h[j]); - } - Free(param); - } - else if(*family==10) //BB8 - { - double* param; - param = Calloc(2,double); - param[0]=*theta; - param[1]=*nu; - int T=1; - if(*nu==0) - { - h[j]=u[j]; - } - else if(*nu==1) - { - if(*theta==1) h[j]=u[j]; - else h[j]=pow(pow(1.0-u[j],*theta) + pow(1.0-v[j],*theta) - pow(1.0-u[j],*theta)*pow(1.0-v[j],*theta),1.0/(*theta)-1) * pow(1.0-v[j],*theta-1.0)*(1-pow(1-u[j],*theta)); - } - else - { - pcondbb8(&v[j],&u[j],&T,param,&h[j]); - } - Free(param); - } - else if(*family==13) //rotated clayton (180) - { - if(*theta == 0) h[j] = u[j] ; - if(*theta < XEPS) h[j] = u[j] ; - else - { - u[j]=1-u[j]; - v[j]=1-v[j]; - x = pow(u[j],-*theta)+pow(v[j],-*theta)-1.0 ; - h[j] = pow(v[j],-*theta-1.0)*pow(x,-1.0-1.0/(*theta)); // pow(v[j],-*theta-1.0)*pow(pow(u[j],-*theta)+pow(v[j],-*theta)-1.0,-1.0-1.0/(*theta)); - h[j]= 1-h[j]; - u[j]=1-u[j]; - v[j]=1-v[j]; - } - } - else if(*family==14) //rotated gumbel (180) - { - v[j]= 1-v[j]; - u[j]= 1-u[j]; - h[j]= -(exp(-pow(pow(-log(v[j]),*theta)+pow(-log(u[j]),*theta),1.0/(*theta)))*pow(pow(-log(v[j]),*theta)+pow(-log(u[j]),*theta),1.0/(*theta)-1.0)*pow(-log(v[j]),*theta))/(v[j]* log(v[j])); - h[j]= 1-h[j]; - u[j]=1-u[j]; - v[j]=1-v[j]; - } - else if(*family==16) - { - v[j]= 1-v[j]; - u[j]= 1-u[j]; - h[j] = pow(pow(1.0-u[j],*theta) + pow(1.0-v[j],*theta) - pow(1.0-u[j],*theta)*pow(1.0-v[j],*theta),1.0/(*theta)-1) * pow(1.0-v[j],*theta-1.0)*(1-pow(1-u[j],*theta)); - h[j]= 1-h[j]; - u[j]=1-u[j]; - v[j]=1-v[j]; - } - else if(*family==17) //rotated BB1 - { - double* param; - param = Calloc(2,double); - param[0]=*theta; - param[1]=*nu; - int T=1; - if(*nu==1) - { - if(*theta==0) h[j]=u[j]; - else - { - h[j]=pow(pow(1-u[j],-*theta)+pow(1-v[j],-*theta)-1,-1/(*theta)-1)*pow(1-v[j],-*theta-1); - h[j]= 1-h[j]; - } - } - else if(*theta==0) - { - h[j]=-(exp(-pow(pow(-log(1-v[j]),*nu)+pow(-log(1-u[j]),*nu),1.0/(*nu)))*pow(pow(-log(1-v[j]),*nu)+pow(-log(1-u[j]),*nu),1.0/(*nu)-1.0)*pow(-log(1-v[j]),*nu))/((1-v[j])*log(1-v[j])); - h[j]= 1-h[j]; - } - else - { - v[j]= 1-v[j]; - u[j]= 1-u[j]; - pcondbb1(&v[j],&u[j],&T,param,&h[j]); - u[j]=1-u[j]; - v[j]=1-v[j]; - h[j]= 1-h[j]; - } - Free(param); - } - else if(*family==18) //rotated BB6 - { - double* param; - param = Calloc(2,double); - param[0]=*theta; - param[1]=*nu; - int T=1; - if(*theta==1) - { - if(*nu==1) h[j]=u[j]; - else - { - h[j]=-(exp(-pow(pow(-log(1-v[j]),*nu)+pow(-log(1-u[j]),*nu),1.0/(*nu)))*pow(pow(-log(1-v[j]),*nu)+pow(-log(1-u[j]),*nu),1.0/(*nu)-1.0)*pow(-log(1-v[j]),*nu))/((1-v[j])*log(1-v[j])); - h[j]= 1-h[j]; - } - } - else if(*nu==1) - { - h[j]=pow(pow(u[j],*theta) + pow(v[j],*theta) - pow(u[j],*theta)*pow(v[j],*theta),1.0/(*theta)-1) * pow(v[j],*theta-1.0)*(1-pow(u[j],*theta)); - h[j]= 1-h[j]; - } - else - { - v[j]= 1-v[j]; - u[j]= 1-u[j]; - pcondbb6(&v[j],&u[j],&T,param,&h[j]); - u[j]=1-u[j]; - v[j]=1-v[j]; - h[j]= 1-h[j]; - } - Free(param); - } - else if(*family==19) //rotated BB7 - { - double* param; - param = Calloc(2,double); - param[0]=*theta; - param[1]=*nu; - int T=1; - if(*theta==1) - { - if(*nu==0) h[j]=u[j]; - else{ - h[j]=pow(pow(1-u[j],-*nu)+pow(1-v[j],-*nu)-1,-1/(*nu)-1)*pow(1-v[j],-*nu-1); - h[j]= 1-h[j]; - } - } - else if(*nu==0) - { - h[j] = pow(pow(u[j],*theta) + pow(v[j],*theta) - pow(u[j],*theta)*pow(v[j],*theta),1.0/(*theta)-1) * pow(v[j],*theta-1.0)*(1-pow(u[j],*theta)); - h[j]= 1-h[j]; - } - else - { - v[j]= 1-v[j]; - u[j]= 1-u[j]; - pcondbb7(&v[j],&u[j],&T,param,&h[j]); - u[j]=1-u[j]; - v[j]=1-v[j]; - h[j]= 1-h[j]; - } - Free(param); - } - else if(*family==20) //rotated BB8 - { - double* param; - param = Calloc(2,double); - param[0]=*theta; - param[1]=*nu; - int T=1; - if(*nu==0) - { - h[j]=u[j]; - } - else if(*nu==1) - { - if(*theta==1) h[j]=u[j]; - else{ - h[j]=pow(pow(u[j],*theta) + pow(v[j],*theta) - pow(u[j],*theta)*pow(v[j],*theta),1.0/(*theta)-1) * pow(v[j],*theta-1.0)*(1-pow(u[j],*theta)); - h[j]= 1-h[j]; - } - } - else - { - v[j]= 1-v[j]; - u[j]= 1-u[j]; - pcondbb8(&v[j],&u[j],&T,param,&h[j]); - u[j]=1-u[j]; - v[j]=1-v[j]; - h[j]= 1-h[j]; - } - Free(param); - } - else if(*family==41) - { - double t1,t2,t3; - t1=qgamma(1.0-u[j],*theta,1,1,0); - t2=qgamma(1.0-v[j],*theta,1,1,0); - t3=pow(pow(t1,*theta)+pow(t2,*theta),(1.0/(*theta))); - h[j]=exp(-t3+t1); - } - else if(*family==104) - { - int T=1; - double par3=1; - dC_dv(&u[j],&v[j],&T,theta,nu,&par3,&h[j]); - } - else if(*family==114) - { - int T=1; - double par3=1; - v[j]= 1-v[j]; - u[j]= 1-u[j]; - dC_dv(&u[j],&v[j],&T,theta,nu,&par3,&h[j]); - u[j]=1-u[j]; - v[j]=1-v[j]; - h[j]= 1-h[j]; - } - else if(*family==204) - { - int T=1; - double par3=*nu, par2=1; - dC_dv(&u[j],&v[j],&T,theta,&par2,&par3,&h[j]); - } - else if(*family==214) - { - int T=1; - double par3=*nu, par2=1; - v[j]= 1-v[j]; - u[j]= 1-u[j]; - dC_dv(&u[j],&v[j],&T,theta,&par2,&par3,&h[j]); - u[j]=1-u[j]; - v[j]=1-v[j]; - h[j]= 1-h[j]; - } - } - out[j] = MAX(MIN(h[j],UMAX),UMIN); - } - Free(h); -} - -/////////////////////////////////////////////////////////////// -void qcondgum(double* q, double* u, double* de, double* out) -{ - double a,p,g,gp,z1,z2,con,de1,dif; - double mxdif; - int iter; - - p = 1-*q; - z1 = -log(*u); - con=log(1.-p)-z1+(1.-*de)*log(z1); de1=*de-1.; - a=pow(2.*pow(z1,*de),1./(*de)); - mxdif=1; iter=0; - dif=.1; // needed in case first step leads to NaN - while(mxdif>1.e-6 && iter<20) - { g=a+de1*log(a)+con; - gp=1.+de1/a; - if(isnan(g) || isnan(gp) || isnan(g/gp) ) { dif/=-2.; } // added for de>50 - else dif=g/gp; - a-=dif; iter++; - while(a<=z1) { dif/=2.; a+=dif; } - mxdif=fabs(dif); - } - z2=pow(pow(a,*de)-pow(z1,*de),1./(*de)); - *out = exp(-z2); -} - -void qcondjoe(double* q, double* u, double* de, double* out) -{ double t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t13,t15,t16,t19,t23,t28,t31; - double c21,pdf; - int iter; - double diff,v,de1,dtem,de1inv,tem; - - t1 = 1.0-*u; - t2 = pow(t1,1.0*(*de)); - t7 = 1./(*de); - t10 = t2*(*de); - t11 = 1./t1; - t19 = (*de)*(*de); - de1=*de-1; // may need better modification for large delta - dtem=-de1/(1.+de1); de1inv=-1./de1; - - // v = 0.5 * (q+u); // starting guess - - // Use a better starting point based on reflected B4 copula - // A good starting point is crucial when delta is large because - // C_{2|1} will be steep - // C_{R,2|1}(v|u)=1-C_{2|1}(1-v|1-u), - // C_{R,2|1}^{-1}(q|u)=1-C_{2|1}^{-1}(1-q|1-u) - tem=pow(1.-*q,dtem)-1.; - tem=tem*pow(1.-*u,-de1)+1.; - v=pow(tem,de1inv); v=1.-v; - diff=1; iter=0; - while(fabs(diff)>1.e-6 && iter<20) - { t3 = 1.-v; - t4 = pow(t3,*de); - t5 = t2*t4; - t6 = t2+t4-t5; - t8 = pow(t6,t7); - t9 = t7*t8; - t13 = t11*t4; - t15 = -t10*t11+t10*t13; - t16 = 1./t6; - t23 = 1./t3; - t28 = t6*t6; - t31 = (-t4*(*de)*t23+t5*(*de)*t23)/t28*t15; - c21 = -t9*t15*t16; - pdf = -t8/t19*t31+t8*(*de)*t2*t13*t23*t16+t9*t31; - iter++; - if(isnan(pdf) || isnan(c21) ) { diff/=-2.; } // added for de>=30 - else diff=(c21-*q)/pdf; - v-=diff; - while(v<=0 || v>=1 || fabs(diff)>0.25 ) { diff/=2.; v+=diff; } - } - *out = v; -} - - -/*void qcondbb1(double* q, double* u, double* de, double* th, double* out) -{ - double t1, t2, t3, t4, t5, t6, t7, t9, t10, - t12, t13, t16, t17, t20, t24, t25, t27, t29, - t32, t33, t34, t36, t38, t39, t43, t59; - double c21,pdf; - int iter,mxiter; - double diff,v,vb4,tau,tau2,v0,mxstep,min(double,double); - - // mxiter=20; // need larger mxiter for d,th large - mxiter=30; - mxstep=.05; // .05 .1; //.25; // some failures if set at 0.25 - t1 = pow(*u,-*th); - t2 = t1-1.0; - t3 = pow(t2,*de); - t16 = 1./(*u); - t17 = 1./t2; - t38 = t1*t16; - t39 = t38*t17; - - v = 0.5 * (*q+*u); // starting guess - diff=.1; iter=0; - // B4(th) when de=1, B6(de) when th=0 - vb4=pow(*q,-*th/(1+*th))-1; - vb4=vb4*pow(*u,-*th)+1; - vb4=pow(vb4,-1/(*th)); - tau=1-2/(*de*(*th+2.)); tau2=pow(tau,1.7); - // for tau large, choose v=u as starting point - // de near 1, choose vb4 - // otherwise weight (q+u)/2 and u - if(*de<1.3) v=vb4; - else v=tau2*(*u) + (1-tau2)*(*q+*u)/2.; - while(fabs(diff)>1.e-6 && iter*q) v=v-MIN(mxstep,v/2); - else v=v+MIN(mxstep,(1-v)/2); - if(iter>10) mxstep=.025; // half the original - } - else - { - diff=(c21-*q)/pdf; - v0=v; - v-=diff; - // this can be infinite loop if |v| is extremely large - //while(v<=0 || v>=1 || fabs(diff)>0.25) { diff/=2; v+=diff; } - while(v<=0 || v>=1 || fabs(diff)>mxstep) { diff/=2; v+=diff; } - } - } - *out = v; -}*/ - - -/////////////////////////////////////////////////////////////// -// Function to compute inversion of H numerically through Bisection -// Input: -// u variable for which h-function computes conditional distribution function -// v variable on which h-function conditions -// theta parameter for the copula family -// out output -////////////////////////////////////////////////////////////// -void HNumInv(int* family, double* u, double* v, double* theta, double* nu, double* out) -{ - - int br=0, in=1; - double ans=0.0, tol=0.000001, x0=UMIN, x1=UMAX, fl, fh, val; - //Rprintf("family in HNumInv: %d\n", *family); - Hfunc1(family,&in,&x0,v,theta,nu,&fl); fl -= *u; - Hfunc1(family,&in,&x1,v,theta,nu,&fh); fh -= *u; - if(fabs(fl)<=tol) { ans=x0; br=1; } - if(fabs(fh)<=tol) { ans=x1; br=1; } - - while(!br){ - - ans = (x0+x1)/2.0; - Hfunc1(family,&in,&ans,v,theta,nu,&val); - val -= *u; - if(fabs(val)<=tol) br=1; - if(fabs(x0-x1)<=1e-10) br=1; //stop if values become too close (avoid infinite loop) - - if(val > 0.0) {x1 = ans; fh = val;} - else {x0 = ans; fl = val;} - - } - *out = ans; -} - -///////////////////////////////////////////// -// Function to invert h-function for vine simulation and estimation -///////////////////////////////////////////// -void Hinv1(int* family, int* n, double* u, double* v, double* theta, double* nu, double* out) -{ - double *negv, *negu; - negv = (double*) Calloc(*n,double); - negu = (double*) Calloc(*n,double); - double ntheta, nnu; - int nfamily; - ntheta = -*theta; - nnu = -*nu; - - for(int i=0;i<*n;i++) - { - if(u[i]UMAX) u[i]=UMAX; - if(v[i]UMAX) v[i]=UMAX; - } - - if(((*family ==23) | (*family ==24) | (*family==26) | (*family ==27) | (*family ==28) | (*family==29) | (*family==30) | (*family==61) )) - { - nfamily=(*family)-20; - for (int i = 0; i < *n; ++i) {negv[i]=1 - v[i];} - Hinv(&nfamily, n, u, negv, &ntheta, &nnu, out); - } - else if(((*family==33) | (*family==34) | (*family==36) | (*family ==37) | (*family ==38) | (*family==39) | (*family==40) | (*family==71) )) - { - nfamily=(*family)-30; - for (int i = 0; i < *n; i++) {negu[i]=1 - u[i];}; - Hinv(&nfamily, n, negu, v, &ntheta, &nnu, out); - for (int i = 0; i < *n; i++) {out[i]=1-out[i];}; - } - // else if(*family==104 | *family==204 | *family==114 | *family==214) - // { - // Hinv( family, n, v, u, theta, nu, out); // u und v vertauscht - // } - else if((*family==124) | (*family==224)) - { - nfamily=(*family)-20; - for (int i = 0; i < *n; ++i) {negv[i]=1 - v[i];} - Hinv(&nfamily, n, u, negv, &ntheta, nu, out); - } - else if((*family==134) | (*family==234)) - { - nfamily=(*family)-30; - for (int i = 0; i < *n; i++) {negu[i]=1 - u[i];}; - Hinv(&nfamily, n, negu, v, &ntheta, nu, out); - for (int i = 0; i < *n; i++) {out[i]=1-out[i];}; - } - else { - Hinv( family, n, u, v, theta, nu, out); - } - Free(negv); - Free(negu); -} - -void Hinv2(int* family, int* n, double* v, double* u, double* theta, double* nu, double* out) -{ - double *negv, *negu; - negv = (double *) malloc(*n*sizeof(double)); - negu = (double *) malloc(*n*sizeof(double)); - double ntheta, nnu; - int nfamily; - ntheta = -*theta; - nnu = -*nu; - - for(int i=0;i<*n;i++) - { - if(u[i]UMAX) u[i]=UMAX; - if(v[i]UMAX) v[i]=UMAX; - } - - if(((*family ==23) | (*family ==24) | (*family==26) | (*family ==27) | (*family ==28) | (*family==29) | (*family==30) | (*family==61) )) - { - nfamily = (*family)-20; - for (int i = 0; i < *n; ++i) {negv[i]=1 - v[i];} - Hinv(&nfamily, n, negv, u, &ntheta, &nnu, out); - for (int i = 0; i < *n; i++) {out[i]=1-out[i];}; - } - else if(((*family==33) | (*family==34) | (*family==36) | (*family ==37) | (*family ==38) | (*family==39) | (*family==40) | (*family==71) )) - { - nfamily=(*family)-30; - for (int i = 0; i < *n; ++i) {negu[i]=1 - u[i];} - Hinv(&nfamily, n, v, negu, &ntheta, &nnu, out); - //*out = 1-*out; - } - // else if(*family==104 | *family==204 | *family==114 | *family==214) - // { - // Hinv( family, n, u, v, theta, nu, out); // u und v vertauscht - // } - else if((*family==124) | (*family==224)) - { - nfamily = (*family)-20; - for (int i = 0; i < *n; ++i) {negv[i]=1 - v[i];} - Hinv(&nfamily, n, negv, u, &ntheta, nu, out); - for (int i = 0; i < *n; i++) {out[i]=1-out[i];}; - } - else if((*family==134) | (*family==234)) - { - nfamily=(*family)-30; - for (int i = 0; i < *n; ++i) {negu[i]=1 - u[i];} - Hinv(&nfamily, n, v, negu, &ntheta, nu, out); - } - else { - Hinv( family, n, v, u, theta, nu, out); - } - free(negv); - free(negu); -} - - - -////////////////////////////////////////////////////////////// -// Function to invert h-function for vine simulation and estimation -// Input: -// family copula family (1=gaussian, 2=student, 3=clayton, 4=gumbel, 5=frank, 6=joe) -// n number of iterations -// u variable for which h-function computes conditional distribution function -// v variable on which h-function conditions -// theta parameter for the copula family -// nu degrees-of-freedom for the students copula -////////////////////////////////////////////////////////////// -void Hinv(int* family, int* n, double* u, double* v, double* theta, double* nu, double* out) -{ - int j; - double *hinv; - hinv = Calloc(*n,double); - - for(int i=0;i<*n;i++) - { - if(u[i]UMAX) u[i]=UMAX; - if(v[i]UMAX) v[i]=UMAX; - } - - for(j=0;j<*n;j++) - { - if(*family==0) - { - hinv[j]=u[j]; - } - else if(*family==1) //gaussian - { - hinv[j] = pnorm(qnorm(u[j],0.0,1.0,1,0)*sqrt(1.0-pow(*theta,2.0))+*theta*qnorm(v[j],0.0,1.0,1,0),0.0,1.0,1,0); - } - else if(*family==2) //student - { - double temp1, temp2, mu, var; - temp1 = qt(u[j],*nu+1.0,1,0); temp2 = qt(v[j],*nu,1,0); mu = *theta*temp2; var=((*nu+(temp2*temp2))*(1.0-(*theta*(*theta))))/(*nu+1.0); - hinv[j] = pt((sqrt(var)*temp1)+mu,*nu,1,0); - } - else if(*family==3) //clayton - { - if(*theta < XEPS) hinv[j]=u[j]; - else - hinv[j] = pow(pow(u[j]*pow(v[j],*theta+1.0),-*theta/(*theta+1.0))+1.0-pow(v[j],-*theta),-1.0/(*theta)); - } - else if(*family==4) //gumbel - must turn to numerical inversion - { - //double nu=0.0; - //HNumInv(family,&u[j],&v[j],theta,&nu,&hinv[j]); - qcondgum(&u[j],&v[j],theta,&hinv[j]); - } - else if(*family==5) //frank - numerical inversion - { - hinv[j] = -1/(*theta)*log(1-(1-exp(-*theta)) / ((1/u[j]-1)*exp(-*theta*v[j])+1)); - } - else if(*family==6) //joe - numerical inversion - { - if(*theta<40) - { - qcondjoe(&u[j],&v[j],theta,&hinv[j]); - } - else - { - double nu=0.0; - HNumInv(family,&u[j],&v[j],theta,&nu,&hinv[j]); - } - } - else if(*family==7) //BB1 - { - HNumInv(family,&u[j],&v[j],theta,nu,&hinv[j]); - //qcondbb1(&u[j],&v[j],nu,theta,&hinv[j]); - } - else if(*family==8) //BB6 - { - HNumInv(family,&u[j],&v[j],theta,nu,&hinv[j]); - } - else if(*family==9) //BB7 - { - HNumInv(family,&u[j],&v[j],theta,nu,&hinv[j]); - } - else if(*family==10) //BB8 - { - HNumInv(family,&u[j],&v[j],theta,nu,&hinv[j]); - } - else if(*family==13) - { - u[j]=1-u[j]; - v[j]=1-v[j]; - hinv[j] = pow(pow(u[j]*pow(v[j],*theta+1.0),-*theta/(*theta+1.0))+1.0-pow(v[j],-*theta),-1.0/(*theta)); - hinv[j]=1-hinv[j]; - u[j]=1-u[j]; - v[j]=1-v[j]; - } - else if(*family==14) //rotated gumbel (180) - must turn to numerical inversion - { - //int jj=4; - u[j]=1-u[j]; - v[j]=1-v[j]; - //HNumInv(&jj,&u[j],&v[j],theta,nu,&hinv[j]); - qcondgum(&u[j],&v[j],theta,&hinv[j]); - hinv[j]=1-hinv[j]; - u[j]=1-u[j]; - v[j]=1-v[j]; - } - else if(*family==16) //rotated joe (180) - must turn to numerical inversion - { - u[j]=1-u[j]; - v[j]=1-v[j]; - if(*theta<40) - { - qcondjoe(&u[j],&v[j],theta,&hinv[j]); - } - else - { - int jj=6; - double nu=0.0; - HNumInv(&jj,&u[j],&v[j],theta,&nu,&hinv[j]); - } - hinv[j]=1-hinv[j]; - u[j]=1-u[j]; - v[j]=1-v[j]; - } - else if(*family==17) //rotated BB1 (180) - must turn to numerical inversion - { - int jj=7; - u[j]=1-u[j]; - v[j]=1-v[j]; - HNumInv(&jj,&u[j],&v[j],theta,nu,&hinv[j]); - //qcondbb1(&u[j],&v[j],nu,theta,&hinv[j]); - hinv[j]=1-hinv[j]; - u[j]=1-u[j]; - v[j]=1-v[j]; - } - else if(*family==18) //rotated BB6 (180) - must turn to numerical inversion - { - int jj=8; - u[j]=1-u[j]; - v[j]=1-v[j]; - HNumInv(&jj,&u[j],&v[j],theta,nu,&hinv[j]); - hinv[j]=1-hinv[j]; - u[j]=1-u[j]; - v[j]=1-v[j]; - } - else if(*family==19) //rotated BB7 (180) - must turn to numerical inversion - { - int jj=9; - u[j]=1-u[j]; - v[j]=1-v[j]; - HNumInv(&jj,&u[j],&v[j],theta,nu,&hinv[j]); - hinv[j]=1-hinv[j]; - u[j]=1-u[j]; - v[j]=1-v[j]; - } - else if(*family==20) //rotated BB8 (180) - must turn to numerical inversion - { [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/vinecopula -r 36