next up previous contents
Next: 4 An introductory session Up: Inferring patterns of migration Previous: 2 The model   Contents

3 Downloading and loading the code into R or S-Plus

The library comes in one version which detects whether it is running under R or S-plus. In theory, everything should work in both environments. However, because the S-plus' memory usage is sometimes quite inefficient (see section 5 and 8), and because S-Plus is pretty expensive, proprietary software whereas R is GPL'ed software freely available on the Internet (follow this link), the code optimized for R. Note that to use the R version, you will probably need to have access to R installed on a Unix system which supports loading of shared libraries with the ``dlopen'' mechanism. A good idea is probably to install some popular Linux distribution on a fast computer somewhere in your network neighbourhood, install R, and run everything remotely over the network. If you want to use R's excellent graphics capabilities you will also want an X-server on your computer instead of just telnet'ing to the remote computer. There are several freeware and shareware version available on the net (e. g here and here).

The R (or S-plus) and c code needed consists of the two files; migrlib.R and migrlib.c. In addition, the c part of the code uses randlib for random number generation. These files and accompanying documentation (the file you're reading) can be downloaded from this url (see Table 1).


Table 1: Contents of migrlib.tar.gz
migrlib.R R (or S-Plus) functions
migrlib.c c-code for generating bootstrap samples
migrlib-doc.tex LATEX file for generating this documentation
migrlib-doc.pdf This documentation in portable document format
randlib.c c-library for random number generation
randlib.h  
linpack.c  
com.c  

The randlib library may also be downloaded separately from from this url.

The first thing to do is to compile the c routines together with randlib. On the Unix system I used at one point in time, which had S-plus installed, there was a special command for compiling c code for later loading into S-plus. The following command

   s+compile -o all.o -g linpack.c com.c randlib.c migrlib.c
from the OS-prompt, seemed to do the trick, but this will vary between different operating systems. This will probably be different on, for example, a Windows95 platform. It should be described somewhere in S-plus' documentation.

Dynamic loading of shared libraries in R is presently only implemented on unix version, for example linux. On this platform, the shared library ``all.so'' can be compiled as follows:

   gcc -g -O2 -fpic -c *.c
   ld -shared -o all.so *.o

After having compiled the c code, start S-plus (or R), and load the library into R (or into S-Plus) with the command

   > source("migrlib.R")
In doing this, the compiled c code is also loaded through the command
dyn.load.shared("./all.o") (or dyn.load("./all.so") in R).


next up previous contents
Next: 4 An introductory session Up: Inferring patterns of migration Previous: 2 The model   Contents
Jarle Tufto 2001-08-28