calibrate: Model Calibrations

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

calibrate is a generic function used to produce calibrations from various model fitting functions. The function invokes particular ‘methods’ which depend on the ‘class’ of the first argument.

Usage

1
calibrate(object, ...)

Arguments

object

An object for which a calibration is desired.

...

Additional arguments affecting the calibration produced. Usually the most important argument in ... is newdata which, for calibrate, contains new response data, Y, say.

Details

Given a regression model with explanatory variables X and response Y, calibration involves estimating X from Y using the regression model. It can be loosely thought of as the opposite of predict (which takes an X and returns a Y of some sort.) In general, the central algorithm is maximum likelihood calibration.

Value

In general, given a new response Y, some function of the explanatory variables X are returned. For example, for constrained ordination models such as CQO and CAO models, it is usually not possible to return X, so the latent variables are returned instead (they are linear combinations of the X). See the specific calibrate methods functions to see what they return.

Note

This function was not called predictx because of the inability of constrained ordination models to return X; they can only return the latent variable values (also known as site scores) instead.

Author(s)

T. W. Yee

References

ter Braak, C. J. F. and van Dam, H. (1989). Inferring pH from diatoms: a comparison of old and new calibration methods. Hydrobiologia, 178, 209–223.

See Also

predict, calibrate.rrvglm, calibrate.qrrvglm.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Not run: 
hspider[, 1:6] <- scale(hspider[, 1:6])  # Stdzed environmental vars
set.seed(123)
pcao1 <- cao(cbind(Pardlugu, Pardmont, Pardnigr, Pardpull, Zoraspin) ~
         WaterCon + BareSand + FallTwig + CoveMoss + CoveHerb + ReflLux,
         family = poissonff, data = hspider, Rank = 1, Bestof = 3,
         df1.nl = c(Zoraspin = 2, 1.9), Crow1positive = TRUE)

siteNos <- 1:2  # Calibrate these sites
cpcao1 <- calibrate(pcao1, trace = TRUE,
                    newdata = data.frame(depvar(pcao1)[siteNos, ],
                                         model.matrix(pcao1)[siteNos, ]))

# Graphically compare the actual site scores with their calibrated values
persp(pcao1, main = "Site scores: solid=actual, dashed=calibrated",
      label = TRUE, col = "blue", las = 1)
abline(v = latvar(pcao1)[siteNos], col = seq(siteNos))  # Actual scores
abline(v = cpcao1, lty = 2, col = seq(siteNos))  # Calibrated values

## End(Not run)

Example output

Loading required package: stats4
Loading required package: splines

========================= Fitting model 1 =========================

Obtaining initial values

Using initial values
         latvar
WaterCon  0.202
BareSand  0.126
FallTwig -0.352
CoveMoss  0.607
CoveHerb -0.270
ReflLux   0.283

Iteration 1 
initial  value 2119.051975 
iter  10 value 1255.283223
final  value 1245.808015 
converged

========================= Fitting model 2 =========================

Obtaining initial values

Using initial values
         latvar
WaterCon  0.439
BareSand  0.094
FallTwig -0.297
CoveMoss  0.660
CoveHerb  0.225
ReflLux   0.306

Iteration 1 
initial  value 2177.265220 
iter  10 value 1317.555695
iter  20 value 1274.033409
iter  30 value 1254.285957
iter  40 value 1253.193201
iter  50 value 1247.795662
final  value 1247.794484 
converged

========================= Fitting model 3 =========================

Obtaining initial values

Using initial values
         latvar
WaterCon  0.387
BareSand  0.124
FallTwig -0.589
CoveMoss  0.475
CoveHerb -0.164
ReflLux   0.319

Iteration 1 
initial  value 1812.433028 
iter  10 value 1249.213903
iter  20 value 1245.176255
iter  30 value 1243.812063
final  value 1243.528901 
converged
Warning message:
In valt(x = cbind(X1, X2), z = etamat, U = sqrt(t(wts)), Rank = effrank,  :
  did not converge
Grid searching initial values for observation 1 -----------------
Grid searching initial values for observation 2 -----------------

Optimizing for observation 1 -----------------
initial  value 24.342928 
final  value 22.028574 
converged
Successful convergence

Optimizing for observation 2 -----------------
initial  value 18.989525 
final  value 18.326082 
converged
Successful convergence

VGAM documentation built on Jan. 16, 2021, 5:21 p.m.