Source code to fit the ZSM
This page provides brief documentation for the source code used to simulate
and estimate parameters for the modified ZSM (zero sum multinomial) described in
the book the The Unified Neutral Theory of Biogeography by Stephen Hubbell 2001
The methods are described in more detail in a paper in Nature
and in supplementary materials. This
paper should be cited if you publish results using the source code on this page.
Five main files and four ancillary files are provided:
- hubbell.c
- is a C program file which generates one random sample from the ZSM.
It is based on pp. 290-293 and figure 9.1 in Hubbell's book
- hubbell.dll
- is a binary executable compilation of hubbell.c for Win32 platforms. For other platforms users
must use MATLAB's MEX utility to build this file
- esthub.m
- is a Matlab program file which repeatedly calls myhubeng.m to compare the goodness
of fit for different permutations of parameters
- myhubeng.m
- is a Matlab program file which repeatedly calls hubbell.c to generate
an average ZSM for one given set of parameters
- hubplot.m
- is a Matlab program which will plot an estimated and observed SAD for visual comparison
- Miscellaneous
- Four MATLAB utility routines which I have written and which are used by
esthub.m: sadhist.m, myhistc.m, isvector.m and getglobal
Calling syntax for these routines
randint=hubbell(randseed) - seeds the random # generator in hubbell. Use this to give repeatable results
ab=hubbell(theta,Jm) or hubbell(theta,Jm,1.0) - generate a random metacommunity, returns a vector of observed abundances
ab=hubbell(theta,J,m) - generates a local community (uses Jm=1,000,000 to first generate metacommunity)
ab=hubbell(theta,J,m,ts) - generates a local community, using ts timesteps to approach equilibrium in the local community (ts defaults to 10,000)
ab=hubbell(theta,J,m,tsary) - as above but returns the community for each timestep in tsary
[thetaest,mest]=esthub(abundvect,nruns,bDraw) - estimates theta and m for the given abundances. nreps is optional and describes how many
communities to generate for each set of potential parameters. bDraw is an optional boolean argument that
indicates whether to draw the fitted curve. A third output argument can be added to give the likelihood surfaces created. Abundances should be integers greater than zero.
[mn,var]=myhubeng(theta,Jm,m,nreps,bDraw,ts) - calls the hubbell generator routine nreps times and returns the mean and variance in abunce for species of rank 1...N. The last four arguments are optional
hubplot(estabund,variance,obsab,hPlot,lognormalparams) - plots a rank-abundance SAD plot overlaying estimated and observed curves. All but the first parameter is optional
Downloading
Anyone may download and use this code. If you publish results using this code you must
cite the above mentioned paper. You must also fill out a brief form giving your name, insitution and
email address before downloading he code.
I will not provide this information to any other person or institution.
Go to Brian McGill's homepage