@@ -53,26 +53,26 @@ sce.nbr <- read.csv(file=file, header=TRUE, check.names=FALSE, stringsAsFactors=
5353# process each measure
5454for (meas in meass )
5555{ tlog(2 ," Dealing with measure " ,meas )
56- wts <- NA
57- if (meas == " strength" )
56+ if (meas == MEAS_STRENGTH )
5857 wts <- c(" duration" ," occurrences" )
59-
58+ else
59+ wts <- c(" none" )
60+
6061 for (wt in wts )
61- { if (! is.na(wt ))
62- tlog(4 ," Dealing with weight " ,wt )
62+ { tlog(4 ," Dealing with weight \" " ,wt ," \" " )
6363
6464 # load precomputed data
6565 data <- list ()
6666 # unfiltered
67- file <- get.path.stat.table(object = " nodes" , mode = " scenes" , net.type = " static" , weights = if (is.na( wt )) " occurrences " else wt , filtered = " unfiltered" )
67+ file <- get.path.stat.table(object = " nodes" , mode = " scenes" , net.type = " static" , weights = wt , filtered = " unfiltered" )
6868 tab <- as.matrix(read.csv(file , header = TRUE , check.names = FALSE , row.names = 1 ))
6969 data [[1 ]] <- tab [,meas ]
7070 unfilt.idx <- data [[1 ]] > 0
7171 data [[1 ]] <- data [[1 ]][unfilt.idx ] # remove isolates
7272# file <- get.path.stats.comp(mode="scenes", meas.name=meas, weights=if(is.na(wt)) "none" else wt, filtered=FALSE, suf="distrtest_noisolates")
7373# test.disc.distr(data[[1]], xlab=paste0("Unfiltered ",ALL_MEASURES[[meas]]$cname," (no isolates)"), return_stats=FALSE, sims=100, plot.file=file)
7474 # filtered
75- file <- get.path.stat.table(object = " nodes" , mode = " scenes" , net.type = " static" , weights = if (is.na( wt )) " occurrences " else wt , filtered = " filtered" )
75+ file <- get.path.stat.table(object = " nodes" , mode = " scenes" , net.type = " static" , weights = wt , filtered = " filtered" )
7676 tab <- as.matrix(read.csv(file , header = TRUE , check.names = FALSE , row.names = 1 ))
7777 data [[2 ]] <- tab [,meas ]
7878 filt.idx <- data [[2 ]] > 1
@@ -82,12 +82,12 @@ for(meas in meass)
8282# test.disc.distr(data[[2]], xlab=paste0("Unfiltered ",ALL_MEASURES[[meas]]$cname," (no isolates)"), return_stats=FALSE, sims=100, plot.file=file)
8383
8484 # set params
85- file <- get.path.stats.topo(net.type = " static" , mode = " scenes" , meas.name = meas , weights = if (is.na( wt )) " none " else wt , filtered = " both" , suf = " distrib " )
85+ file <- get.path.stats.topo(net.type = " static" , mode = " scenes" , meas.name = meas , weights = wt , filtered = " both" , suf = " ccdf " )
8686 ml <- paste0(ALL_MEASURES [[meas ]]$ cname , " distribution" )
87- if (! is.na( wt ) )
87+ if (wt != " none " )
8888 ml <- paste0(ml ," (" ,wt ," )" )
8989 xl <- paste0(ALL_MEASURES [[meas ]]$ cname )
90- if (! is.na( wt ) )
90+ if (wt != " none " )
9191 xl <- paste0(xl ," (" ,wt ," )" )
9292
9393 # check distribution
@@ -96,9 +96,9 @@ for(meas in meass)
9696 { power.law <- displ $ new(data [[i ]])
9797 est <- estimate_xmin(power.law )
9898 tmp <- power.law $ setXmin(est )
99- if (laws [paste0(names(data )[i ]," -" ,meas ,if (! is.na( wt ) ) paste0(" -" ,wt ) else " " )]== " truncated" )
99+ if (laws [paste0(names(data )[i ]," -" ,meas ,if (wt != " none " ) paste0(" -" ,wt ) else " " )]== " truncated" )
100100 pl [[i ]] <- discpowerexp.fit(x = data [[i ]],threshold = power.law $ xmin )
101- else if (laws [paste0(names(data )[i ]," -" ,meas ,if (! is.na( wt ) ) paste0(" -" ,wt ) else " " )]== " good" )
101+ else if (laws [paste0(names(data )[i ]," -" ,meas ,if (wt != " none " ) paste0(" -" ,wt ) else " " )]== " good" )
102102 pl [[i ]] <- power.law
103103 else
104104 pl [[i ]] <- NA
@@ -114,24 +114,37 @@ for(meas in meass)
114114 par(mar = c(4 ,4 ,0 ,0 )+ 0.1 ) # remove the title space Bottom Left Top Right
115115 plot.ccdf(data = data , main = NA , xlab = xl , ylab = " default" , log = TRUE , cols = pal , leg.title = " Characters" )
116116 for (i in 1 : 2 )
117- { if (laws [paste0(names(data )[i ]," -" ,meas ,if (! is.na( wt ) ) paste0(" -" ,wt ) else " " )]== " truncated" )
117+ { if (laws [paste0(names(data )[i ]," -" ,meas ,if (wt != " none " ) paste0(" -" ,wt ) else " " )]== " truncated" )
118118 { x <- seq(pl [[2 ]]$ threshold ,max(data [[2 ]]))
119119 y <- 1 - cumsum(ddiscpowerexp(x = x ,exponent = pl [[2 ]]$ exponent ,rate = pl [[2 ]]$ rate ,threshold = pl [[2 ]]$ threshold ))
120120 lines(x , y , col = " BLACK" , lty = 2 )
121121 }
122- else if (laws [paste0(names(data )[i ]," -" ,meas ,if (! is.na( wt ) ) paste0(" -" ,wt ) else " " )]== " good" )
122+ else if (laws [paste0(names(data )[i ]," -" ,meas ,if (wt != " none " ) paste0(" -" ,wt ) else " " )]== " good" )
123123 lines(pl [[i ]], col = " BLACK" , lty = 2 )
124124 }
125125 dev.off()
126126 }
127127
128128 # correlation between degree and number of occurrences
129+ pear.cor <- cor(data [[1 ]],sce.nbr [unfilt.idx ], method = " pearson" )
129130 kend.cor <- cor(data [[1 ]],sce.nbr [unfilt.idx ], method = " kendall" )
130131 spear.cor <- cor(data [[1 ]],sce.nbr [unfilt.idx ], method = " spearman" )
131- tlog(6 ," Correlation between unfiltered degree and scene numbers: Kendall=" ,kend.cor ," Spearman=" ,spear.cor )
132+ tlog(6 ," Correlation between unfiltered degree and scene numbers: Pearson=" ,pear.cor ," Kendall=" ,kend.cor ," Spearman=" ,spear.cor )
133+ file <- get.path.stats.topo(net.type = " static" , mode = " scenes" , meas.name = MEAS_MULTI_NODES , weights = wt , filtered = " unfiltered" , suf = paste0(meas ," _vs_scenes_correlation" ))
134+ tlog(8 ," Recording in file \" " ,file ," \" " )
135+ tab <- data.frame (pear.cor , kend.cor , spear.cor )
136+ colnames(tab ) <- c(" Pearson" , " Kendall" , " Spearman" )
137+ write.csv(x = tab , file = paste0(file ," .csv" ), row.names = FALSE )
138+ #
139+ pear.cor <- cor(data [[2 ]],sce.nbr [idx.keep ][filt.idx ], method = " pearson" )
132140 kend.cor <- cor(data [[2 ]],sce.nbr [idx.keep ][filt.idx ], method = " kendall" )
133141 spear.cor <- cor(data [[2 ]],sce.nbr [idx.keep ][filt.idx ], method = " spearman" )
134- tlog(6 ," Correlation between filtered degree and scene numbers: Kendall=" ,kend.cor ," Spearman=" ,spear.cor )
142+ tlog(6 ," Correlation between filtered degree and scene numbers: Pearson=" ,pear.cor ," Kendall=" ,kend.cor ," Spearman=" ,spear.cor )
143+ file <- get.path.stats.topo(net.type = " static" , mode = " scenes" , meas.name = MEAS_MULTI_NODES , weights = wt , filtered = " filtered" , suf = paste0(meas ," _vs_scenes_correlation" ))
144+ tlog(8 ," Recording in file \" " ,file ," \" " )
145+ tab <- data.frame (pear.cor , kend.cor , spear.cor )
146+ colnames(tab ) <- c(" Pearson" , " Kendall" , " Spearman" )
147+ write.csv(x = tab , file = paste0(file ," .csv" ), row.names = FALSE )
135148 }
136149}
137150
0 commit comments