2

I am using one-sample log-rank test in my paper. I use the implementation from this website http://www.ms.uky.edu/~mai/splus/LogRank1.r. I wonder whether I should cite this and how I can cite a function on a website in Latex.

1

2 Answers 2

3

If you use a script written by someone else, it is best to acknowledge them in some way. Citations are common, and many R packages define citations explicitly. Some authors will write papers documenting the code and publish them in journals, allowing you to cite the documentation rather than the code directly. However for one-off functions like your example, these options are usually not available. The information can be included in a footnote, or you can create a full citation.

You can cite an online resource in bibtex using the @online record and include the URL and access date. I would recommend the following bibtex record for this resource:

@online{zhoucode,
  author="Mai Zhou",
  title="LogRank1 function",
  url="http://www.ms.uky.edu/~mai/splus/LogRank1.r",
  addendum="Accessed: 26 May 2020"
}

In the latex document, you can cite this using \cite{zhoucode}

This should not be the only method by which a reader can access the source code. For reproducibility, it is best to make your analysis scripts publicly available for review so that future researchers can repeat your calculations exactly, and it is best to include a footnote in your text that links to a stable repository of your code. This can be accomplished in a number of ways.

  • @louic in another answer recommends publishing the script as supplemental materials (with the script writer's permission) which if available is the best option because the materials will always be available with the paper. This may not always be possible or reasonable depending on journals or the amount of code.
  • Some scholars use Github to host their materials and analysis scripts. Github is stable, publicly accessible, and maintains a history of changes made to your analysis scripts allowing review of the process and not simply the end point. Other public code repositories such as Bitbucket and sourceforge exist but are less popular in my experience.
  • If you preregister your experiment and analysis through the Open Science Foundation website, they allow uploads of analysis scripts. Preregistration is useful in its own right, but uploading your analysis scripts makes them available to others in a stable repository linked to your work.
  • Have the internet archive save the page and link to the archived copy. This solution is far worse than the above recommendations because it doesn't show how the script was used by you, only what the source code of that function was. While other methods should be used, this method is better than nothing.
1

Never cite a website as only source of information. Websites are likely to disappear in a few years time (especially academic ones unfortunately), or worse: the location stays the same but the code on the website is updated or changed.

In addition to that, the one who implements the algorithm is (more often than not) not its inventor. Maybe the algorithm has a name, or is published elsewhere?

A paper where this implementation of LogRank is explained would a better source for the citation. A reader should be able to access the exact code you used. The only good solution is to include the source code in your paper's supplementary information (with the author's consent). You can still cite the website if you like, but now the paper is reproducible if it disappears or changes.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .