[Vinecopula-commits] r10 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Di Apr 23 15:08:58 CEST 2013


Author: ben_graeler
Date: 2013-04-23 15:08:58 +0200 (Tue, 23 Apr 2013)
New Revision: 10

Modified:
   pkg/R/BiCopSelect.r
   pkg/R/RVineStructureSelect.r
Log:
- Error in the default familyset of BiCopSelect

Modified: pkg/R/BiCopSelect.r
===================================================================
--- pkg/R/BiCopSelect.r	2013-04-22 07:30:41 UTC (rev 9)
+++ pkg/R/BiCopSelect.r	2013-04-23 13:08:58 UTC (rev 10)
@@ -1,13 +1,23 @@
 BiCopSelect <- function(u1,u2,familyset=NA,selectioncrit="AIC",indeptest=FALSE,level=0.05,weights=NA)
 {
-  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(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(!is.na(familyset[1])) for(i in 1:length(familyset)) if(!(familyset[i] %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(selectioncrit != "AIC" && selectioncrit != "BIC") stop("Selection criterion not implemented.")
-  if(level < 0 || level > 1) stop("Significance level has to be between 0 and 1.")
+  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(length(u1)<2) 
+    stop("Number of observations has to be at least 2.")
+  if(any(u1>1) || any(u1<0)) 
+    stop("Data has to be in the interval [0,1].")
+  if(any(u2>1) || any(u2<0)) 
+    stop("Data has to be in the interval [0,1].")	
+  if(any(is.na(familyset)))
+    familyset <- c(1:10,13,14,16:20,23,24,26:30,33,34,36:40,41,51,61,71)
+  if(any(!(familyset %in% c(0,1:10,13,14,16:20,23,24,26:30,33,34,36:40,41,51,61,71))))
+    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.")
   
   out=list()
 

Modified: pkg/R/RVineStructureSelect.r
===================================================================
--- pkg/R/RVineStructureSelect.r	2013-04-22 07:30:41 UTC (rev 9)
+++ pkg/R/RVineStructureSelect.r	2013-04-23 13:08:58 UTC (rev 10)
@@ -7,21 +7,32 @@
 	n = dim(data)[2]
 	d = dim(data)[1]
 	
-	if(dim(data)[1]<2) stop("Number of observations has to be at least 2.")
-  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(selectioncrit != "AIC" && selectioncrit != "BIC") stop("Selection criterion not implemented.")
-  if(level < 0 || level > 1) stop("Significance level has to be between 0 and 1.")
+	if(dim(data)[1]<2) 
+    stop("Number of observations has to be at least 2.")
+  if(d<2) 
+    stop("Dimension has to be at least 2.")
+  if(any(data>1) || any(data<0)) 
+    stop("Data has to be in the interval [0,1].")
+  if(any(is.na(familyset))) {
+    familyset <- c(1:10,13,14,16:20,23,24,26:30,33,34,36:40)
+  }
+  if(any(!(familyset %in% c(0,1:10,13,14,16:20,23,24,26:30,33,34,36:40))))
+    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.")
   	
-	if(is.null(colnames(data))) colnames(data) = paste("V",1:n,sep="") 
+	if(is.null(colnames(data))) 
+    colnames(data) = paste("V",1:n,sep="") 
 
-  if(is.na(trunclevel)) trunclevel = d
+  if(is.na(trunclevel)) 
+    trunclevel = d
 
 	RVine = list(Tree = NULL, Graph=NULL)
 
-  if(trunclevel == 0) familyset = 0
+  if(trunclevel == 0) 
+    familyset = 0
 	
 	g = initializeFirstGraph(data,weights)
 	mst = findMaximumTauTree(g,mode=type)



Mehr Informationen über die Mailingliste Vinecopula-commits