Description of S-Plus Programs. The following text describes how the programs are organized and how they can be used to fit the latent class model
using the MCMC algorithm and how to create the plots and displays presented in this thesis. These programs can be found
at the following website: The programs are organized into 3 main folders: LCM, LCR, and VALIDITY. Folders/directories are in capital letters and
filenames are in lowercase letters. The LCM folder contains all of the programs used for fitting the latent class model
using the algorithm described in Chapter 3 and creating the graphics presented in Chapter 4. The LCR folder contains
the MCMC algorithm for fitting the latent class regression model outlined in Chapter 3 and the graphics presented in Chapter 5.
The VALIDITY folder contains all programs used to create the sensitivity, specificity, positive predictive value and negative
predictive value plots from Chapter 7. LCM STEP1 step1a.txt: This is the "batch file" that runs the latent class model. If running the latent class model program, all one needs to do is edit this file to choose the number of classes, number of iterations, input data, output files, prior distributions, etc. It reads in all of the appropriate programs, but needs to be editted so that the program knows where the programs are. The other necessary files in this folder are sourced into Splus via step1a.txt small.txt: collapses Nxk data binary matrix into matrix with 2^k rows and a vector representing the number of individuals with each pattern. poster.txt: calculates posterior probability of each pattern given p and pi. fc.txt: defines the full-conditional distributions used in the MCMC algorithm. env.txt: defines "envelope" or "candidate" distributions for Metropolis-Hasting steps in the MCMC algorithm. iter.txt: defines one iteration of the algorithm. mcinit.txt: selects initial values for MCMC algorithm lcstdi.txt: program that fits the latent class model using maximum likelihood with a Newton-Raphson algorithm. step1b.txt: Reads in output from result of step1.txt. Needs to be editted to call in correct output files. step1c.txt: Produce traceplots of certain parameters. step1d.txt: Calculate lag correlation of parameters between iterations. STEP2 step2.txt: Performs post-processing algorithm. Reads in other programs in this folder. cp2.txt, cp3.txt, cp4.txt: Calculate conditional probabilities for class given pattern cp2z.txt,cp3z.txt, cp4z.txt: Apply optimal permutation to output. STEP3 step3.txt: Calculates the non-parametric estimates from data (e.g. 95% confidence interval based on saturated model). PFC pfc1.txt: Calculates posterior distributions of pattern frequencies. Reads in sensg.txt. sensg.txt: Calculates expected pattern frequencies for one iterations. pfc2.txt: Makes histogram of posterior distributions for pattern frequencies pfc3.txt: Makes PFC plot LORC lorc1.txt: Calculates log odds ratios at each iteration lorc2.txt: Makes traceplots of log odds ratios lorc3.txt: Plots posterior densities of log odds ratios lorc4.txt: Make LORC plot LCED lced.txt: Makes LCED. PCAD pcad1.txt: Defines functions and sets up data for PCAD pcad2.txt: Makes PCAD LCR STEP1 (Note: all files in this folder are analogous to those in LCM/STEP1) step1a.txt poster.txt small.txt fc.txt iter.txt mcinit.txt lcstdi.txt step1b.txt LCRR lcrr.txt: Makes latent class regression residual plot. Reads in sensg.txt. sensg.txt: Calculates expected pattern frequency at one iteration. LCED lced.txt: Makes LCED for LCR VALIDITY diagnostic.txt: Defines individuals in a dataset as "depressed" or "not depressed" using 5 diagnostic criteria. sens.txt: Calculates sensitivity of diagnosis at each iteration under assumption that latent class model is "gold standard." spec.txt: Analogous to sens.txt but for specificity. ppv.txt: Analogous to sens.txt but for positive predictive value. npv.txt: Analogous to sens.txt but for negative predictive value. traceplots.txt: Make traceplots of 4 sens, spec, ppv, and npv. densities.txt: Calculate 2.5th, 50th, and 97.5th percentiles of posterior distributions. se-sp.txt: Make sensitivity-specificity plot as in Chapter 7. ppv-npv.txt: Make ppv-npv plot as in Chapter 7. USING THESE PROGRAMS: Fitting the LCM: To fit the LCM, edit the step1a.txt batch file and submit to Splus. When it is finished running, you will have output files containing the parameter draws from each saved iteration. These are read back into Splus using step1b.txt. step1c.txt can then be used to make traceplots of p and pi. step1d.txt can then be used to calculate lag correlations. If these are high, you may want to consider using larger "skip" parameter. step2.txt is then used for post-processing--it corrects for any class "label-switching." Next, run step3.txt to calculate estimates from saturated model. The remaining programs in the LCM folder are used to create the graphics presented in this thesis. Each of the folders has "numbered" programs. Run each in succession (i.e. run pfc1.txt, then pfc2.txt, then pfc3.txt, etc.) Fitting the LCR: Same idea as LCM. Validity measures: These programs should be run in the order that they are listed above. GENERAL COMMENTS: Be sure that the correct data directory is specified! All of these programs (or most) begin by "attaching" an Splus data directory.
This tells Splus where to read from and write to. It is VERY important to make sure this is correct.
These programs can be used with Splus for Windows or for Unix. However, if you are using Splus for Windows, you will need to edit
programs to use the appropriate graphics device. These programs create "postscript" files using the postscript command which is not
available in Splus for Windows.
If you have problems accessing the files, you may email at esg@jhu.edu.