Function index
Where is the code that produced a given quantity? A book function has an index entry for the section that teaches its calculation and the source that defines or calls it. For a mathematical function, the entry gives a particular call and the convention its arguments use. For a comparison with existing software, the entry leads to the recorded result and the settings shared by the two calculations. File paths start in the book directory, the companion folder latent-models-r. An index locates the calculation; its presence is not evidence that the calculation or its interpretation is correct.
E.1 Functions implemented or called by the reader and their teaching locations
The teaching index connects a calculation to its lesson and source. Its 455 rows assign 281 calculations for the reader to implement, 126 supplied functions to call and 48 supplied calculations to follow. These roles are this book’s labels for the assigned learning activity, not names of statistical methods. The totals count assigned index rows rather than distinct function names. The section can explain a calculation without displaying the function that carries it out. The following entries locate the model representations and interface explanations in the text.
| Function | Location | What the text shows |
|---|---|---|
model_spec(), finite_latent() | 1.2–1.3 | Design, response coefficients, loadings, and possible latent values and their probabilities |
make_glm() | 2.3 | Fixed observations and design, with coefficients supplied to the returned functions |
normal_cov_model(), make_pk() | 3.7; 3.10 | Transformed parameters and the corresponding covariance and pharmacokinetic parameters |
mix_unpack() | 4.1; 4.5 | Mixture proportions, means and standard deviations, including their names during expectation-conditional maximization |
make_ri_integrand() | 5.1 | Fixed data and parameters, the random-intercept argument and the log integrand |
fa_unpack(), fa_implied() | 6.1 | Loadings, unique variances and the default identity factor covariance |
ram_spec(), full_sem_spec(), ram_implied() | 7.1–7.2 | Structural matrices, the table linking free parameters to matrix and mean-vector entries and implied moments |
lmm_design() | 8.1 | Grouped response and design matrices, separate from the model parameters |
glmm_data(), glmm_integrand() | 9.1 | Data blocks, offsets, response family and standard normal variables and the covariance factor that transforms them into random effects |
irt_item(), irt_estep() | 10.1–10.3 | Item constructors, item lists and the separate integration rule |
irt_dichotomous(), dichotomous_check() | 10.1 | Probability and derivative arrays, perturbed item coordinates and the four numerical checks |
irt_graded_response(), item_check() | 10.2 | Category and parameter indices, packed coordinates and the probability-weighted derivative check |
irt_variance_rule(), irt_log_density() | 10.5 | Probability weights at fixed integration points and the normal-density term for a free variance |
mixed6_model(), mixed_va_model() | 11.1; 11.6 | Response-model fields and reconstruction of fitted loadings, intercepts and family-specific parameters |
gmm_model(), mixreg_em() | 12.3–12.4 | Component distributions and regression coefficients, SDs and membership coefficients |
npmle_distribution() | 12.8 | Estimated intercept values and their probabilities |
hmm_model() | 13.1 | Initial probabilities, transition matrix and response parameters |
hmm_em_start(), hmm_densities(), hmm_direct_model() | 13.4–13.5 | Parameter representations for expectation-maximization and direct optimization, and array indices for state-conditional response probabilities or densities |
multidim_design(), multidim_start() | 14.2 | Response indicators, fixed and free parameters, and starting values |
multidim_em() | 15.1 | Estimated free item parameters and the ordering of the information matrices |
bayes4_prior() | 16.1 | Prior hyperparameters in the returned list |
bayes4_coordinates(), bayes4_target() | 16.2 | Parameter ordering, log-density evaluation and derivatives |
mt_generator(), mt_normal() | 16.3 | The chain’s local random-number state and normal draws |
four_streams(), run_chain() | 16.4 | Functions supplied for running a chain, updating its state and selecting stored quantities |
For these explanations, use the locations above. The distributed table also identifies the source definitions and selected script examples; its assigned_section can name a later use, such as 13.5 for hmm_model(). From the book directory, read the table and use assigned_section and teaching_role together with the textual locations.
1
2
index <- read.csv("data/derived/appendix/teaching-functions.csv",
stringsAsFactors = FALSE)
For ram_admissibility(), the entry is 7.2. The function written there returns the positions of negative disturbance variances and the smallest eigenvalue of the disturbance covariance matrix. Two entries for 3.4 illustrate the other roles. The supplied optimizer bobyqa() is called on the Rosenbrock function at line 8 of code/practice/3.4.R. To follow the calculation of a step inside the trust region, open code/lib/bobyqa.R. The optimizer calls bq_main(), which calls bq_trust_step() for that step.
The same roles apply to numerical optimization, EM and integration, model fitting, inference, posterior simulation and diagnostics. Choose the destination according to the question. For instance, the prior predictive figure in 16.1 shows how widely the sample variance of the first response and its sample covariance with the second response can vary under the prior. To see which simulated values enter each histogram, look up plot_prior_predictive(). The section describes the two histograms without naming the plotting function. Its definition starts at line 11 of figures/ch16/prior-predictive.R.
For the arguments, open definition at line. The lesson’s selected example_source at example_line can be a call or a definition. The field named_final_list_fields lists names only from a final explicit list() expression. For bfgs() it is blank because final_expression is result. At lines 127 through 132 of code/lib/quasi_newton.R, new_result() creates that object with estimates in par. The optimizer adds inverse_hessian and par_scale before returning it. For an internal calculation, via_function identifies the caller. The names in calls_in_book locate related definitions. The worked example supplies their loading order.
The index generator collects names appearing in function bodies for calls_in_book; it does not establish every executed call, including functions passed as arguments or selected at run time.
Consider the simulated binary random-intercept data in 9.3. The glmm_fit() row points to its library definition at line 276 of code/lib/glmm.R. In code/ch09.R, line 348 begins the chapter’s definition and line 573 calls it. Start with the libraries used in 9.1 and the observed responses. Each of 80 clusters supplies eight binary responses. The fixed design gives each observation an intercept and its observed x. A single column of ones in the design matrix for the random effects gives observations with the same id a shared random intercept.
For observation $j$ in cluster $i$, the conditional success probability is $\operatorname{logit}^{-1}(\beta_0+\beta_1x_{ij}+b_i)$, with $b_i$ normal with mean zero and variance $G_{11}$. The intercept $\beta_0$ gives the log odds at $x=0$ and $b_i=0$; at fixed $b_i$, a unit increase in $x$ changes the log odds by $\beta_1$. The variance $G_{11}$ measures between-cluster variation in these intercepts, in squared log-odds units. Clusters are independent, and their responses are conditionally independent given the shared intercept.
1
2
3
4
5
6
7
8
9
10
11
12
.libPaths(c(".R-library", .libPaths()))
for (file in c("result", "stability", "families", "logit", "differentiation",
"line_search",
"quasi_newton", "newton", "glm", "transforms", "simulation", "em", "factor", "sem",
"lmm", "dogleg", "lmm_fast", "lmm_profile", "integration")) {
source(paste0("code/lib/", file, ".R"))
}
source("code/lib/glmm.R")
obs <- readRDS("data/source/ch09/GLMM80-binary.rds")
binary <- glmm_data(obs$y, cbind(intercept=1, x=obs$x), matrix(1, nrow(obs), 1),
obs$id, "binomial")
adaptive_fit <- glmm_fit(binary, "AGQ", 7)
The fit estimates two regression coefficients and a random-intercept variance with seven adaptive quadrature points for the one random-intercept dimension. With several random effects, the product rule uses this count on each axis. To find how the underlying standard normal nodes and probability weights are constructed, look up normal_rule() in 5.2. Its library definition starts at line 7 of code/lib/integration.R.
Which function recovers a cluster’s contribution to the marginal log likelihood? Select six names from the same index. The missing-name check ensures that every requested row was found. Read the arguments and return fields in the same six-row order each time the printout continues under a new column heading.
1
2
3
4
5
6
selected <- c("glmm_fit","glmm_integrate","glmm_integrand","conditional_mode",
"product_rule","bfgs")
lookup <- match(selected, index$name)
stopifnot(!anyNA(lookup))
print(index[lookup, c("name", "assigned_section", "teaching_role", "definition", "line",
"inputs", "named_final_list_fields", "calls_in_book")], row.names = FALSE)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
name assigned_section teaching_role definition line
glmm_fit 9.3 reader implements code/lib/glmm.R 276
glmm_integrate 9.3 reader implements code/lib/glmm.R 109
glmm_integrand 9.1 reader implements code/lib/glmm.R 51
conditional_mode 5.4 reader implements code/lib/integration.R 135
product_rule 5.6 reader implements code/lib/integration.R 194
bfgs 3.3 reader implements code/lib/quasi_newton.R 29
inputs
data, method, nodes, start, control
data, beta, L, method, nodes, starts, control
block, beta, L, family
h, gr, he, start, control
n, dimension, center, covariance, curvature, max_nodes
fn, gr, par, control
named_final_list_fields
value, beta, G, theta, loglik_contributions, converged, reason, optimizer, modes, method, nodes_per_axis, constraints
value, valid, loglik_contributions, clusters, method, nodes_per_axis, number_of_random_effects, beta, G, failed_clusters
response, h, gr, he, centered, at_nodes, dimension
mode, curvature, factor, log_integrand_gradient, fit, valid, reason
nodes, log_weights, standard_nodes, count, dimension, measure, valid
calls_in_book
glmm_laplace_fit, normal_rule, bfgs, glmm_cd_jacobian, glmm_normal_log_density, glmm_row_logsumexp, glmm_par_to_D, fit_glm, make_glm, glmm_nearest_pd, glmm_fd_jacobian, glmm_D_to_par
product_rule, glmm_integrand, conditional_mode, laplace_approx, logsumexp
glmm_response, glmm_log_density_change
inner_newton
normal_rule
new_result, bfgs_update
The first two rows both list loglik_contributions. The fit returns a quadrature approximation to the log marginal probability of each cluster’s response pattern at the estimated parameters. The check in 9.3 tests both the length and the finiteness of that vector.
1
2
stopifnot(length(adaptive_fit$loglik_contributions) == binary$groups,
all(is.finite(adaptive_fit$loglik_contributions)))
To evaluate specified parameters, use the second row. Pass glmm_integrate() the fixed coefficients beta and a lower triangular Cholesky factor L of the random-effect covariance. When all cluster evaluations meet the function’s checks, value is the negative sum of their approximated log marginal probabilities. If a cluster evaluation fails, value is Inf and failed_clusters identifies the affected indices. The utils package reads the index with read.csv(), and base supplies match() for the name lookup. The returned valid flag concerns these numerical evaluations, not model adequacy or a guarantee of integration accuracy.
E.2 Mathematical functions used directly
A function name can identify the operation without specifying the interpretation of its arguments. Did a normal probability refer to the area above the observed value or below it? Open the mathematical function index from the book directory. Preserving the original column names allows selection of an entry using math[["function"]].
1
2
math <- read.csv("data/derived/appendix/mathematical-functions.csv",
colClasses = "character", check.names = FALSE)
The 51 rows cover matrix calculations, elementary and special functions, probability functions and random draws, quadrature, random-number streams and auxiliary variables. Read section for the worked example, source and line for the call, teaching_use for its statistical purpose and documentation for the argument definitions. The two stream functions return the generator state at the start of the next stream or substream.
Read the convention before interpreting a numerical argument. For a symmetric positive definite matrix $A$, the default chol(A) returns an upper triangular $R$ satisfying $R^\top R=A$. With real matrices $X$ and $Y$, crossprod(X,Y) computes $X^\top Y$ when the row counts agree. For equal column counts, tcrossprod(X,Y) gives $XY^\top$.
The gamma rows specify a rate, the reciprocal of the scale. In the negative binomial rows, size $r$ and mean $\mu$ imply variance $\mu+\mu^2/r$. The normal probability row uses lower.tail to choose the tail and log.p to request the probability or its logarithm.
In 16.5, a half-t prior for a positive standard deviation $\tau$ adds $\log 2$ to the symmetric t log density. Expressing that prior on $u=\log\tau$ adds a further $u$ because $d\tau/du=e^u$.
In 16.8, quantile() uses its default type-7 interpolation on the pooled draws. At each cutoff, the fifth or ninety-fifth percentile, the indicator is one for a draw at or below it. The smaller of the two effective sample sizes is the reported tail effective sample size.
In 16.4, the call BayesLogit::rpg(length(y), trials, eta) generates one Pólya-Gamma variable for each observed binomial count. The trial count supplies its first distribution parameter; the second is the linear predictor entering this conditional update. The draws are independent conditional on the current predictors and trial counts. Each draw then weights that observation in the normal update for the regression coefficients.
The points used for quadrature in 5.2 come from a deterministic calculation. Look up the book function normal_rule() in E.1 and eigen() here. The sorted eigenvalues of its symmetric Jacobi matrix give the standard normal nodes, and the accompanying probability weights sum to one.
Select the pnorm row to locate an example where the choice of tail affects an interval calculation.
1
math[math[["function"]] == "pnorm", c("section", "source", "line", "documentation")]
| Section | Source | Line | Documentation |
|---|---|---|---|
| C.2 | code/examples/appendix-stability.R | 17 | Normal distribution |
The source line in C.2 evaluates the first endpoint. For a standard normal variable $Z$, write $S(z)=P(Z>z)$. The interval from 9 to 9.001 has probability $S(9)-S(9.001)$. The following calculation can start in a fresh session. Define the log difference before passing it the two upper-tail log probabilities. The final output is the upper-tail inverse Mills ratio $\phi(z)/S(z)$, the standard normal density divided by its upper-tail probability, also called its hazard function.
1
2
3
4
5
6
7
8
9
10
11
12
logdiffexp <- function(a,b) {
stopifnot(length(a)==length(b),all(!is.na(a)&!is.na(b)),all(a>=b),all(a<Inf))
out <- rep(-Inf,length(a)); different <- a>b
out[different] <- a[different]+log(-expm1(b[different]-a[different]))
out
}
bounds <- c(9,9.001)
log_interval <- logdiffexp(pnorm(bounds[1],lower.tail=FALSE,log.p=TRUE),
pnorm(bounds[2],lower.tail=FALSE,log.p=TRUE))
print(c(naive_interval=diff(pnorm(bounds)),stable_log_interval=log_interval,
upper_tail_inverse_Mills_ratio=exp(dnorm(9,log=TRUE)-pnorm(9,lower.tail=FALSE,
log.p=TRUE))))
1
2
naive_interval stable_log_interval upper_tail_inverse_Mills_ratio
0.000000 -48.331191 9.108523
Both lower-tail probabilities round to one, giving the printed difference of zero. With $a=\log S(9)$ and $b=\log S(9.001)$, -expm1(b-a) evaluates $1-e^{b-a}$. Adding its logarithm to $a$ gives the log interval probability, printed as −48.331191. The last column evaluates that hazard at 9, using the upper-tail probability in its denominator.
For the stipulated covariance A and residual v, the Cholesky calculation reconstructs the covariance and gives the squared length of the residual transformed to have unit variances and zero covariances under the stated covariance model. A direct solve evaluates the same quadratic form. The print call also checks the three-point normal rule.
1
2
3
4
5
6
7
8
9
10
A <- matrix(c(2,.4,.4,1),2)
R <- chol(A)
v <- c(1,-.5)
u <- forwardsolve(t(R),v)
source("code/lib/integration.R")
nodes <- normal_rule(3L)
print(list(covariance=crossprod(R),quadratic=sum(u^2),
direct=drop(crossprod(v,solve(A,v))),
normal_second_moment=sum(nodes$weights*nodes$nodes^2),
total_probability=sum(nodes$weights)))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$covariance
[,1] [,2]
[1,] 2.0 0.4
[2,] 0.4 1.0
$quadratic
[1] 1.032609
$direct
[1] 1.032609
$normal_second_moment
[1] 1
$total_probability
[1] 1
The off-diagonal of crossprod(R) recovers 0.4. Solving $R^\top u=v$ gives $u^\top u=v^\top A^{-1}v$. The direct solve gives the same quadratic, $1.9/1.84$, printed as 1.032609. In ascending order the nodes $-\sqrt{3},0,\sqrt{3}$ carry weights $1/6,2/3,1/6$. Their weighted squares contribute $1/2,0,1/2$ to the second moment, and the weights alone recover total probability one. The four entries below locate these operations in estimation examples.
1
2
3
4
5
6
print(data.frame(primitive=c("chol","forwardsolve","eigen","rpg"),
mathematical_result=c("upper triangular Cholesky factor R with t(R) R = A",
"solution of the lower triangular system",
"eigenvalues of the symmetric Jacobi matrix, the nodes of normal_rule()",
"independent Polya-Gamma draws given the shape and current linear predictor"),
example=c("4.1","4.1","5.2","16.4")))
1
2
3
4
5
primitive mathematical_result example
1 chol upper triangular Cholesky factor R with t(R) R = A 4.1
2 forwardsolve solution of the lower triangular system 4.1
3 eigen eigenvalues of the symmetric Jacobi matrix, the nodes of normal_rule() 5.2
4 rpg independent Polya-Gamma draws given the shape and current linear predictor 16.4
The two entries for 4.1 belong to one normal likelihood calculation. The Cholesky factorization uses the covariance submatrix for the observed responses, and the triangular solve transforms the corresponding residuals to unit variances and zero covariances under that model. The other two entries give the node construction in 5.2 and the conditional draws in 16.4. The base package supplies the three matrix operations and BayesLogit supplies rpg().
E.3 Existing implementations used for verification
Which result in the index checks an item calibration against mirt::mirt()? From the book directory, read the chapter comparison index as text. Section numbers are identifiers. Numeric conversion would merge 3.10 with 3.1 and drop the final zero from 10.10. Select the section and the reference function together.
1
2
3
refs <- read.csv("data/derived/appendix/matched-references.csv", colClasses = "character")
refs[refs$section == "10.10" & refs$reference == "mirt::mirt",
c("section", "reference", "match", "record", "output", "kind", "package_version_in_run")]
section | reference | match | record | output | kind | package_version_in_run |
|---|---|---|---|---|---|---|
| 10.10 | mirt::mirt | 2PL, Rasch, graded, generalized partial-credit and nominal items; common 121-node likelihood and response probabilities | printed | 10.10.txt | translation | 1.45.1 |
| 10.10 | mirt::mirt | 3PL MAP with a normal prior on logit(g), mean -1.5 and SD 3; EM cycles, common 121-node likelihood and response probabilities | printed | 10.10.txt | translation | 1.45.1 |
| 10.10 | mirt::mirt | Science graded response model; common 121-node marginal log likelihood | printed | 10.10.txt | translation | 1.45.1 |
All three rows point to results/ch10/10.10.txt and the same version. The match column identifies the fitted model. Ordinary printed outputs are under results/chNN/. Assertion rows instead name the script that tests the comparison.
The kind column records this book’s classification of the compared calculations. Its interpretation depends on which quantities each side actually computes. In a translation check, part of the book code behind the compared result is translated or adapted from the reference, or from code that the reference runs, such as the minimizers of optim() and nlminb(); code/NOTICE.md names that part. Agreement at the tested inputs supports the fidelity of that adaptation, and an error shared with the source would leave no difference.
A package-settings check concerns agreement under specified settings, or compares two runs of the reference itself. For a row labeled independent, the intended comparison uses separate calculations of the named quantity.
For example, the numDeriv assertion rows compare numerical derivatives with separately derived analytic derivatives. They differ from D.1’s comparison of num_grad() with the source from which it was adapted. A package name alone does not determine the type of check.
Section 6.9 illustrates why the compared calculation matters. Its single stats::factanal record is labeled independent. The EM fits in that section use conditional-moment updates, providing a separate calculation from the concentrated search in factanal(). The bounded HEYWOOD3 fit instead uses a concentrated likelihood and a start adapted from factanal(). Its agreement checks that adaptation; the row’s independent label should not be extended to this comparison.
Of the 64 records, 41 are translation checks, 5 are package-settings checks and 18 are independent checks. All three 10.10 rows are translation checks, because the acceleration of the book’s EM cycles follows mirt.
The first 10.10 row covers dichotomous items under the Rasch and two-parameter logistic models. For items with several categories, it covers the nominal response model as well as the graded response and generalized partial credit models. The second row concerns the three-parameter logistic model, in which the lower-asymptote parameter, often called the guessing parameter, gives the response probability as ability tends to negative infinity. Both maximum a posteriori fits placed a normal prior on the logit of that lower-asymptote probability, with mean $-1.5$ and standard deviation 3. Each took 133 EM cycles. The book used its 121-node rule to evaluate the negative marginal log likelihood at both sets of fitted item parameters, omitting the prior from this comparison. The difference printed as zero. Across the 16 items and the ability grid from $-4$ to 4, the largest absolute difference in response probabilities was $4.884981\times10^{-15}$.
To interpret a comparison, identify who estimated the parameters and who evaluated the reported quantity. In 9.3, the book and GLMMadaptive::mixed_model() each fitted the binary random-intercept model with seven adaptive quadrature nodes. The two regression coefficients and the log standard deviation of the random intercept differed by at most $2.88\times10^{-14}$. The book evaluated the score vector, the gradient of the log likelihood, at both fitted vectors using 61 fixed nodes. Its component for the log standard deviation was about $-0.120422$ at both. Thus agreement of fitted coordinates does not establish stationarity under the finer rule. The 9.3 row is a translation check, since parts of the book’s adaptive quadrature follow GLMMadaptive.
In the separate infert comparison in 9.8, the book and lme4::glmer() each fitted the model with 15 adaptive nodes. The book subtracted its 61-node negative marginal log likelihood at the glmer() estimates from its 15-node value of 129.18231980 at its own estimates. The difference of $+0.28347470$ reflects both the parameters and the quadrature rule. The glmer() row of 9.8 is classified as a comparison with a separate fitting implementation.
Of the 64 chapter records, 59 report printed results. For the five assertions, result_recorded is FALSE because the index does not retain a printed comparison result for them. This flag alone does not say whether those scripts ran or passed.
In code/checks/ch02.R, the grouped-binomial checks compare the stats::nlm() coefficients with the exact estimates at tolerance $10^{-5}$ and the minimum with the negative log likelihood there at $10^{-8}$. They accept stopping codes 1 and 2. In code/checks/ch03.R, the grouped-binomial and Rosenbrock examples compare analytic gradients with numDeriv::grad() at $10^{-7}$ and analytic Hessians with numDeriv::hessian() and stats::optimHess() at $10^{-5}$. These tolerances are passed to all.equal(), which ordinarily compares an average relative difference and switches to an absolute comparison near zero; they are not bounds on every coordinate’s absolute error. For the root of $x^2-2$ between 0 and 2, the script requires exact agreement with stats::uniroot() on the root, iteration count and estimated precision.
Two output_file entries belong under results/completion/. The independently initialized regressions in 12.9-independent.csv used flexmix 2.3.21. The full and null maximum likelihood fits in 15.3-reference.csv used lme4 1.1.37. Their respective version records, completion-mixture-reference.csv and completion-inference.csv, are under results/package-versions/.
The direct comparisons have a separate index. Count each check identifier once, then count the distinct combinations of section, comparison, function and version. A check can call several functions and test several quantities. The lookup also selects the failed adaptive Poisson evaluation in 9.3, so its finite-pair count can be read alongside the reported values.
1
2
3
4
5
6
7
8
9
verification <- utils::read.delim("data/derived/appendix/package-method-checks.tsv",
colClasses = "character", check.names = FALSE)
cols <- c("section", "comparison", "package_function", "version")
length(unique(verification$check))
nrow(unique(verification[cols]))
nrow(verification)
verification[verification$section == "9.3" &
verification$quantity == "adaptive Poisson failure: initial negative log posterior density",
c("values", "finite_pairs", "book_value", "reference_value", "tolerance", "passed")]
The three counts give 18 checks, 29 displayed combinations and 165 quantity rows. In 7.9, lavaan::growth() fits the four-occasion model with equal residual variances. The checks compare that variance, implied means and covariance matrix. Chapter 7 uses lavaan::sem() for its full structural equation model and PoliticalDemocracy comparisons; their results are in results/ch07/7.9.txt and the numerical checks in validation.csv under results/ch07/application. In 9.3, the checks include the clusters’ contributions to the marginal log likelihood, components of the score vector and the first EM log likelihood.
Ten rows have fewer finite pairs than values. For the failed adaptive Poisson evaluation, both implementations returned Inf for the initial negative log posterior density. With one value and zero finite pairs, this passing check establishes agreement on a failed evaluation. All 165 rows pass their stated tests in the retained output; that count includes agreement on nonfinite results and is not a count of successful finite calculations.
These checks also do not imply agreement for every chapter comparison: the stochastic EM and Metropolis-Hastings Robbins-Monro (MH-RM) differences are reported in 14.8.
To check fitted coordinates for the zero start in 3.4, read the separate numeric table and select one row per radius.
1
2
3
4
5
6
zero_start_file <- "data/derived/ch03/3.4-zero-start-comparison.csv"
if (file.exists(zero_start_file)) {
zero_start <- read.csv(zero_start_file)
print(unique(zero_start[c("setting", "final_radius", "max_pair_coordinate_difference",
"within_5e_minus_6")]), row.names = FALSE)
}
1
2
3
setting final_radius max_pair_coordinate_difference within_5e_minus_6
default 2e-07 1.828322e-05 FALSE
refined 2e-10 1.234273e-10 TRUE
Both the book optimizer and minqa::bobyqa() returned stopping code zero at each final radius. With the default radius of $2\times10^{-7}$, the largest coordinate difference exceeded the $5\times10^{-6}$ tolerance despite normal termination. Reducing the radius to $2\times10^{-10}$ brought the fitted coordinates within that same tolerance.