calibrate.qrrvglm.control.RdAlgorithmic constants and parameters for running
calibrate.qrrvglm are set using this function.
calibrate.qrrvglm.control(object, trace = FALSE, method.optim = "BFGS",
gridSize = ifelse(Rank == 1, 21, 9), varI.latvar = FALSE, ...)The fitted CQO/CAO model. The user should ignore this argument.
Logical indicating if output should be produced for each iteration.
It is a good idea to set this argument to be TRUE since the
computations are expensive.
Character. Fed into the method argument of
optim.
Numeric, recycled to length Rank. Controls the resolution
of the grid used for initial values. For each latent variable,
an equally spaced grid of length gridSize is cast from the
smallest site score to the largest site score. Then the likelihood
function is evaluated on the grid, and the best fit is chosen as the
initial value. Thus increasing the value of gridSize increases
the chance of obtaining the global solution, however, the computing
time increases proportionately.
Logical. For CQO objects only, this argument is fed into
Coef.qrrvglm.
Avoids an error message for extraneous arguments.
Most CQO/CAO users will only need to make use of trace
and gridSize. These arguments should be used inside their
call to calibrate.qrrvglm, not this function
directly.
A list which with the following components.
Numeric (even though the input can be logical).
Positive integer.
Logical.
Yee, T. W. (2020). On constrained and unconstrained quadratic ordination. Manuscript in preparation.
Despite the name of this function, CAO models are handled as well.
if (FALSE) hspider[, 1:6] <- scale(hspider[, 1:6]) # Needed for I.tol=TRUE
set.seed(123)
p1 <- cqo(cbind(Alopacce, Alopcune, Pardlugu, Pardnigr,
Pardpull, Trocterr, Zoraspin) ~
WaterCon + BareSand + FallTwig + CoveMoss + CoveHerb + ReflLux,
family = poissonff, data = hspider, I.tol = TRUE)
#>
#> ========================= Fitting model 1 =========================
#>
#> Obtaining initial values
#>
#> Using initial values
#> latvar
#> WaterCon 0.7244
#> BareSand -0.1235
#> FallTwig 0.1120
#> CoveMoss 0.0586
#> CoveHerb 0.3812
#> ReflLux -0.8604
#>
#> Using BFGS algorithm
#> initial value 2030.378806
#> iter 10 value 1191.785817
#> iter 20 value 1134.125667
#> iter 30 value 1110.584942
#> iter 40 value 1095.546170
#> iter 50 value 1093.598998
#> iter 60 value 1092.887178
#> final value 1092.711676
#> converged
#>
#> BFGS using optim():
#> Objective = 1092.712
#> Parameters (= c(C)) =
#> 0.3498072 -0.3269432 0.443126 -0.2121283 0.3238953 -0.5685142
#>
#> Number of function evaluations = 97
#>
#>
#> ========================= Fitting model 2 =========================
#>
#> Obtaining initial values
#>
#> Using initial values
#> latvar
#> WaterCon 0.753
#> BareSand -0.139
#> FallTwig 0.114
#> CoveMoss 0.106
#> CoveHerb 0.397
#> ReflLux -0.867
#>
#> Using BFGS algorithm
#> initial value 2117.094268
#> iter 10 value 1207.406850
#> iter 20 value 1137.818663
#> iter 30 value 1107.008044
#> iter 40 value 1094.156830
#> iter 50 value 1092.860991
#> final value 1092.694536
#> converged
#>
#> BFGS using optim():
#> Objective = 1092.695
#> Parameters (= c(C)) =
#> 0.3468791 -0.3271243 0.4446075 -0.2118018 0.3259767 -0.5687157
#>
#> Number of function evaluations = 79
#>
#>
#> ========================= Fitting model 3 =========================
#>
#> Obtaining initial values
#>
#> Using initial values
#> latvar
#> WaterCon 2.010
#> BareSand 0.550
#> FallTwig -0.951
#> CoveMoss 0.523
#> CoveHerb 0.696
#> ReflLux -0.647
#>
#> Using BFGS algorithm
#> initial value 5435.547900
#> iter 10 value 1972.345980
#> iter 20 value 1824.518889
#> iter 30 value 1631.923635
#> iter 40 value 1562.299939
#> iter 50 value 1528.994793
#> iter 60 value 1522.180408
#> iter 70 value 1499.511419
#> iter 80 value 1494.115131
#> iter 90 value 1492.277539
#> iter 100 value 1490.136484
#> iter 110 value 1489.674874
#> iter 120 value 1488.891867
#> iter 130 value 1488.313957
#> iter 140 value 1487.907990
#> iter 150 value 1487.588044
#> iter 160 value 1487.569958
#> iter 170 value 1487.476594
#> final value 1487.428778
#> converged
#>
#> BFGS using optim():
#> Objective = 1487.429
#> Parameters (= c(C)) =
#> 1.034952 -0.02678373 -0.275884 -0.1398335 0.2390684 -0.09697712
#>
#> Number of function evaluations = 212
#>
#>
#> ========================= Fitting model 4 =========================
#>
#> Obtaining initial values
#>
#> Using initial values
#> latvar
#> WaterCon 2.285
#> BareSand 0.341
#> FallTwig -0.597
#> CoveMoss 0.234
#> CoveHerb 0.861
#> ReflLux -0.298
#>
#> Using BFGS algorithm
#> initial value 3790.995931
#> iter 10 value 2045.010619
#> iter 20 value 1843.477854
#> iter 30 value 1652.049259
#> iter 40 value 1551.497390
#> iter 50 value 1529.660328
#> iter 60 value 1514.028013
#> iter 70 value 1506.491323
#> iter 80 value 1504.234631
#> iter 90 value 1497.089722
#> iter 100 value 1493.947358
#> iter 110 value 1492.813880
#> iter 120 value 1491.049505
#> iter 130 value 1489.340496
#> iter 140 value 1488.837209
#> iter 150 value 1488.322966
#> iter 160 value 1488.075371
#> iter 170 value 1487.759759
#> iter 180 value 1487.660424
#> iter 190 value 1487.578247
#> iter 200 value 1487.513498
#> iter 210 value 1487.476726
#> iter 220 value 1487.466551
#> iter 230 value 1487.448489
#> final value 1487.431821
#> converged
#>
#> BFGS using optim():
#> Objective = 1487.432
#> Parameters (= c(C)) =
#> 1.035227 -0.02669058 -0.2759473 -0.1401196 0.2391693 -0.09703823
#>
#> Number of function evaluations = 237
#>
#>
#> ========================= Fitting model 5 =========================
#>
#> Obtaining initial values
#>
#> Using initial values
#> latvar
#> WaterCon 0.0233
#> BareSand 0.2933
#> FallTwig -0.3130
#> CoveMoss 0.3737
#> CoveHerb -0.1267
#> ReflLux 0.4831
#>
#> Using BFGS algorithm
#> initial value 1287.743787
#> final value 1213.138518
#> converged
#>
#> BFGS using optim():
#> Objective = 1213.139
#> Parameters (= c(C)) =
#> 0.002403783 -0.3379723 0.3759548 -0.3906854 0.1334452 -0.5070797
#>
#> Number of function evaluations = 42
#>
#>
#> ========================= Fitting model 6 =========================
#>
#> Obtaining initial values
#>
#> Using initial values
#> latvar
#> WaterCon 1.6528
#> BareSand 0.0203
#> FallTwig -0.1179
#> CoveMoss 0.0837
#> CoveHerb 0.3036
#> ReflLux -0.7315
#>
#> Using BFGS algorithm
#> initial value 3242.014094
#> iter 10 value 3115.372011
#> iter 20 value 2854.953395
#> Taking evasive action for latent variable 1.
#> cqo_1; no convergence for Species number 2. Trying internal starting values.
#> cqo_1; no convergence for Species number 2. Continuing on with other species.
#> cqo_1; no convergence for Species number 3. Trying internal starting values.
#> cqo_1; no convergence for Species number 3. Continuing on with other species.
#> cqo_1; no convergence for Species number 6. Trying internal starting values.
#> cqo_1; no convergence for Species number 6. Continuing on with other species.
#> cqo_1; no convergence for Species number 7. Trying internal starting values.
#> cqo_1; no convergence for Species number 7. Continuing on with other species.
#> iter 30 value 1813.991721
#> iter 40 value 1402.707634
#> iter 50 value 1224.555938
#> iter 60 value 1126.307430
#> iter 70 value 1111.920761
#> iter 80 value 1102.450009
#> iter 90 value 1096.114816
#> iter 100 value 1093.641627
#> iter 110 value 1092.976207
#> iter 120 value 1092.747624
#> iter 130 value 1092.685229
#> final value 1092.684062
#> converged
#>
#> BFGS using optim():
#> Objective = 1092.684
#> Parameters (= c(C)) =
#> 0.3476257 -0.326887 0.4464637 -0.2133953 0.3231358 -0.5624177
#>
#> Number of function evaluations = 155
#>
#>
#> ========================= Fitting model 7 =========================
#>
#> Obtaining initial values
#>
#> Using initial values
#> latvar
#> WaterCon 0.3599
#> BareSand -0.2581
#> FallTwig 0.2834
#> CoveMoss 0.0237
#> CoveHerb 0.3734
#> ReflLux -0.7091
#>
#> Using BFGS algorithm
#> initial value 1546.095842
#> iter 10 value 1114.311124
#> iter 20 value 1097.781866
#> iter 30 value 1095.419346
#> iter 40 value 1093.300949
#> iter 50 value 1093.047684
#> iter 60 value 1092.789902
#> final value 1092.717277
#> converged
#>
#> BFGS using optim():
#> Objective = 1092.717
#> Parameters (= c(C)) =
#> 0.3433832 -0.3287036 0.4425915 -0.2113692 0.325794 -0.57251
#>
#> Number of function evaluations = 68
#>
#>
#> ========================= Fitting model 8 =========================
#>
#> Obtaining initial values
#>
#> Using initial values
#> latvar
#> WaterCon 0.042018
#> BareSand -0.440049
#> FallTwig 0.579916
#> CoveMoss -0.195127
#> CoveHerb 0.000887
#> ReflLux -0.115046
#>
#> Using BFGS algorithm
#> initial value 1445.053980
#> iter 10 value 1145.870978
#> iter 20 value 1128.225579
#> iter 30 value 1118.044874
#> iter 40 value 1108.470657
#> iter 50 value 1096.458553
#> iter 60 value 1093.670936
#> iter 70 value 1092.973898
#> iter 80 value 1092.723374
#> iter 90 value 1092.695493
#> iter 90 value 1092.695487
#> iter 90 value 1092.695474
#> final value 1092.695474
#> converged
#>
#> BFGS using optim():
#> Objective = 1092.695
#> Parameters (= c(C)) =
#> 0.3369502 -0.3279891 0.4466022 -0.2154016 0.3227831 -0.5623371
#>
#> Number of function evaluations = 124
#>
#>
#> ========================= Fitting model 9 =========================
#>
#> Obtaining initial values
#>
#> Using initial values
#> latvar
#> WaterCon 2.691
#> BareSand 0.366
#> FallTwig -0.613
#> CoveMoss 0.403
#> CoveHerb 0.733
#> ReflLux -0.474
#>
#> Using BFGS algorithm
#> initial value 3329.862297
#> iter 10 value 2186.376698
#> iter 20 value 1958.521126
#> iter 30 value 1742.000511
#> iter 40 value 1646.021282
#> iter 50 value 1578.841078
#> iter 60 value 1534.259208
#> iter 70 value 1524.123600
#> iter 80 value 1516.925705
#> iter 90 value 1501.104862
#> iter 100 value 1498.035193
#> iter 110 value 1496.224091
#> iter 120 value 1494.643250
#> iter 130 value 1490.469563
#> iter 140 value 1489.321881
#> iter 150 value 1488.820435
#> iter 160 value 1488.448593
#> iter 170 value 1488.136135
#> iter 180 value 1487.987293
#> iter 190 value 1487.782306
#> iter 200 value 1487.657727
#> iter 210 value 1487.604087
#> iter 220 value 1487.564731
#> iter 230 value 1487.515483
#> iter 240 value 1487.482326
#> iter 250 value 1487.460761
#> final value 1487.460761
#> stopped after 250 iterations
#>
#> BFGS using optim():
#> Objective = 1487.461
#> Parameters (= c(C)) =
#> 1.037434 -0.0271824 -0.2772544 -0.1394015 0.2384577 -0.09808291
#>
#> Number of function evaluations = 250
#>
#> initial value 1487.460761
#> final value 1487.450193
#> converged
#>
#> BFGS using optim():
#> Objective = 1487.45
#> Parameters (= c(C)) =
#> 1.036884 -0.0266903 -0.276872 -0.1400233 0.2388298 -0.09767775
#>
#> Number of function evaluations = 21
#>
#>
#> ========================= Fitting model 10 =========================
#>
#> Obtaining initial values
#>
#> Using initial values
#> latvar
#> WaterCon 0.0597
#> BareSand 0.2732
#> FallTwig -0.3922
#> CoveMoss 0.2051
#> CoveHerb -0.1448
#> ReflLux 0.5575
#>
#> Using BFGS algorithm
#> initial value 1330.125048
#> final value 1188.408042
#> converged
#>
#> BFGS using optim():
#> Objective = 1188.408
#> Parameters (= c(C)) =
#> 0.005828076 -0.353777 0.4524669 -0.2921701 0.2137005 -0.57597
#>
#> Number of function evaluations = 42
#>
sort(deviance(p1, history = TRUE)) # A history of all the iterations
#> [1] 1092.684 1092.695 1092.695 1092.712 1092.717 1188.408 1213.139 1487.429
#> [9] 1487.432 1487.450
siteNos <- 3:4 # Calibrate these sites
cp1 <- calibrate(p1, trace = TRUE,
new = data.frame(depvar(p1)[siteNos, ]))
#> Grid searching initial values for observation 1 -----------------
#> Grid searching initial values for observation 2 -----------------
#>
#> Optimizing for observation 1 -----------------
#> initial value 37.507165
#> final value 34.563038
#> converged
#> Successful convergence
#>
#> Optimizing for observation 2 -----------------
#> initial value 31.637353
#> final value 29.755590
#> converged
#> Successful convergence
# \dontrun{}
if (FALSE) { # \dontrun{
# Graphically compare the actual site scores with their calibrated values
persp(p1, main = "Site scores: solid=actual, dashed=calibrated",
label = TRUE, col = "blue", las = 1)
abline(v = latvar(p1)[siteNos], col = seq(siteNos)) # Actual site scores
abline(v = cp1, lty = 2, col = seq(siteNos)) # Calibrated values
} # }