-
Notifications
You must be signed in to change notification settings - Fork 22
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
Refactoring exposure function #42
Conversation
…-test-discussion too.
… in rdiffnet function
a54800b
to
587babb
Compare
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
@@ -7,6 7,7 @@ Authors@R: c( | |||
), | |||
person("Thomas", "Valente", email="[email protected]", 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
@@ -631,6 631,7 @@ new_diffnet <- function(graph, toa, t0=min(toa, na.rm = TRUE), t1=max(toa, na.rm | |||
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
} | ||
|
||
#as.vector(ans) | ||
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
diffnet
package, 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:
DESCRIPTION
file.R/diffnet-class.r
file to version 5.dgr.array
function inR/stats.R
.Exposure Calculation Enhancements:
R/stats.R
to handle multiple diffusion processes and added normalization steps. [1] [2]exposure_for
function to support multiple contagions and added checks for attribute dimensions.Testing Improvements:
tests/testthat/test-stats.R
to validate the multidiffusion exposure calculations, including handling of lagged exposures and structural equivalence.playground
directory to discuss and validate exposure calculations (exposure-ans-discussion.R
,exposure-out-discussion.R
,multidiff-test-discussion.R
). [1] [2] [3]