Skip to content

Commit

Permalink
Merge pull request #35 from snlab-ch/develop
Browse files Browse the repository at this point in the history
Introduces the DyNAMi model
  • Loading branch information
jhollway authored Jul 25, 2021
2 parents af9a9c7 + d05227d commit a9a51f3
Show file tree
Hide file tree
Showing 86 changed files with 11,470 additions and 2,986 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
^\.github$
^.lintr
^codecov\.yml$
^.*\.code-workspace$
25 changes: 25 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
#*.c text
#*.h text

# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf
src/Makevars.win text eol=crlf
cleanup.win text eol=crlf

# Declare files that will always have LF line endings on checkout.
*.ac text eol=lf
configure text eol=lf
configure.ac text eol=lf
src/Makevars.in text eol=lf
cleanup text eol=lf

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
*.gif binary
*.pdf binary
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 8 additions & 9 deletions .github/workflows/prchecks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
config:
- {os: macOS-latest, r: 'release', artifact_name: '*.tar.gz', asset_name: macOS}
- {os: windows-latest, r: 'release', artifact_name: '*.zip', asset_name: winOS}
# - {os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest", artifact_name: '*.tar.gz', asset_name: linuxOS}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest", artifact_name: '*.tar.gz', asset_name: linuxOS}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
Expand Down Expand Up @@ -46,14 +46,13 @@ jobs:
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

#- name: Install system dependencies
# if: runner.os == 'Linux'
# env:
# RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
# run: |
# Rscript -e "remotes::install_github('r-hub/sysreqs')"
# sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
# sudo -s eval "$sysreqs"
- name: Install system dependencies
if: runner.os == 'Linux'
run: |
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "20.04"), sep = "\n")')
- name: Install dependencies
run: |
Expand Down
71 changes: 41 additions & 30 deletions .github/workflows/pushrelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
config:
- {os: macOS-latest, r: 'release', artifact_name: '*.tar.gz', asset_name: macOS}
- {os: windows-latest, r: 'release', artifact_name: '*.zip', asset_name: winOS}
# - {os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest", artifact_name: '*.tar.gz', asset_name: linuxOS}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest", artifact_name: '*.tar.gz', asset_name: linuxOS}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
Expand Down Expand Up @@ -46,14 +46,13 @@ jobs:
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

#- name: Install system dependencies
# if: runner.os == 'Linux'
# env:
# RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
# run: |
# Rscript -e "remotes::install_github('r-hub/sysreqs')"
# sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
# sudo -s eval "$sysreqs"
- name: Install system dependencies
if: runner.os == 'Linux'
run: |
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "20.04"), sep = "\n")')
- name: Install dependencies
run: |
Expand Down Expand Up @@ -154,32 +153,44 @@ jobs:
- name: Display structure of downloaded files
run: ls -R

