-
Notifications
You must be signed in to change notification settings - Fork 22
Refactoring exposure function #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…-test-discussion too.
… in rdiffnet function
a54800b to
587babb
Compare
gvegayon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Address the missing bits and we will merge.
DESCRIPTION
Outdated
| ), | ||
| person("Thomas", "Valente", email="tvalente@usc.edu", role=c("aut", "cph"), | ||
| comment=c(ORCID="0000-0002-8824-5816", what="R original code")), | ||
| person("Anibal", "Olivera Morales", role = c("aut", "ctb")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add your ORCID like I do.
R/diffnet-class.r
Outdated
| as.character(name))) | ||
| meta$behavior <- ifelse(!length(behavior), "", ifelse(is.na(behavior), "", | ||
| as.character(behavior))) | ||
| meta$version <- 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a way of capturing the package version.
| meta$version <- 5 | |
| meta$version <- utils::packageVersion("netdiffuseR") |
R/stats.R
Outdated
| return(as.vector(ans)) | ||
| } | ||
|
|
||
| # library(microbenchmark) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # library(microbenchmark) |
R/stats.R
Outdated
| #out <- matrix(nrow = nrow(cumadopt), ncol = ncol(cumadopt)) | ||
|
|
||
| #if (lags >= 0L) { | ||
| # for (i in 1:(nslices(graph) - lags)) | ||
| # out[,i+lags]<- .exposure(graph[[i]], cumadopt[,i,drop=FALSE], attrs[,i,drop=FALSE], | ||
| # outgoing, valued, normalized, self) | ||
| #} else { | ||
| # for (i in (1-lags):nslices(graph)) | ||
| # out[,i+lags]<- .exposure(graph[[i]], cumadopt[,i,drop=FALSE], attrs[,i,drop=FALSE], | ||
| # outgoing, valued, normalized, self) | ||
| #} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #out <- matrix(nrow = nrow(cumadopt), ncol = ncol(cumadopt)) | |
| #if (lags >= 0L) { | |
| # for (i in 1:(nslices(graph) - lags)) | |
| # out[,i+lags]<- .exposure(graph[[i]], cumadopt[,i,drop=FALSE], attrs[,i,drop=FALSE], | |
| # outgoing, valued, normalized, self) | |
| #} else { | |
| # for (i in (1-lags):nslices(graph)) | |
| # out[,i+lags]<- .exposure(graph[[i]], cumadopt[,i,drop=FALSE], attrs[,i,drop=FALSE], | |
| # outgoing, valued, normalized, self) | |
| #} |
R/stats.R
Outdated
| #ans <- ( graph %*% (attrs * cumadopt) ) | ||
| # | ||
| #if (normalized) { | ||
| # as.vector(ans/( graph %*% attrs + 1e-20 )) | ||
| #} else { | ||
| # as.vector(ans) | ||
| #} | ||
| # |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #ans <- ( graph %*% (attrs * cumadopt) ) | |
| # | |
| #if (normalized) { | |
| # as.vector(ans/( graph %*% attrs + 1e-20 )) | |
| #} else { | |
| # as.vector(ans) | |
| #} | |
| # |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete this file.
This pull request includes several changes to the
diffnetpackage, focusing on enhancing the exposure calculation functionality, adding support for multiple diffusion processes, and improving the testing framework. The most significant changes include adding a new author, updating the version metadata, modifying the exposure calculation logic, and adding comprehensive tests.Metadata and Documentation Updates:
DESCRIPTIONfile.R/diffnet-class.rfile to version 5.dgr.arrayfunction inR/stats.R.Exposure Calculation Enhancements:
R/stats.Rto handle multiple diffusion processes and added normalization steps. [1] [2]exposure_forfunction to support multiple contagions and added checks for attribute dimensions.Testing Improvements:
tests/testthat/test-stats.Rto validate the multidiffusion exposure calculations, including handling of lagged exposures and structural equivalence.playgrounddirectory to discuss and validate exposure calculations (exposure-ans-discussion.R,exposure-out-discussion.R,multidiff-test-discussion.R). [1] [2] [3]