GLCfit {Rglimclim} | R Documentation |
This routine fits generalised linear models (GLMs) to daily climate time series. It is designed to allow flexibility in fitting fairly complicated models to daily climate/weather data, and to avoid some of the tedious manipulation of data files which would be necessary if standard software packages were used to perform this kind of analysis. It also has some nonlinear fitting capabilities that are not available in standard GLM routines such as glm
.
GLCfit(model.def, dispersion.def,response.check=1, max.iter=Inf, data.file="gaugvals.dat", missval=-99.99, which.response=1, nprev.required, nvar.check=TRUE, allow.incomplete.averages=FALSE,siteinfo, model.type, external.files = c("yr_preds.dat", "mn_preds.dat", "dy_preds.dat"), diagnostics = 2, verbosity=2, resid.file, cor.file)
model.def |
An object of class |
dispersion.def |
An object of class |
response.check |
Code to determine whether to check the values of the response variable. Options:
|
max.iter |
Maximum number of iterations for the iterative weighted least squares fitting algorithm. Negative values, along with the default of |
data.file |
Name of file containing daily weather / climate data (defaults to
For sites which record non-negative values as ‘trace’ below a
certain threshold, trace values should be entered as any strictly
positive number less than the trace threshold (the trace threshold
itself is defined to the system via If a site provides no data for any variables on a particular
day, the corresponding record should be omitted from the file. If a
site provides data for some variables but not others on a particular
day, the missing values should be coded as The underlying FORTRAN code reserves values less than |
missval |
A numeric value used to indicate missing data in |
which.response |
Indicates which of the variables in |
nprev.required |
Used to select a subset of the cases in The rationale is that when comparing models, for example using likelihood ratio tests via the Note: to completely ignore a particular variable when deciding whether to include a case in the fitting, set the corresponding element of |
nvar.check |
Controls whether to check that the number of variables in
|
allow.incomplete.averages |
When fitting models, cases can only be
included if all required covariates are present. In multivariate settings,
this can lead to large amounts of data being discarded in situations where
a covariate is a lagged or contemporaneous value of a variable other
than the response, and where different stations record different subsets
of the variables (for example: if rainfall and temperature are recorded
at different stations then temperature cannot be included as
a covariate in a model for rainfall). However, if the covariate
is a (possibly weighted) average over all sites then it may still be
reasonably well-defined for the purposes of model fitting, even if it
was not recorded at the same site as the response. Setting
Note: this argument has no effect on lagged values of the response itself. There are three reasons for this: (i) there is less potential for discarding such large quantities of data here, because by definition the lagged values are measured at the same set of stations as the response (ii) the results may be slightly unsatisfactory as indicated above (iii) dependence upon lagged values of the response is often strong and may also be localised in space, so that any problems due to the slightly unsatisfactory nature of the solution are likely to be exacerbated. |
siteinfo |
An object containing site information, for example the result of a call to |
model.type |
One 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 the model
requires it. The format of these files is tightly specified; use
|
diagnostics |
Controls the amount of diagnostic information (residual analysis etc. aimed at checking the model assumptions) produced for the fit. Options:
The default value (and value assumed if any value other than 0 or 1 is supplied) is 2. |
verbosity |
Controls the amount of information written to screen as the fitting progresses. To work silently, set this to zero; to provide brief progress updates, set it to 1; and to provide detailed information set it to 2 (the default). |
resid.file |
Optional (produced only if |
cor.file |
This output file is produced when the user chooses to
incorporate inter-site dependence via correlations (see
manual for details). The files can be used directly as
input to the |
The function returns an object of class GLC.modeldef
Richard Chandler (richard@stats.ucl.ac.uk)
GLCdemo
, write.modeldef
,
GLC.modeldef
, write.GLCdata
,
write.GLCexternal
require(Rglimclim) ## ## Load objects for artificial example - help(GLCdemo) for details ## data(GLCdemo) ## ## Collate site information ## Ashdown.sites <- make.siteinfo(Ashdown.sites,site.names=1,region.col=2) ## ## Generate data file in current working directory, and fit the ## simple logistic regression model defined in SimpleModel ## write.GLCdata(Ashdown.data,file="Ashdown.dat") print(SimpleModel,global.warn=FALSE) Model1 <- GLCfit(model.type="logistic",model.def=SimpleModel, siteinfo=Ashdown.sites,diagnostics=1, data.file="Ashdown.dat",nprev.required=0) print(Model1,global.warn=FALSE) summary(Model1) ## ## Summary without residual tables ## summary(Model1,tables=NULL)