Skip to content
Prev 294072 / 398503 Next

Random resampling of columns in species association matrices

Sample data would make it possible to explore the options in more detail,
but here are two possibilities:

1. Convert each row of the matrix to row proportions and then take the
cumulative sum. Now draw a random uniform number between 0 and 1 and find
the first column that is larger than the random number. That column is your
randomly selected host. If there is one host, the cumulative sums will be
zero until you reach that column and then it will flip to 1 so that you will
always select that host.

2. For each parasite, create a vector of host names with each host repeated
by the number of interactions with that host. Use sample() to randomly draw
a host. You'll probably want to combine the vectors into a list to automate
the process over all parasites.

----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352