read.modeldef {Rglimclim} | R Documentation |
This function is intended as a convenient way to read model definitions from old GLIMCLIM
(rather than Rglimclim
) definition files, and to store the result in a format that can be used directly as an argument to other routines such as GLCfit
.
read.modeldef(model.file, nhead = 46, model.type, which.part="mean", siteinfo, var.names, which.response=1, external.files = c("yr_preds.dat", "mn_preds.dat","dy_preds.dat"), sim = FALSE, oldGlimClim.warning=TRUE)
model.file |
The name of a model definition file, which should be in the format specified in the Details section below. The file should contain three sections: a header containing |
nhead |
Number of header rows in |
model.type |
One of |
which.part |
If |
siteinfo |
An object of class |
var.names |
Vector of variable names (used to construct labels,
in multivariate models in particular). If not supplied, this is set to
|
which.response |
Index number of the response variable (used to
identify which element of |
external.files |
3-element character vector giving names of files containing "external" covariates at annual, monthly and daily resolution (in that order). Each element is used only if such covariates are part of the model specification. See manual for details. |
sim |
Logical value, indicating whether we're defining a model for simulation or fitting purposes. For simulating some model types, a dispersion parameter should be specified in the model definition file (this is not necessary for model fitting - dispersion parameters will be estimated automatically as necessary). Conversely, if we're fitting models then we'll need to calculate derivatives of log-likelihoods with respect to any parameters that enter nonlinearly intothe "linear predictor". Defaults to |
oldGlimClim.warning |
Logical value indicating whether to issue a warning if the model definition file contains a value for |
Model definition files are used to define covariates for a GLM (along with their associated coefficients), and to select spatial dependence structures. For the model fitting programs, the parameter values in these files are treated as initial estimates for the numerical estimation algorithm.
The final section of the file (see documentation for argument model.file
above) defines the model structure proper. In this section, each row corresponds to a single parameter in the model, and contains
five entries in fixed-width format:
COMPONENT VALUE CODE1 CODE2 CODE3 TEXTThe field widths are 5,10,5,5,5,40. An explanation of the entries is as follows:
COMPONENT
occupies the first 5 positions in the record, and is used to identify the type of quantity being defined. Valid values are:
0
if the record relates to the constant term in the linear predictor (i.e. the regression part of the model).
1
if the record relates to a site effect in the linear predictor.
2
if the record relates to a ‘year’ effect in the linear predictor.
3
if the record relates to a ‘month’ effect in the linear predictor.
4
if the record relates to a ‘day’ effect, in the linear predictor. This includes previous days' values, as well as any other covariate that varies on a daily timescale (except those that vary with both day and site).
5
if the record relates to a 2-way interaction in the linear predictor.
6
if the record relates to a 3-way interaction in the linear predictor.
7
if the record relates to the nonlinear transformation of one of the covariates in the linear predictor.
8
if the record relates to a global quantity such as a ‘trace’ threshold for raingauges. Such quantities are not strictly part of the model, but must be defined to the system somehow.
9
if the record relates to a dispersion parameter for the
model (not all models have a dispersion parameter, and the parameter does not need to be specified when fitting models - see documentation for argument sim
above).
10
if the record relates to the spatial structure of the model.
The rows of a model definition file must be ordered according to the
value of COMPONENT
; if the rows are out of order, an error message will result.
VALUE
is the value of the parameter / coefficient being defined, occupying positions 6-15 of the record.
CODE1
, CODE2
and CODE3
are used to define
the precise details of the model to the system. Their interpretation
depends on the value of COMPONENT
. In general, it is not
necesary to define all three codes. If they are all defined,
CODE1
occupies positions 16-20 of the record, CODE2
occupies positions 21–25 and CODE3
occupies positions 26-30. See Tables 2 to 8 of the PDF package manual for full details on coding.
TEXT
contains descriptive text for this record, and appears after position 31. It is intended to help make the definition file readable by the user, and is not required or used by the program.
An object of class GLC.modeldef
. This is not intended to be manipulated by the user: it is a list containing a large number of components, all of which are passed to the underlying Fortran
code when fitting and simulating models.
Richard Chandler (richard@stats.ucl.ac.uk)
require(Rglimclim) ## ## Define site information (see make.siteinfo for details) ## data(GLCdemo) siteinfo <- make.siteinfo(Ashdown.sites,site.names=1,region.col=2, attr.names=c( "Eastings (inches from left of 11\" wide map)", "Northings (inches from bottom of 8\" high map)")) ## ## Valid logistic.def file required in current working directory ## #logistic.modeldef <- read.modeldef("logistic.def", # model.type="logistic", # siteinfo=siteinfo)