Company socioeconomic and demographic diversity was the single most important predictor of desertion [in the Civil War].
Age and occupational diversity were especially important. For all-black regiments, former slave status (or not) and plantation of origin are important diversity measures for predicting desertion.
That is from the forthcoming book by Dora L. Costa and Matthew E. Kahn. I have not yet finished it but I believe this book will make a big splash. Here is the book’s home page. Here is a blog post by Matt Kahn on the book. Here is Matt Kahn on holding hands.