From f5e3ffeb6ab7df29377331a3d667209022fb5cca Mon Sep 17 00:00:00 2001 From: derek-corcoran-barrios Date: Mon, 28 Dec 2020 09:47:48 -0300 Subject: [PATCH] re-fixed degree distribution --- NAMESPACE | 3 +- R/Extintions.R | 3 ++ R/Powerlaw.R | 2 +- man/CompareExtinctions.Rd | 4 +- ...eDistribution.Rd => DegreeDistribution.Rd} | 6 +-- man/Mostconnected.Rd | 4 +- man/SimulateExtinctions.Rd | 42 +++++++++++++++++++ ...w_to_use_the_NetworkExtinction_Package.Rmd | 6 +-- 8 files changed, 58 insertions(+), 12 deletions(-) rename man/{DergreeDistribution.Rd => DegreeDistribution.Rd} (93%) create mode 100644 man/SimulateExtinctions.Rd diff --git a/NAMESPACE b/NAMESPACE index 61f418f..b03e44e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,11 +1,12 @@ # Generated by roxygen2: do not edit by hand export(CompareExtinctions) -export(DergreeDistribution) +export(DegreeDistribution) export(ExtinctionOrder) export(ExtinctionPlot) export(Mostconnected) export(RandomExtinctions) +export(SimulateExtinctions) importFrom(MASS,fitdistr) importFrom(broom,augment) importFrom(broom,glance) diff --git a/R/Extintions.R b/R/Extintions.R index 9dbcbbb..8fdc55e 100644 --- a/R/Extintions.R +++ b/R/Extintions.R @@ -22,6 +22,9 @@ #' @examples #' data("net") #' SimulateExtinctions(Network = net, Method = "Mostconnected") +#' @author Derek Corcoran +#' @author M.Isidora Avila Thieme +#' @export SimulateExtinctions <- function(Network, Method){ diff --git a/R/Powerlaw.R b/R/Powerlaw.R index a09239a..ca5a8d4 100644 --- a/R/Powerlaw.R +++ b/R/Powerlaw.R @@ -55,7 +55,7 @@ #' @export -DergreeDistribution <- function(Network, scale = "arithmetic"){ +DegreeDistribution <- function(Network, scale = "arithmetic"){ AIC <- Cumulative <- Exp <- fit <- model <- LogPower <- logLik <- BIC <- Power <- Normal.Resid <- LogExp <- family <- AICcNorm <- NULL totaldegree<- degree(Network) K <- 0:max(totaldegree) diff --git a/man/CompareExtinctions.Rd b/man/CompareExtinctions.Rd index 14f0d82..8e9ac18 100644 --- a/man/CompareExtinctions.Rd +++ b/man/CompareExtinctions.Rd @@ -9,7 +9,7 @@ CompareExtinctions(Nullmodel, Hypothesis) \arguments{ \item{Nullmodel}{an object generated by the RandomExtinctions} -\item{Hypothesis}{Extinction history generated by the Mostconected or ExtinctionOrder +\item{Hypothesis}{Extinction history generated by the Mostconnected or ExtinctionOrder fuction} } \value{ @@ -17,7 +17,7 @@ a plot comparing the expected value of secondary extinctions originated at rando with the observed extinction history. } \description{ -It compares an object genrated either by the Mostconected or ExtinctionOrder functions +It compares an object genrated either by the Mostconnected or ExtinctionOrder functions with a null hypothesis generated by the RandomExtinctions function and it tests weather they are significantly different. } diff --git a/man/DergreeDistribution.Rd b/man/DegreeDistribution.Rd similarity index 93% rename from man/DergreeDistribution.Rd rename to man/DegreeDistribution.Rd index 7995052..4962f6f 100644 --- a/man/DergreeDistribution.Rd +++ b/man/DegreeDistribution.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/Powerlaw.R -\name{DergreeDistribution} -\alias{DergreeDistribution} +\name{DegreeDistribution} +\alias{DegreeDistribution} \title{Degree distribution of the network} \usage{ -DergreeDistribution(Network, scale = "arithmetic") +DegreeDistribution(Network, scale = "arithmetic") } \arguments{ \item{Network}{a trophic network of class network} diff --git a/man/Mostconnected.Rd b/man/Mostconnected.Rd index c6320ed..e92b8dd 100644 --- a/man/Mostconnected.Rd +++ b/man/Mostconnected.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/Extintions.R \name{Mostconnected} \alias{Mostconnected} -\title{Extinctions analysis from most connected to less conected nodes in the network} +\title{Extinctions analysis from most connected to less connected nodes in the network} \usage{ Mostconnected(Network) } @@ -16,7 +16,7 @@ topological index, the secondary extinctions, predation release, and total extin in each primary extinction. } \description{ -It takes a network and it calculates wich node is the most conected +It takes a network and it calculates wich node is the most connected of the network, using total degree. Then remove the most connected node, and calculates the the topological indexes of the network and the number of secundary extintions (how many species have indegree 0, without considered diff --git a/man/SimulateExtinctions.Rd b/man/SimulateExtinctions.Rd new file mode 100644 index 0000000..46cbe85 --- /dev/null +++ b/man/SimulateExtinctions.Rd @@ -0,0 +1,42 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/Extintions.R +\name{SimulateExtinctions} +\alias{SimulateExtinctions} +\title{Extinctions analysis for trophic networks} +\usage{ +SimulateExtinctions(Network, Method) +} +\arguments{ +\item{Network}{a trophic network of class network} + +\item{Method}{a character with the options Mostconnected, Oredered, or Random} +} +\value{ +exports data frame with the characteristics of the network after every +extintion. The resulting data frame contains 11 columns that incorporate the +topological index, the secondary extinctions, predation release, and total extinctions of the network +in each primary extinction. +} +\description{ +The SimulateExtinctions function, can be used to test how the order of species +extinctions might affect the stability of the network by comparing The extintion history +and checking for secondary extinctions. +} +\details{ +When method is Mostconnected, it takes a network and it calculates wich node is the most connected +of the network, using total degree. Then remove the most connected node, +and calculates the the topological indexes of the network and the number of +secundary extintions (how many species have indegree 0, without considered +primary producers). After that, remove the nodes that were secondarily extinct +in the previous step and recalculate which is the new most connected +node and so on, until the number of links in the network is zero. +} +\examples{ +data("net") +SimulateExtinctions(Network = net, Method = "Mostconnected") +} +\author{ +Derek Corcoran + +M.Isidora Avila Thieme +} diff --git a/vignettes/How_to_use_the_NetworkExtinction_Package.Rmd b/vignettes/How_to_use_the_NetworkExtinction_Package.Rmd index 5e71df4..11ba2aa 100644 --- a/vignettes/How_to_use_the_NetworkExtinction_Package.Rmd +++ b/vignettes/How_to_use_the_NetworkExtinction_Package.Rmd @@ -173,14 +173,14 @@ RandomExtinctions(Network= net, nsim= 100) ```{r, echo = FALSE} data(net) -set.seed(123) -Test <- RandomExtinctions(Network= net, nsim= 50) +set.seed(707) +Test <- RandomExtinctions(Network= net, nsim= 100) knitr::kable(Test$sims, caption = "Table 3: The resulting dataframe of the RandomExtinctions function") ``` ```{r, echo = FALSE, fig.cap= "Figure 5. The resulting graph of the RandomExtinctions function"} data(net) -set.seed(123) +set.seed(707) Test$graph ```