- name: Zip up
uses: montudor/action-zip@v0.1.0
- name: Rename Mac release
run: mv ./macOS/*.tgz goldfish_macOS.tgz

- name: Upload Mac binary
id: upload-mac
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: zip -qq -r goldfish_AllOS.zip . -i ./macOS/* ./winOS/*
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: goldfish_macOS.tgz
asset_name: goldfish_macOS.tgz
asset_content_type: application/zip

- name: Display structure of downloaded files again
run: ls -R
- name: Rename Linux release
run: mv ./linuxOS/*.tar.gz goldfish_linuxOS.tar.gz

- name: Upload binary
id: upload-binary
- name: Upload Linux binary
id: upload-lin
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: goldfish_AllOS.zip
asset_name: goldfish_AllOS.zip
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: goldfish_linuxOS.tar.gz
asset_name: goldfish_linuxOS.tar.gz
asset_content_type: application/zip

- name: Rename Windows release
run: mv ./winOS/*.zip goldfish_winOS.zip

- name: Upload Windows binary
id: upload-win
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: goldfish_winOS.zip
asset_name: goldfish_winOS.zip
asset_content_type: application/zip

# - name: Upload Mac binary
# id: upload-mac-binary
# uses: actions/upload-release-asset@v1.0.2
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
# asset_path: macOS/*.tgz
# asset_name: macOS
# asset_content_type: application/zip
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Encoding: UTF-8
Package: goldfish
Type: Package
Title: Goldfish -- Statistical network models for dynamic network data
Version: 1.4.9
Date: 2020-07-14
Version: 1.5.0
Date: 2021-07-24
Authors@R: c(person("Christoph", "Stadtfeld", role = c("cre", "aut"), email = "c.stadtfeld@ethz.ch"),
person("James", "Hollway", role = c("aut", "dtc")),
person("Marion", "Hoffman", role = "ctb"),
Expand All @@ -25,7 +25,7 @@ Suggests:
devtools,
covr
VignetteBuilder: knitr
License: GPL (>= 3)
License: GPL (>= 3) | file LICENSE
LazyData: true
RoxygenNote: 7.1.1
Depends: R (>= 3.5.0)
Expand All @@ -39,3 +39,4 @@ LinkingTo:
Rcpp,
RcppArmadillo
NeedsCompilation: yes
Config/testthat/edition: 3
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ S3method(tail,network.goldfish)
S3method(tail,nodes.goldfish)
export(defineDependentEvents)
export(defineGlobalAttribute)
export(defineGroups_interaction)
export(defineNetwork)
export(defineNodes)
export(estimate)
Expand All @@ -35,17 +36,20 @@ export(linkEvents)
importFrom(Rcpp,sourceCpp)
importFrom(changepoint,cpt.mean)
importFrom(changepoint,cpt.var)
importFrom(graphics,points)
importFrom(methods,is)
importFrom(stats,AIC)
importFrom(stats,BIC)
importFrom(stats,aggregate)
importFrom(stats,coef)
importFrom(stats,end)
importFrom(stats,filter)
importFrom(stats,formula)
importFrom(stats,na.omit)
importFrom(stats,pnorm)
importFrom(stats,printCoefmat)
importFrom(stats,qnorm)
importFrom(stats,sd)
importFrom(stats,time)
importFrom(utils,getTxtProgressBar)
importFrom(utils,head)
Expand Down
53 changes: 53 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
# goldfish 1.5.0

## New features

* New DyNAM-i model available to model face-to-face interaction data, collected through video or RFID badges.
* Functions to transform interaction data into DyNAM-compatible objects

```R
defineGroups_interaction(interactions_data, actors, seed.randomization)
```
* Estimation functions for the joining and leaving rates of a DyNAM-i model

```R
estimate(
dependent.events_interactions ~ 1 + intercept(network_interactions, joining = 1) +
ego(actors$age,joining = 1, subType = "centered") +
ego(actors$age,joining = -1, subType = "centered"),
model = "DyNAMi", subModel = "rate")
```

* Estimation functions for the choice part of a DyNAM-i model

```R
estimate(
dependent.events_interactions ~ diff(actors$age,subType="averaged_sum") ,
model = "DyNAMi", subModel = "choice",
estimationInit = list(opportunitiesList = opportunities))
```
* New closure effects for `model = "DyNAM"` with `subModel = "choice"` and `model = "REM"`.
Documentation is updated accordingly.

```R
cycle(list(bilatnet, contignet))
clSender(list(bilatnet, contignet))
clReceiver(list(bilatnet, contignet))
mixedCycle(list(bilatnet, contignet))
mixedClSender(list(bilatnet, contignet))
mixedClReceiver(list(bilatnet, contignet))
```

## Minor improvements and fixes

* Minor bugs in parsing and printing solved.
* Solves some warnings regarding S3 generic/method consistency.
* Solves no visible binding for global variables.
* Documentation improvements creating new documentation pages
aggregating similar functions on `print-method` and `update-method`.

## Breaking changes

* `tertius_diff()` and `node_trans()` are changed to `tertiusDiff()` and
`nodeTrans()` complaining with naming convention.

# goldfish 1.4.3

## New features
Expand Down
17 changes: 17 additions & 0 deletions R/Fisheries_Treaties_6070.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,20 @@
#'
#' @keywords datasets dynamic political network states fisheries
NULL

#' @rdname Fisheries_Treaties_6070
"bilatchanges"
#' @rdname Fisheries_Treaties_6070
"bilatnet"
#' @rdname Fisheries_Treaties_6070
"contigchanges"
#' @rdname Fisheries_Treaties_6070
"contignet"
#' @rdname Fisheries_Treaties_6070
"gdpchanges"
#' @rdname Fisheries_Treaties_6070
"regchanges"
#' @rdname Fisheries_Treaties_6070
"sovchanges"
#' @rdname Fisheries_Treaties_6070
"states"
60 changes: 60 additions & 0 deletions R/RFID_Validity_Study.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#' RFID Validity dataset
#'
#' Dataset collected at ETH Zürich by Timon Elmer and colleagues in order to
#' test the accuracy of Radio Frequency Identification (RFID) badges for
#' measuring social interactions.
#' Social interactions of 11 individuals (from the university staff) were
#' recorded with RFID badges in an informal setting. They were then compared to
#' the interactions observed by two confederates who watched the video recording
#' of the event. The RFID data went through the data processing procedure
#' detailed in the original article. See Elmer et al, 2019 for more details,
#' and the OSF platform for all details on the dataset.
#'
#' @name RFID_Validity_Study
#' @docType data
#' @usage data(RFID_Validity_Study)
#' @format 3 dataframes: \cr
#' - participants (11 rows, 7 columns): attributes of the experiment's participants\cr
#' - rfid (1011 rows, 4 columns): dyadic interactions detected by the RFID badges (after data processing)\cr
#' - video (219 rows, 4 columns): dyadic interactions detected by the video rating\cr
#' and one network:\cr
#' - known.before (11 rows, 11 columns): network of previous acquaintances\cr
#' See below for variables and formats.\cr
#'
#'\tabular{lll}{
#' \strong{Object} \tab \strong{Description} \tab \strong{Format} \cr
#' participants$actor \tab Identifier of the actor \tab integer \cr
#' participants$label \tab (Anonymized) name \tab Factor \cr
#' participants$present \tab Presence of the actor (all actors are present) \tab logical \cr
#' participants$age \tab Actor's age \tab integer \cr
#' participants$gender \tab Actor's gender (0: male, 1: female) \tab integer \cr
#' participants$group \tab Actor's group affiliation (groups have distinct ids) \tab integer \cr
#' participants$level \tab Actor's seniority (1: MSc student, 2: PhD student, 3: PostDoc, 4: Prof)
#' \tab integer \cr
#' rfid$NodeA \tab Identifier for the first actor \tab chr \cr
#' rfid$NodeB \tab Identifier for the second actor \tab chr \cr
#' rfid$Start \tab Time of the beginning of the dyadic interaction \tab integer \cr
#' rfid$End \tab Time of the end of the dyadic interaction \tab integer \cr
#' video$NodeA \tab Identifier for the first actor \tab chr \cr
#' video$NodeB \tab Identifier for the second actor \tab chr \cr
#' video$Start \tab Time of the beginning of the dyadic interaction \tab integer \cr
#' video$End \tab Time of the end of the dyadic interaction \tab integer \cr
#' }
#'
#' @source \url{https://osf.io/rrhxe/}
#' @references
#' Elmer, T., Chaitanya, K., Purwar, P., & Stadtfeld, C. (2019).
#' The validity of RFID badges measuring face-to-face interactions.
#' Behavior research methods, 1-19. \doi{10.3758/s13428-018-1180-y}
#'
#' @keywords datasets RFID validity study social interactions
NULL

#' @rdname RFID_Validity_Study
"rfid"
#' @rdname RFID_Validity_Study
"video"
#' @rdname RFID_Validity_Study
"known.before"
#' @rdname RFID_Validity_Study
"participants"
7 changes: 7 additions & 0 deletions R/Social_Evolution.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,10 @@
#'
#' @keywords datasets social evolution network
NULL

#' @rdname Social_Evolution
"actors"
#' @rdname Social_Evolution
"calls"
#' @rdname Social_Evolution
"friendship"
6 changes: 0 additions & 6 deletions R/functions_checks.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ forcePresence <- function(compositionChanges, events, nodes) {
}
compositionChanges <- compositionChanges[order(compositionChanges$time), ]

# TODO: trim down to a TRUE FALSE sequence
# for (node in compositionChanges$node) {
# trim <- rle(compositionChanges[compositionChanges$node==node,"replace"])
# compositionChanges <- compositionChanges[cumsum(c(1, trim$lengths[-length(trim$lengths)])),]
# }

return(compositionChanges)
}

Expand Down
Loading

0 comments on commit a9a51f3

Please sign in to comment.