zpneal / backbone

R backbone package - Extract the backbone from weighted and unweighted networks
https://www.rbackbone.net
40 stars 8 forks source link

NaN's appearing in sdsm under "model = chi2" with certain dataset #15

Closed domagal9 closed 4 years ago

domagal9 commented 4 years ago

Using the gawc11 dataset, NaN's appearing in sdsm$positive and sdsm$negative when "model = chi2" is used. gawc11.zip

Issue replicated on mac and windows Not necessarily when there are exact 0's & 1's cause can occur under other models (e.g. logit, polytope). Does not occur in other datasets (e.g. senate)

Rep code: data <- read.csv("gawc11.csv", row.names = 1) data <- as.matrix(data) sdsmchi2 <- sdsm(data, model="chi2") sdsmchi2$positive sdsmchi2$negative

Error is specifically occurring in the rna function under the command pp = rep(pp, wts) The error is "rep(pp, wts) : invalid 'times' argument". This command does not have an error with other datasets.

domagal9 commented 4 years ago

Reason: This problem is occurring within the RNA function The part that is causing the error is the line: ind = gammak/(6*sigmak^3) This is causing an error because it is dividing by zero. sigmak is zero because each value of pp is zero

Why is each value of pp zero?

This is good! This means it is directly because of the dataset, not an error. We could remedy this by (1) Adding a statement that all zero bipartite data shouldn’t be used or (2) Adding a super small amount to the chi2 values with the line: probs <- probs+0.000000000000001