Kernel home range estimation
This web page contains documentation of a small program I wrote to estimate
home range size using the method of kernel density estimation (Worton 1989).
The actual program is written in Borlant Pascal and should compile with most
standard pascal compilers. Executeables are only available for MS-DOS here.
I will probably not maintain this program (fix bugs) very actively any
more, since better alternatives are becoming available
(e.g the adehabitat R-package).
In case you still wan't to use this package and you find a bug
it may be a good idea to send me an email
with the "macro.txt" file and the indata file
that causes the problem attached. This makes it easier for me
to do the debugging, and usually only takes me about half an hour.
(The problems reported so far have tended to have rather obscure causes...)
My email address is here.
The revision history can be found here.
The file kernel.zip contains the following
files:
| Filename |
Content |
| KERNEL.EXE |
Ms-dos executeable |
| KERNEL.PAS |
Source code |
| NEWDELAY.PAS |
Patch sometimes necessary (see revision history) |
| MACRO.TXT |
An example macro for processing one individual |
| BATCHJOB.BAT |
An example batch job to process the whole population |
| FXDAT053.RAW |
Example tracking data in fixed format ascii |
| FXDAT025.RAW |
Unpack this .zip file in a separate directory.
KERNEL.EXE can be run i two ways, either interactively or as a batch
job. The input data file name is specified in this batch job. (See below)
It is most convinient to create a batch job that takes some additional
parameters specifying, say the animal identification number, and perhaps
some other selection criteria. The example batch job MACRO.TXT contains
commands for calculating the 0.95 contour of the fixed kernel, the 0.75
contour of the adaptive and the 0.90, 0.80,.... ,0.10 contours of the adaptive
kernel with lscv choice of smoothing parameter.
To run the batch job type
kernel macro.txt 053 3 121 230
When the batchjob is processed %1 is substituted with 005, %2 with 3
and so on just like msdos .bat files. The idea is that if you have a lot
of individuals in you study, you create a ms-dos .bat file or a Arc/Info
.sml file which makes several calls to kernel.exe to do the analysis of
each individual. The enclosed file BATCHJOB.BAT is an example.
The program can use least-square cross-validation method for choosing
the smoothing parameter h. A problem with the lscv method is that it tend
to sometimes undersmooth drastically. This is in particular a problem for
discretisized data (Silverman 1986). As an attempt to solve this
problem the program therefore adds uniform noise to the data to make it
non-discrete, before the optimal choice of h is calculated using the lscv
method. This is described in the appendix of Tufto et al. (1996).
A better method is perhaps to use the BCV method of Sain et al. (1994)
but I have not had the time to implement this.
The program handles up to 3000 tracking points but the computer time
increase very rapidly with increasing sample size.
Explanation of commands in macrofile
- nfields <n>
- Specifies the number of columns in the indata file.
- exclude <logical expression>
- Exclude all cases in the raw data file for which <logical expression>
is true. The <logical expression> can be made up of the following
operators: AND, OR, NOT, LT, GT, EQ, ( and ). To refer to spesific fields
in the raw data #<field number> should be used.
In the example data files column number 11 contain the day number (number
of days since the 1st of January). The command
exclude (#11LT%3)OR(#11GT%4)
will therefore exclude all observation before daynr 121 and after daynr 230.
It's generally a good idea to use paranthesis to get your thinking about this
straight.
If you want to include all observations in the indata file, you can ommit
this command.
- xyfields 1 2
- Specifies which column that contains the coordinates in the
data input file. The example above
specifies that the first and second column of the input data file contain
the x and y coordinates. The coordinate can contain decimal numbers. Note
that this command must appear before the indata command.
- indata c:\kernel\fxdat%1.raw
- Reads indata from the specified filename. The input data file must
be in fixed column ascii format, and should contain only numerical variable.
Coordinates are specified using the xyfield command. In the example above
the %1 parameter passed to kernel.exe at the command prompt is used to
identify individual animals, and indata is thus read in from e.g. fxdat053.raw
and so on... Alternatively, observation of all individuals can be present
in one big file. Individuals must then be selected using the exclude command,
e.g. "exclude not(#1=%1)" would do the job if the first column
in the indata file contain the animal identification number.
- shift 0.5
- Shift all coordinates 0.5 coordinates units.
- resolution 10
- Specifies the resolution of the coordinate system, in coordinate units.
This is important if coordinates are rounded when written down becuase
this may cause least-square cross-validation to crash. The solution is
to:
- simulate
- Simulate nondiscrete data. This is sometimes nescessary when using
crossvalidation to avoid least-square cross-validation choose the degenarate
choice of h=0.
- range <h_min> <h_max>
- Specifies the range to search for the optimum value of h within. If your
home ranges is, say 1000 length units across, a good range would be
10 to 500. You may have to experiment with different ranges until you
are sure that the optimum value of h has been located.
- leastsquare
- Use least-square cross-validation choice of smoothing parameter.
- nadjust h'
- The best way to choose h is perhaps subjectively (see discussion in
Silverman 1986). By using this command the smoothing factor h will be equal
to h'*n^(-1/6) where n is the number of tracking points. You specify h'
which should be any positive number. The sample size adjustment should
help minimize the sample size bias in the final home range estimate.
- pointfile temp.pnt
- Outputs the selected tracking points to temp.pnt suitable for the Arc/Info
GENERATE comand
- histofile histo.pnt
- Works the same way as the pointfile, except that coordinates at same
place are shifted slightly so that they will show up as small "spikes"
when a point coverage is generated with Arc/Info, like in the
figure below. This option is of cource only
relevant if you have discretisized data.
- fixed
- Calculate the fixed kernel density estimate
- adaptiv
- Calculate the adaptive kernel density estimate...
- volume
- Calculate the 0.90, 0.80, ...... , 0.10 contours (default) If specific
proportion are specified e.g. by contour 0.90 only the 90% contour is calculated.
- contourfile availabl.lin
- Output the contour to availabl.lin.... This can be used to generate
a polygon in Arc/Info GENERATE command. You may also import these files
into Sigma-Plot and then do a scatterplot
and then choose plot/lines from the menu.
- outdata data.txt
- The following statistics are appended to data.txt separated by white
spaces. This file can then be read into, say SPSS, using the SPSS read
ascii data / free format command
- The parameters passed to kernel.exe at the command prompt.
- The area within each contour computed.
- The number of selected observations.
- The total number of observations in the indata file.
- Shoeners index of dependence.
- Swiharts and Slades [1] index of autocorrelation
(which is to prefer).
- Standard deviation of simulated h values.
- The h value that chosen by the "ad hoc" method (see Worton
paper)
- matrixfile c:\hr\matrix.txt
- Output the density estimate matrix to a tabulated ascii file. This
can also be imported into Sigma-Plot
and a surface diagram like this can be made:
- exit
- Return to DOS.
When I GENERATE the different point and polygon coverages in Arc/Info
I get something like this using ArcView:

There is also a number of other free and commercial software packages
that will do more or less the same thing as this program, available at
Thomas Weiss' wildlife telemetry page.
References
Worton, B. J. (1989) Kernel methods for estimating the utilisation distribution
in home range studies. Ecology. 70, 164-168.
Sain, S. R., Baggerly, K. A., Scott, D. W.(1994) Cross-Validation of
Multivariate Densities. Journal of American Statistical Association 89,807-817
.ps.gz
Silverman, B. W. (1986) Density estimation for statistics and data analysis.
Chapman and Hall, London.
Swihart, R. K. & Slade, N. A. (1985) Influence of sampling interval
on estimates of home range size. Journal of Wildlife Management. 49, 1019-1025.
Swihart, R. K. & Slade, N. A. (1985)
Testing for independence of observations in animal movements.
Ecology 66:1176-1184.
Tufto, J., R, Andersen, J. Linnell. (1996) Habitat use and ecological
correlates of home range size in a small cervid: the roe deer. Journal
of Animal Ecology, 65(6):715-724.
March 5, 1997, Jarle Tufto