diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index d26acb3..75c9e0c 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -1,3 +1,3 @@ -Version: 1.6.7 -Date: 2024-04-11 11:53:04 UTC -SHA: 859b5bcfafb03bd44ce97a810673b5fd943d92ef +Version: 1.6.8 +Date: 2024-04-11 15:22:41 UTC +SHA: e429a7b18059ead79de506ae04d0f10fd47db4e4 diff --git a/DESCRIPTION b/DESCRIPTION index 549046b..229e77f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,8 +2,8 @@ Encoding: UTF-8 Package: goldfish Type: Package Title: Statistical Network Models for Dynamic Network Data -Version: 1.6.8 -Date: 2024-04-11 +Version: 1.6.9 +Date: 2024-09-02 Authors@R: c(person("James", "Hollway", role = c("aut", "dtc"), email = "james.hollway@graduateinstitute.ch", comment = c("IHEID", ORCID = "0000-0002-8361-9647")), diff --git a/NEWS.md b/NEWS.md index 495f8f5..c3b7901 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# goldfish 1.6.9 + +* Solve issue on `Makevars.in` file that produced a note when check as CRAN. + # goldfish 1.6.8 * `checkEvents()` method addresses S3 generic/method consistency. diff --git a/README.Rmd b/README.Rmd index 6cd2661..170584d 100644 --- a/README.Rmd +++ b/README.Rmd @@ -24,7 +24,7 @@ library(goldfish) ![GitHub All Releases](https://img.shields.io/github/downloads/stocnet/goldfish/total) [![R-CMD-check](https://github.com/stocnet/goldfish/actions/workflows/R-CMD-check.yml/badge.svg)](https://github.com/stocnet/goldfish/actions/workflows/R-CMD-check.yml) [![Codecov test coverage](https://codecov.io/gh/stocnet/goldfish/branch/main/graph/badge.svg)](https://app.codecov.io/gh/stocnet/goldfish?branch=main) -[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/4563/badge)](https://bestpractices.coreinfrastructure.org/projects/4563) +[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/4563/badge)](https://www.bestpractices.dev/projects/4563) diff --git a/README.md b/README.md index 0787da2..a9fca70 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,8 @@ Releases](https://img.shields.io/github/downloads/stocnet/goldfish/total) [![R-CMD-check](https://github.com/stocnet/goldfish/actions/workflows/R-CMD-check.yml/badge.svg)](https://github.com/stocnet/goldfish/actions/workflows/R-CMD-check.yml) [![Codecov test coverage](https://codecov.io/gh/stocnet/goldfish/branch/main/graph/badge.svg)](https://app.codecov.io/gh/stocnet/goldfish?branch=main) -[![CII Best -Practices](https://bestpractices.coreinfrastructure.org/projects/4563/badge)](https://bestpractices.coreinfrastructure.org/projects/4563) +[![OpenSSF Best +Practices](https://www.bestpractices.dev/projects/4563/badge)](https://www.bestpractices.dev/projects/4563) diff --git a/configure b/configure index 9f3b3cf..06cedc5 100755 --- a/configure +++ b/configure @@ -2439,6 +2439,263 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +if test -z "$CXX"; then + if test -n "$CCC"; then + CXX=$CCC + else + if test -n "$ac_tool_prefix"; then + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 +$as_echo "$CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CXX" && break + done +fi +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 +$as_echo "$ac_ct_CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CXX" && break +done + + if test "x$ac_ct_CXX" = x; then + CXX="g++" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_ct_CXX + fi +fi + + fi +fi +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 +$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } +if ${ac_cv_cxx_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 +$as_echo "$ac_cv_cxx_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GXX=yes +else + GXX= +fi +ac_test_CXXFLAGS=${CXXFLAGS+set} +ac_save_CXXFLAGS=$CXXFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 +$as_echo_n "checking whether $CXX accepts -g... " >&6; } +if ${ac_cv_prog_cxx_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_cxx_werror_flag=$ac_cxx_werror_flag + ac_cxx_werror_flag=yes + ac_cv_prog_cxx_g=no + CXXFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cxx_g=yes +else + CXXFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + +else + ac_cxx_werror_flag=$ac_save_cxx_werror_flag + CXXFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cxx_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cxx_werror_flag=$ac_save_cxx_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 +$as_echo "$ac_cv_prog_cxx_g" >&6; } +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS=$ac_save_CXXFLAGS +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + # check openMP openmp_flag="" diff --git a/configure.ac b/configure.ac index f3e94a8..38693ae 100644 --- a/configure.ac +++ b/configure.ac @@ -22,6 +22,7 @@ CXXFLAGS=$("${R_HOME}/bin/R" CMD config CXXFLAGS) ## We are using C++ AC_LANG(C++) AC_REQUIRE_CPP +AC_PROG_CXX # check openMP openmp_flag="" diff --git a/src/Makevars.in b/src/Makevars.in index 3054ae4..ccd0d07 100644 --- a/src/Makevars.in +++ b/src/Makevars.in @@ -1,4 +1,5 @@ ## -*- mode: makefile; -*- +PKG_CPPFLAGS = -I../inst/include PKG_CXXFLAGS = @OPENMP_FLAG@ -PKG_LIBS= @OPENMP_CFLAG@ $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) +PKG_LIBS= @OPENMP_FLAG@ $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) diff --git a/vignettes/dynami-example.R b/vignettes/dynami-example.R index 82308f0..4a2fca2 100644 --- a/vignettes/dynami-example.R +++ b/vignettes/dynami-example.R @@ -1,67 +1,67 @@ -## ----setup, include=FALSE----------------------------------------------------- +## ----setup, include=FALSE----------------------------------------------------------------------------------- knitr::opts_chunk$set(echo = TRUE) -## ----load--------------------------------------------------------------------- +## ----load--------------------------------------------------------------------------------------------------- library(goldfish) data("RFID_Validity_Study") #?RFID_Validity_Study -## ----headParticipants--------------------------------------------------------- +## ----headParticipants--------------------------------------------------------------------------------------- head(participants) -## ----headRfid----------------------------------------------------------------- +## ----headRfid----------------------------------------------------------------------------------------------- head(rfid) -## ----headVideo---------------------------------------------------------------- +## ----headVideo---------------------------------------------------------------------------------------------- head(video) -## ----defGroups---------------------------------------------------------------- +## ----defGroups---------------------------------------------------------------------------------------------- #?defineGroups_interaction prepdata <- defineGroups_interaction(video, participants, seed.randomization = 1) -## ----assGroups---------------------------------------------------------------- +## ----assGroups---------------------------------------------------------------------------------------------- groups <- prepdata$groups head(groups) -## ----headDependent------------------------------------------------------------ +## ----headDependent------------------------------------------------------------------------------------------ dependent.events <- prepdata$dependent.events head(dependent.events) -## ----headExogenous------------------------------------------------------------ +## ----headExogenous------------------------------------------------------------------------------------------ exogenous.events <- prepdata$exogenous.events head(exogenous.events) -## ----headInteraction---------------------------------------------------------- +## ----headInteraction---------------------------------------------------------------------------------------- interaction.updates <- prepdata$interaction.updates head(interaction.updates) -## ----headOpportunities-------------------------------------------------------- +## ----headOpportunities-------------------------------------------------------------------------------------- opportunities <- prepdata$opportunities head(opportunities) -## ----defNodes----------------------------------------------------------------- +## ----defNodes----------------------------------------------------------------------------------------------- # goldfish requires character names participants$label <- as.character(participants$label) actors <- defineNodes(participants) -## ----groups------------------------------------------------------------------- +## ----groups------------------------------------------------------------------------------------------------- groups <- defineNodes(groups) -## ----defNet------------------------------------------------------------------- +## ----defNet------------------------------------------------------------------------------------------------- init.network <- diag(x = 1, nrow(actors), nrow(groups)) # goldfish check that row/column names agree with the nodes data frame labels dimnames(init.network) <- list(actors$label, groups$label) @@ -78,21 +78,21 @@ network.interactions <- linkEvents( ) -## ----defNetPast, warning=FALSE------------------------------------------------ +## ----defNetPast, warning=FALSE------------------------------------------------------------------------------ network.past <- defineNetwork(nodes = actors, directed = FALSE) network.past <- linkEvents( x = network.past, changeEvents = interaction.updates, nodes = actors ) # don't worry about the warnings -## ----defEvents---------------------------------------------------------------- +## ----defEvents---------------------------------------------------------------------------------------------- dependent.events <- defineDependentEvents( events = dependent.events, nodes = actors, nodes2 = groups, defaultNetwork = network.interactions ) -## ----modeRateM1--------------------------------------------------------------- +## ----modeRateM1--------------------------------------------------------------------------------------------- formula.rate.M1 <- dependent.events ~ 1 + intercept(network.interactions, joining = 1) + ego(actors$age, joining = 1, subType = "centered") + @@ -104,7 +104,7 @@ formula.rate.M1 <- dependent.events ~ 1 + tie(known.before, joining = -1, subType = "proportion") -## ----modeChoiceM1------------------------------------------------------------- +## ----modeChoiceM1------------------------------------------------------------------------------------------- formula.choice.M1 <- dependent.events ~ diff(actors$age, subType = "averaged_sum") + diff(actors$level, subType = "averaged_sum") + @@ -113,12 +113,12 @@ formula.choice.M1 <- dependent.events ~ tie(known.before, subType = "proportion") -## ----modRateM1Est------------------------------------------------------------- +## ----modRateM1Est------------------------------------------------------------------------------------------- est.rate.M1 <- estimate(formula.rate.M1, model = "DyNAMi", subModel = "rate") summary(est.rate.M1) -## ----modChoiceM1Est----------------------------------------------------------- +## ----modChoiceM1Est----------------------------------------------------------------------------------------- est.choice.M1 <- estimate( formula.choice.M1, model = "DyNAMi", subModel = "choice", @@ -127,7 +127,7 @@ est.choice.M1 <- estimate( summary(est.choice.M1) -## ----modeRateM2--------------------------------------------------------------- +## ----modeRateM2--------------------------------------------------------------------------------------------- formula.rate.M2 <- dependent.events ~ 1 + intercept(network.interactions, joining = 1) + ego(actors$age, joining = 1, subType = "centered") + @@ -142,7 +142,7 @@ formula.rate.M2 <- dependent.events ~ 1 + egopop(network.past, joining = -1, subType = "normalized") -## ----modeChoiceM2------------------------------------------------------------- +## ----modeChoiceM2------------------------------------------------------------------------------------------- formula.choice.M2 <- dependent.events ~ diff(actors$age, subType = "averaged_sum") + diff(actors$level, subType = "averaged_sum") + @@ -156,12 +156,12 @@ formula.choice.M2 <- dependent.events ~ inertia(network.past, window = 300, subType = "mean") -## ----modRateM2Est------------------------------------------------------------- +## ----modRateM2Est------------------------------------------------------------------------------------------- est.rate.M2 <- estimate(formula.rate.M2, model = "DyNAMi", subModel = "rate") summary(est.rate.M2) -## ----modChoiceM2Est----------------------------------------------------------- +## ----modChoiceM2Est----------------------------------------------------------------------------------------- est.choice.M2 <- estimate( formula.choice.M2, model = "DyNAMi", subModel = "choice", @@ -170,7 +170,7 @@ est.choice.M2 <- estimate( summary(est.choice.M2) -## ----interceptJoining--------------------------------------------------------- +## ----interceptJoining--------------------------------------------------------------------------------------- cov.matrix <- vcov(est.rate.M2) est.interceptjoining <- coef(est.rate.M2)[1] + coef(est.rate.M2)[2] diff --git a/vignettes/precompile.R b/vignettes/precompile.R index 708380b..78ba45e 100644 --- a/vignettes/precompile.R +++ b/vignettes/precompile.R @@ -77,4 +77,3 @@ rmarkdown::render( output_format = "md_document", envir = globalenv() ) - diff --git a/vignettes/teaching/plot-examine-1.png b/vignettes/teaching/plot-examine-1.png index 07b863f..68b498a 100644 Binary files a/vignettes/teaching/plot-examine-1.png and b/vignettes/teaching/plot-examine-1.png differ diff --git a/vignettes/teaching/plot-teaching1-1.png b/vignettes/teaching/plot-teaching1-1.png index a4dddb6..1ede483 100644 Binary files a/vignettes/teaching/plot-teaching1-1.png and b/vignettes/teaching/plot-teaching1-1.png differ diff --git a/vignettes/teaching/plot-teaching1-2.png b/vignettes/teaching/plot-teaching1-2.png index 2af2709..ee68100 100644 Binary files a/vignettes/teaching/plot-teaching1-2.png and b/vignettes/teaching/plot-teaching1-2.png differ diff --git a/vignettes/teaching/plot-teaching1-3.png b/vignettes/teaching/plot-teaching1-3.png index ac2c9a7..38f603f 100644 Binary files a/vignettes/teaching/plot-teaching1-3.png and b/vignettes/teaching/plot-teaching1-3.png differ diff --git a/vignettes/teaching/plot-teaching2-1.png b/vignettes/teaching/plot-teaching2-1.png index ed536bb..b78167c 100644 Binary files a/vignettes/teaching/plot-teaching2-1.png and b/vignettes/teaching/plot-teaching2-1.png differ diff --git a/vignettes/teaching1.R b/vignettes/teaching1.R index 08adc0c..1d64d78 100644 --- a/vignettes/teaching1.R +++ b/vignettes/teaching1.R @@ -1,4 +1,4 @@ -## ----load, message=FALSE------------------------------------------------------ +## ----load, message=FALSE------------------------------------------------------------------------------------ library(goldfish) data("Social_Evolution") # ?Social_Evolution @@ -8,7 +8,7 @@ head(actors) -## ----quick-------------------------------------------------------------------- +## ----quick-------------------------------------------------------------------------------------------------- callNetwork <- defineNetwork(nodes = actors, directed = TRUE) |> # 1 linkEvents(changeEvent = calls, nodes = actors) # 2 @@ -34,42 +34,42 @@ mod00Choice <- estimate( summary(mod00Choice) -## ----actors------------------------------------------------------------------- +## ----actors------------------------------------------------------------------------------------------------- class(actors) head(actors) -## ----define-actors------------------------------------------------------------ +## ----define-actors------------------------------------------------------------------------------------------ actors <- defineNodes(actors) actors -## ----calls-events------------------------------------------------------------- +## ----calls-events------------------------------------------------------------------------------------------- head(calls) -## ----hlp1, eval=FALSE--------------------------------------------------------- +## ----hlp1, eval=FALSE--------------------------------------------------------------------------------------- ## ?defineNetwork -## ----call-net----------------------------------------------------------------- +## ----call-net----------------------------------------------------------------------------------------------- callNetwork <- defineNetwork(nodes = actors, directed = TRUE) -## ----strNet------------------------------------------------------------------- +## ----strNet------------------------------------------------------------------------------------------------- callNetwork -## ----hlp2, eval=FALSE--------------------------------------------------------- +## ----hlp2, eval=FALSE--------------------------------------------------------------------------------------- ## ?linkEvents -## ----link-call-net------------------------------------------------------------ +## ----link-call-net------------------------------------------------------------------------------------------ callNetwork <- linkEvents(x = callNetwork, changeEvent = calls, nodes = actors) callNetwork -## ----frdshp-net--------------------------------------------------------------- +## ----frdshp-net--------------------------------------------------------------------------------------------- head(friendship) friendshipNetwork <- defineNetwork(nodes = actors, directed = TRUE) friendshipNetwork <- linkEvents( @@ -80,11 +80,11 @@ friendshipNetwork <- linkEvents( friendshipNetwork -## ----hlp3, eval=FALSE--------------------------------------------------------- +## ----hlp3, eval=FALSE--------------------------------------------------------------------------------------- ## ?defineDependentEvents -## ----call-dep-events---------------------------------------------------------- +## ----call-dep-events---------------------------------------------------------------------------------------- callsDependent <- defineDependentEvents( events = calls, nodes = actors, defaultNetwork = callNetwork @@ -92,7 +92,7 @@ callsDependent <- defineDependentEvents( callsDependent -## ----plot-teaching1, message=FALSE, warning=FALSE----------------------------- +## ----plot-teaching1, message=FALSE, warning=FALSE----------------------------------------------------------- library(igraph) library(ggraph) library(migraph) @@ -124,15 +124,15 @@ autographr(callNetworkEnd, labels = FALSE, layout = "fr") + table(as.matrix(callNetwork, time = max(calls$time) + 1)) -## ----effects, eval=FALSE------------------------------------------------------ +## ----effects, eval=FALSE------------------------------------------------------------------------------------ ## vignette("goldfishEffects") -## ----simple-formula----------------------------------------------------------- +## ----simple-formula----------------------------------------------------------------------------------------- simpleFormulaChoice <- callsDependent ~ tie(friendshipNetwork) -## ----simple-choice------------------------------------------------------------ +## ----simple-choice------------------------------------------------------------------------------------------ mod01Choice <- estimate( simpleFormulaChoice, model = "DyNAM", subModel = "choice" @@ -140,7 +140,7 @@ mod01Choice <- estimate( summary(mod01Choice) -## ----complex-choice----------------------------------------------------------- +## ----complex-choice----------------------------------------------------------------------------------------- complexFormulaChoice <- callsDependent ~ inertia(callNetwork) + recip(callNetwork) + tie(friendshipNetwork) + recip(friendshipNetwork) + @@ -153,7 +153,7 @@ mod02Choice <- estimate( summary(mod02Choice) -## ----simple-rate-------------------------------------------------------------- +## ----simple-rate-------------------------------------------------------------------------------------------- simpleFormulaRate <- callsDependent ~ indeg(friendshipNetwork) mod01Rate <- estimate( simpleFormulaRate, @@ -161,7 +161,7 @@ mod01Rate <- estimate( ) -## ----estimate-init------------------------------------------------------------ +## ----estimate-init------------------------------------------------------------------------------------------ mod01Rate <- estimate( simpleFormulaRate, model = "DyNAM", subModel = "rate", @@ -170,7 +170,7 @@ mod01Rate <- estimate( summary(mod01Rate) -## ----complex-rate------------------------------------------------------------- +## ----complex-rate------------------------------------------------------------------------------------------- complexFormulaRate <- callsDependent ~ indeg(callNetwork) + outdeg(callNetwork) + indeg(friendshipNetwork) @@ -179,7 +179,7 @@ mod02Rate <- estimate(complexFormulaRate, model = "DyNAM", subModel = "rate") summary(mod02Rate) -## ----intcpt-rate-------------------------------------------------------------- +## ----intcpt-rate-------------------------------------------------------------------------------------------- interceptFormulaRate <- callsDependent ~ 1 + indeg(callNetwork) + outdeg(callNetwork) + indeg(friendshipNetwork) @@ -188,7 +188,7 @@ mod03Rate <- estimate(interceptFormulaRate, model = "DyNAM", subModel = "rate") summary(mod03Rate) -## ----waiting-time------------------------------------------------------------- +## ----waiting-time------------------------------------------------------------------------------------------- mod03RateCoef <- coef(mod03Rate) 1 / exp(mod03RateCoef[["Intercept"]]) / 3600 # or days: @@ -209,7 +209,7 @@ mod03RateCoef <- coef(mod03Rate) ) / 3600 -## ----windows-rate------------------------------------------------------------- +## ----windows-rate------------------------------------------------------------------------------------------- windowFormulaRate <- callsDependent ~ 1 + indeg(callNetwork) + outdeg(callNetwork) + indeg(callNetwork, window = 300) + @@ -220,7 +220,7 @@ mod04Rate <- estimate(windowFormulaRate, model = "DyNAM", subModel = "rate") summary(mod04Rate) -## ----windows-choice----------------------------------------------------------- +## ----windows-choice----------------------------------------------------------------------------------------- windowFormulaChoice <- callsDependent ~ inertia(callNetwork) + recip(callNetwork) + inertia(callNetwork, window = 300) + @@ -233,7 +233,7 @@ mod03Choice <- estimate(windowFormulaChoice, summary(mod03Choice) -## ----aic---------------------------------------------------------------------- +## ----aic---------------------------------------------------------------------------------------------------- # Compare different specifications of the subModel = "choice" AIC(mod02Choice, mod03Choice) @@ -241,7 +241,7 @@ AIC(mod02Choice, mod03Choice) AIC(mod03Rate, mod04Rate) -## ----rem---------------------------------------------------------------------- +## ----rem---------------------------------------------------------------------------------------------------- allFormulaREM <- callsDependent ~ 1 + indeg(callNetwork, type = "ego") + outdeg(callNetwork, type = "ego") + @@ -252,14 +252,14 @@ allFormulaREM <- same(actors$gradeType) + same(actors$floor) -## ----rem-gather, eval=FALSE--------------------------------------------------- +## ----rem-gather, eval=FALSE--------------------------------------------------------------------------------- ## mod01REM <- estimate( ## allFormulaREM, model = "REM", ## estimationInit = list(initialDamping = 40, engine = "default_c") ## ) -## ----rem-c-------------------------------------------------------------------- +## ----rem-c-------------------------------------------------------------------------------------------------- mod01REM <- estimate( allFormulaREM, model = "REM", estimationInit = list(engine = "gather_compute") diff --git a/vignettes/teaching1.Rmd b/vignettes/teaching1.Rmd index 59af564..afe7128 100644 --- a/vignettes/teaching1.Rmd +++ b/vignettes/teaching1.Rmd @@ -824,8 +824,7 @@ AIC(mod02Choice, mod03Choice) # Compare different specifications of the subModel = "rate" AIC(mod03Rate, mod04Rate) -#> Warning in AIC.default(mod03Rate, mod04Rate): models are not all fitted to the -#> same number of observations +#> Warning in AIC.default(mod03Rate, mod04Rate): models are not all fitted to the same number of observations #> df AIC #> mod03Rate 4 12014.20 #> mod04Rate 6 10963.75 diff --git a/vignettes/teaching2.R b/vignettes/teaching2.R index c9c9b3f..16a5428 100644 --- a/vignettes/teaching2.R +++ b/vignettes/teaching2.R @@ -1,76 +1,76 @@ -## ----setup, message=FALSE----------------------------------------------------- +## ----setup, message=FALSE----------------------------------------------------------------------------------- library(goldfish) -## ----load-data---------------------------------------------------------------- +## ----load-data---------------------------------------------------------------------------------------------- data("Fisheries_Treaties_6070") # ?Fisheries_Treaties_6070 -## ----examine-states----------------------------------------------------------- +## ----examine-states----------------------------------------------------------------------------------------- tail(states) class(states) -## ----defineNodes-------------------------------------------------------------- +## ----defineNodes-------------------------------------------------------------------------------------------- states <- defineNodes(states) head(states) class(states) -## ----examine-node-changes----------------------------------------------------- +## ----examine-node-changes----------------------------------------------------------------------------------- head(sovchanges) head(regchanges) head(gdpchanges) -## ----present------------------------------------------------------------------ +## ----present------------------------------------------------------------------------------------------------ head(states$present) # or states[,2] -## ----link-present------------------------------------------------------------- +## ----link-present------------------------------------------------------------------------------------------- states <- linkEvents(states, sovchanges, attribute = "present") # If you call the object now, what happens? states -## ----states------------------------------------------------------------------- +## ----states------------------------------------------------------------------------------------------------- str(states) -## ----link-states-vars--------------------------------------------------------- +## ----link-states-vars--------------------------------------------------------------------------------------- states <- linkEvents(states, regchanges, attribute = "regime") |> linkEvents(gdpchanges, attribute = "gdp") str(states) -## ----examine-bilat-mat-------------------------------------------------------- +## ----examine-bilat-mat-------------------------------------------------------------------------------------- bilatnet[1:12, 1:12] # head(bilatnet, n = c(12, 12)) -## ----define-bilat-net--------------------------------------------------------- +## ----define-bilat-net--------------------------------------------------------------------------------------- bilatnet <- defineNetwork(bilatnet, nodes = states, directed = FALSE) -## ----examine-bilat-net-------------------------------------------------------- +## ----examine-bilat-net-------------------------------------------------------------------------------------- class(bilatnet) str(bilatnet) bilatnet -## ----link-bilat-net----------------------------------------------------------- +## ----link-bilat-net----------------------------------------------------------------------------------------- bilatnet <- linkEvents(bilatnet, bilatchanges, nodes = states) bilatnet -## ----contig-net--------------------------------------------------------------- +## ----contig-net--------------------------------------------------------------------------------------------- contignet <- defineNetwork(contignet, nodes = states, directed = FALSE) |> linkEvents(contigchanges, nodes = states) class(contignet) contignet -## ----define-dep-events-------------------------------------------------------- +## ----define-dep-events-------------------------------------------------------------------------------------- createBilat <- defineDependentEvents( events = bilatchanges[bilatchanges$increment == 1,], nodes = states, @@ -78,17 +78,17 @@ createBilat <- defineDependentEvents( ) -## ----examine-dep-events------------------------------------------------------- +## ----examine-dep-events------------------------------------------------------------------------------------- class(createBilat) createBilat -## ----hlp, eval = FALSE-------------------------------------------------------- +## ----hlp, eval = FALSE-------------------------------------------------------------------------------------- ## ?as.data.frame.nodes.goldfish ## ?as.matrix.network.goldfish -## ----plot-teaching2, message=FALSE, warning=FALSE, fig.align='center'--------- +## ----plot-teaching2, message=FALSE, warning=FALSE, fig.align='center'--------------------------------------- library(igraph) library(manynet) @@ -123,11 +123,11 @@ endNet <- delete_nodes(endNet, !isStateActive) autographs(list(startNet, endNet), layout = "fr") -## ----hlp-effects, eval=FALSE-------------------------------------------------- +## ----hlp-effects, eval=FALSE-------------------------------------------------------------------------------- ## vignette("goldfishEffects") -## ----estimate-init------------------------------------------------------------ +## ----estimate-init------------------------------------------------------------------------------------------ formula1 <- createBilat ~ inertia(bilatnet) + indeg(bilatnet, ignoreRep = TRUE) + trans(bilatnet, ignoreRep = TRUE) + @@ -150,7 +150,7 @@ system.time( ) -## ----estimate-rerun----------------------------------------------------------- +## ----estimate-rerun----------------------------------------------------------------------------------------- estPrefs <- list( returnIntervalLogL = TRUE, initialDamping = 40, @@ -166,7 +166,7 @@ partnerModel <- estimate( summary(partnerModel) -## ----estimate-c--------------------------------------------------------------- +## ----estimate-c--------------------------------------------------------------------------------------------- formula2 <- createBilat ~ inertia(bilatnet, weighted = TRUE) + indeg(bilatnet) + trans(bilatnet) + @@ -189,7 +189,7 @@ system.time( ) -## ----broom, message=FALSE----------------------------------------------------- +## ----broom, message=FALSE----------------------------------------------------------------------------------- library(broom) library(pixiedust) dust(tidy(tieModel, conf.int = TRUE)) |> @@ -197,11 +197,11 @@ dust(tidy(tieModel, conf.int = TRUE)) |> sprinkle(col = 5, fn = quote(pvalString(value))) -## ----glance------------------------------------------------------------------- +## ----glance------------------------------------------------------------------------------------------------- glance(tieModel) -## ----plot-examine, fig.width=6, fig.height=4, fig.align='center', fig.retina=3---- +## ----plot-examine, fig.width=6, fig.height=4, fig.align='center', fig.retina=3------------------------------ examineOutliers(tieModel) examineChangepoints(tieModel) diff --git a/vignettes/teaching2.Rmd b/vignettes/teaching2.Rmd index d5769dc..038ddff 100644 --- a/vignettes/teaching2.Rmd +++ b/vignettes/teaching2.Rmd @@ -97,12 +97,12 @@ and they all change: ```r head(sovchanges) #> time node replace -#> 1165 1960-04-03 00:00:00 SEN TRUE -#> 99 1960-04-26 23:00:00 TGO TRUE -#> 1317 1960-05-31 00:00:00 COD TRUE -#> 1316 1960-05-31 00:00:00 MLI TRUE -#> 100 1960-06-19 23:00:00 MLI TRUE -#> 101 1960-06-25 23:00:00 MDG TRUE +#> 1165 1960-04-03 01:00:00 SEN TRUE +#> 99 1960-04-27 00:00:00 TGO TRUE +#> 1317 1960-05-31 01:00:00 COD TRUE +#> 1316 1960-05-31 01:00:00 MLI TRUE +#> 100 1960-06-20 00:00:00 MLI TRUE +#> 101 1960-06-26 00:00:00 MDG TRUE head(regchanges) #> time node replace #> 814 1960-01-02 LAO -1 @@ -405,9 +405,7 @@ isStateActive <- isStateActiveStart | isStateActiveEnd # subset networks to active states startNet <- delete_nodes(startNet, !isStateActive) -#> Error in as_igraph_vs(graph, v): Invalid vertex name(s) endNet <- delete_nodes(endNet, !isStateActive) -#> Error in as_igraph_vs(graph, v): Invalid vertex name(s) autographs(list(startNet, endNet), layout = "fr") ``` @@ -465,10 +463,9 @@ system.time( estimationInit = estPrefs ) ) -#> Warning: engine = "gather_compute" doesn't support ignoreRep effects. engine -#> ="default" is used instead. +#> Warning: engine = "gather_compute" doesn't support ignoreRep effects. engine ="default" is used instead. #> user system elapsed -#> 155.338 25.566 187.693 +#> 165.86 5.52 172.30 ``` Did the model converge? If not, you can restart the estimation process using @@ -488,8 +485,7 @@ partnerModel <- estimate( model = "DyNAM", subModel = "choice_coordination", estimationInit = estPrefs ) -#> Warning: engine = "gather_compute" doesn't support ignoreRep effects. engine -#> ="default" is used instead. +#> Warning: engine = "gather_compute" doesn't support ignoreRep effects. engine ="default" is used instead. summary(partnerModel) #> #> Call: @@ -562,7 +558,7 @@ system.time( ) ) #> user system elapsed -#> 78.661 3.410 83.567 +#> 101.64 0.40 100.70 ``` # Extensions... @@ -581,6 +577,7 @@ Here is an example on the current results object: ```r library(broom) library(pixiedust) +#> Warning: package 'pixiedust' was built under R version 4.3.3 dust(tidy(tieModel, conf.int = TRUE)) |> sprinkle(col = c(2:4, 6, 7), round = 3) |> sprinkle(col = 5, fn = quote(pvalString(value)))