Skip to content

Code review for public release.

-I have reviewed the code in the GitLab repository “code.usgs.gov/werc/dixon-field-station/Halstead-lab/giant-gartersnake-survival-analysis” and found no major issues. The code functioned as intended and produced results in the form of model comparison using AICc and two figures showing survival curves. Below are a few minor comments with suggestions for improving the clarity of the code.

-The code calls for the two csv files to be loaded from a folder named data but the repository does not contain such a folder. I recommend removing “data/” from the directory used to load the csv files. Alternatively, you could add a “data” folder to the GitLab repository, but because the data will not be stored in GitLab, I think it is better to remove “data/” from the directory.

-On line 82, instead of manually writing the AICc values for each model, it could be cleaner to call the AICc function as above on lines 71–79. For example:

aics <- c(AICc(ggs_cox_null), AICc(ggs_TG), AICc(ggs_T), AICc(ggs_act), AICc(ggs_TG_act), AICc(ggs_T_act),AICc(ggs_TG_dist), AICc(ggs_T_dist),AICc(ggs_dist))

-Correct “trtment” to “treatment” on line 34.

-Correct “transloacted” to “translocated” on line 36 (second use of word in the line).

-There is a typo on lines 86 and 170, should read “visualize” instead of “visulaize”

-The code ran without errors and produced the expected figures.

-The top model for adult survival according to AICc was “ggs_T” and included an effect of translocation on survival.

-The top model for juvenile survival according to AICc was the null model.

-It could be nice to have a few lines of code to produce an AIC model comparison table for each analysis. The data frame could have columns for model name, AICc, delta_AICc, rel_LL, and akaike_weight. I find that helpful for comparing models. Here is an example I put together for the adult survival analysis:

model.df <- as.data.frame(matrix(NA, nrow=9, ncol = 5))

colnames(model.df) <- c('model','AICc', 'delta_AICc','rel_LL','akaike_weights')

model.df$model <- c('cox_null','TG','T','T_act','TG_act','TG_dist', 'T_dist','act','dist')

model.df$AICc <- aics

model.df$deltaAICc <- akaike.weights(aics)$deltaAIC

model.df$rel.LL <- akaike.weights(aics)$rel.LL

model.df$akaike_weights <- akaike.weights(aics)$weights

Edited by Rose, Jonathan Patrick