A faculty member of the Psychology department at Bowling Green State University asked me to convert an algorithm from FORTRAN to Visual Basic, for use in a Monte Carlo simulation. The code was originally published in 1977 in the journal Applied Statistics. It computes the tetrachoric correlation and relevant standard errors of a standard 2x2 contingency table.
The tetrachoric correlation is similar to the phi coefficient but is used in cases where the underlying data is (assumed to be) normally distributed but dichotomized at some pair of thresholds. John Uebersax does a far better job of explaining it.
The original task was quite simple, as much of the code is directly translatable into Visual Basic. After searching the internet for other translations, I found that this algorithm had not been translated into any high-level languages, and also did not appear to be well documented.
The original articles were referenced to determine the purpose behind a few cryptic variables, and the inner workings of the algorithm are much more thoroughly explained in comments. The structure of the program has been heavily modified, with all line numbers removed and various code segments relocated. I thought about converting the code to Visual C++, but decided to leave it in Visual Basic so that it could be directly used in an Excel VBA environment. As it is, the code should be easily translatable to any high-level language.
If you wish to use my code module for any reason, please do not hesitate to let me know and I will give you a plain-text copy of the code. I would appreciate knowing that my code is being put to use.