Details
Details
Trouble Shooting
If the main toolkit dialog does not appear on startup or it appears, but many of the functions do not work,
then check the following possible causes.
- It may be that R does not know where the extRemes library is located. R assumes that all
libraries (packages) are in the same place. Often, however, a user may wish to have a
package somewhere else; for example, a unix user who does not have root privileges cannot
install packages in the location where R checks for them. In this case, it is necessary
to tell R where the package is located. If, for example, the package is installed in
the directory, /home/[user]/src/library, then the toolkit must be loaded into R
using the following command.
library( extRemes, lib.loc="/home/[user]/library/")
- Another possible cause for the dialog to not appear is that this toolkit depends on the R
package tcltk, which interfaces with the Tcl/Tk programming language. The Tcl/Tk
programming language must also be installed on your system and R must know where to find
it in order for the toolkit to work. Please see Software Requirements for more
information on obtaining, installing and pointing R to Tcl/Tk.
- If you receive an error message that says,
Error in eval(expr, envir, enclos) : Object "gev.diag" not found
then the package ismev is not loaded. In order to load this package from the R prompt, simply type:
library( ismev)
Or, if it is installed in a library where R does not know to look, such as /home/[user]/src/library, then type:
library( ismev, lib.loc="/home/[user]/src/library")
Of course, this package will not load if it has not been installed. If it is not installed, then it can be
installed from the R prompt by the command:
install.packages( "ismev")
If this does not work, then it is likely that you do not have permission to write to the file where R wants to
install packages. If this is the case, then it is possible to tell R to put it someplace else. For example, to
install ismev in the directory /home/[user]/src/library, use the command:
install.packages( "ismev", lib="/home/[user]/src/library")
Once ismev is installed on your system, it needs to be loaded into R (see above).
Back to Top
Is it Really Necessary to Give a Path to the library Command Every Time?
On the unix and linux platforms, if you do not have root privileges, then you will have had to type:
library( extRemes, lib.loc="[path to extRemes library]")
every time you want to load the extRemes library. Similarly for any other R package, like ismev, that
you install onto your own space. It is possible to set up a file called .Rprofile that will be called by R
every time you start an R session. Inside this file, you can tell it where to look for packages that you install.
To make this file available to any R session it is necessary to put .Rprofile in your home directory. Assuming
that your packages are in /home/[user]/src/library, the .Rprofile file should look something like:
.First
function() {
cat("Hello! You can put any R function that you want run upon start-up in here.") }
# Ok, this next command points R to where your packages exist.
# Note that R will still look in the default path as well.
.libPaths("/home/[user]/src/library")
# Now you will no longer need to use the lib.loc argument to library
# when calling a package located in /home/[user]/src/library.
.Last
function() {
cat("Good-bye! You can put any R function that you want run while exiting R here.") }
Note that many linux networks now use a different method for supplying R libraries, and the above
.libPaths may interfere and cause problems with this new paradigm.
Back to Top
Software Requirements
The following directions were current at the time this tutorial was first written and apply to R
1.7.0,
so please consult the Windows FAQ on the R project web site for more up-to-date directions.
First, Tcl/Tk libraries and R must be installed on the system. R comes with a large amount of documentation
detailing installation. To install R, go to:
CRAN
To obtain the necessary Tcl/Tk software, go to:
http://dev.scriptics.com
Important! The Tcl/Tk interface package, tcltk, for R versions
1.7.0 only work with Tcl version
8.3.x and for R version 1.7.0, it only works with the newer Tcl/Tk version 8.4.x. For Windows users, R version
1.7.0 now installs Tcl/Tk for you by default. If you are on Windows and using R version 1.7.0, please see the
Windows FAQ on the R project site (http://www.R-project.org) for more information. If you do not know which
version of R you have, type (from the R prompt):
R.version.string
For instructions on installing the Tcl/Tk software go to:
http://www.tcl.tk/doc/howto/compile.html
Notes:
- To install Tcl/Tk on unix, you may want to ask your systems administrator to do it for you as it is a rather
onerous affair. Generally, Tcl/Tk will already be installed on unix/linux.
- In unix, you may have to set an environment variable to let R know where to find Tcl/Tk. Something like:
setenv TCL_LIBRARY /opt/local/tcl8.3.2/lib/tcl8.3
setenv TK_LIBRARY /opt/local/tk8.3.2/lib/tk8.3
Again, check with your system administrator about specifics to your system. For instance, the path to
tcl8.3 will probably be different from the one given above. Ask your systems administrator where it is,
or try the following unix/linux command.
find /[base directory] -name init.tcl -print
Note that [base directory] should be replaced with the directory where you suspect tcl might be.
Something like /opt (above example), /usr or something of the kind.
Once you have set the correct TCL_LIBRARY and TK_LIBRARY paths it is recommended that you enter these
commands in your .login or .cshrc or other appropriate file so that these variables are set automatically
in the future.
- In Windows, if you are using an R version
1.7.0 you will also need to tell R where to find Tcl/Tk. It may
behoove you to simply upgrade to version 1.7.0 (or greater). Otherwise, you will need to set an environment
variable and possibly a path. This can be done from within your R session with the following type of commands
(see the R-CRAN Windows FAQ for more information):
Sys.putenv("TCL_LIBRARY"="C:/Program Files/Tcl/lib/tcl8.3")
Sys.putenv( PATH=paste( Sys.getenv( "PATH"), "C:/Tcl/bin", sep = "))
Note that if you set the environment variable from within R, it will not remember this for the the next session.
Better to upgrade to R version 1.7.0 (or greater) and not have to worry about it ever again.
Back to Top
The Underlying Functions
The underlying functions that actually perform the extreme value analyses were written by
Stuart Coles for S-Plus and were ported into R by Alec Stephenson. For information on these
functions please see Coles (2001) (b) and more specifically the
accompaniment to this book Coles (2001) (a). For information on
the R port see the web page:
http://www.maths.lancs.ac.uk/~stephena/software.html.
The primary difference between the original S-PLUS version and the R port is that the R port
uses the optim function for finding MLEs instead of the S-PLUS nlm function. The
following notes are nearly verbatum from Alec Stephenson's notes on the differences.
- As mentioned above, the R port uses the general purpose optimization function optim.
If R cannot find this function make sure you have the latest version of R.
- Both R and S may give warning messages of the form 'NaNs produced in: log(x)'. This is a
result of evaluating log at a negative number and may occur when the likelihood is
evaluated outside of the valid parameter space. These warnings can generally be ignored.
- In the S version, the $conv element of the returned fit list is either true or
false (T or F). When true, a local minimum has theoretically been found. In the R
port, the $conv element is the return code provided by the optim function.
See the help file for optim for the details. A local minimum has theoretically
been found when this is zero.
- The optim function in R allows the user to select which optimization method to use.
These may be selected from the extreme toolkit dialogs as well. The default method is
Nelder-Mead. Another useful method is BFGS. Generally, if one method seems
to fail try the other.
Back to Top
Miscellaneous
Whenever a GEV, GPD or PP model is fit to a data object, the entire fitted object is stored within the
original data object. Because this toolkit uses Stuart Coles' routines for the fits, the original data
is duplicated in the fitted object. For larger datasets this can quickly increase the size of the .RData
file and suck up memory. If you are using a relatively large dataset and are performing many fits on it,
then it would be a good idea to remove fits that you no longer need. For example, if you want to remove
the first GPD fit performed on the "ev.data" object foo, do the following from the R prompt:
foo$models$gpd.fit1
NULL
Back to Top
Back to Table of Contents