The `results` class stores estimation (`$estimate()`) and simulation (`$simulate()`) results.
This class is primarily intended for internal use within the `iglm` framework but provides structured access to the results via the active bindings of the main `iglm_object`.
coefficients_path(`matrix` or `NULL`) Read-only. The path of all estimated coefficients across iterations.
samples(`list` or `NULL`) Read-only. A list of simulated `iglm.data` objects (class `iglm.data.list`).
stats(`matrix` or `NULL`) Read-only. Matrix of summary statistics for simulated samples, which are an `mcmc` obect from `coda`.
var(`matrix` or `NULL`) Read-only. Estimated variance-covariance matrix for non-popularity coefficients.
fisher_popularity(`matrix` or `NULL`) Read-only. Fisher information matrix for popularity coefficients.
fisher_nonpopularity(`matrix` or `NULL`) Read-only. Fisher information matrix for non-popularity coefficients.
score_popularity(`numeric` or `NULL`) Read-only. Score vector for popularity coefficients.
score_nonpopularity(`numeric` or `NULL`) Read-only. Score vector for non-popularity coefficients.
llh(`numeric` or `NULL`) Read-only. Vector of log-likelihood values recorded during estimation.
model_assessment(`list` or `NULL`) Read-only. Results from model assessment (goodness-of-fit).
estimated(`logical`) Read-only. Flag indicating if estimation has been completed.
new()Creates a new `results` object. Initializes internal fields, primarily setting up an empty matrix for the `coefficients_path` based on the expected number of coefficients.
results.generator$new(size_coef, size_coef_popularity, file)size_coef(integer) The number of non-popularity (structural) coefficients in the model.
size_coef_popularity(integer) The number of popularity coefficients in the model (0 if none).
file(character or `NULL`) If provided, loads the sampler state from the specified .rds file instead of initializing from parameters.
A new `results` object, initialized to hold results for a model with the specified dimensions.
set_model_assessment()Stores the results object generated by a model assessment (goodness-of-fit) procedure within this `results` container.
results.generator$set_model_assessment(res)resAn object containing the model assessment results, expected to have the class `iglm_model_assessment`.
The `results` object itself (`self`), invisibly. Called for its side effect of storing the assessment results.
set_prediction()Stores prediction results.
results.generator$set_prediction(prediction)predictionAn object containing the prediction results (is a list of class `iglm.prediction`.
gather()Gathers the current state of the `results` object into a list for saving or inspection. This includes all internal fields such as coefficient paths, samples, statistics, variance-covariance matrix, Fisher information, score vectors, log-likelihood values, model assessment results, and estimation status.
results.generator$gather()A list containing all the internal fields of the `results` object.
save()Saves the current state of the `results` object to a specified file path in RDS format. This allows for persisting the results for later retrieval and analysis.
results.generator$save(file)file(character) The file path where the results state should be saved. Must be a valid character string.
The `results` object itself (`self`), invisibly.
resize()Resizes the internal storage for the coefficient paths to accommodate a different number of coefficients. This is useful if the model structure changes and the results object needs to be reset.
results.generator$resize(size_coef, size_coef_popularity)size_coef(integer) The new number of non-popularity coefficients.
size_coef_popularity(integer) The new number of popularity coefficients. @return The `results` object itself (`self`), invisibly.
update()Updates the internal fields of the `results` object with new outputs, typically after an estimation run (`$estimate()`) or simulation run (`$simulate()`). Allows selectively updating components. Appends to `coefficients_path` and `llh` if called multiple times after estimation. Replaces `samples` and `stats`.
results.generator$update(
coefficients_path = NULL,
samples = NULL,
var = NULL,
fisher_popularity = NULL,
fisher_nonpopularity = NULL,
score_popularity = NULL,
score_nonpopularity = NULL,
llh = NULL,
stats = NULL,
estimated = FALSE
)coefficients_path(matrix) A matrix where rows represent iterations and columns represent all coefficients (non-popularity then popularity), showing their values during estimation. If provided, appends to any existing path.
samples(list) A list of simulated `iglm.data` objects (class `iglm.data.list`). If provided, replaces any existing samples.
var(matrix) The estimated variance-covariance matrix for the non-popularity coefficients. Replaces existing matrix.
fisher_popularity(matrix) The Fisher information matrix for popularity coefficients. Replaces existing matrix.
fisher_nonpopularity(matrix) The Fisher information matrix for non-popularity coefficients. Replaces existing matrix.
score_popularity(numeric) The score vector for popularity coefficients. Replaces existing vector.
score_nonpopularity(numeric) The score vector for non-popularity coefficients. Replaces existing vector.
llh(numeric) Log-likelihood value(s). If provided, appends to the existing vector of log-likelihoods.
stats(matrix) A matrix of summary statistics from simulations, where rows correspond to simulations and columns to statistics. Replaces or extends the existing matrix and will be turned into a mcmc object from the `coda` package.
estimated(logical) A flag indicating whether these results come from a completed estimation run. Updates the internal status.
The `results` object itself (`self`), invisibly. Called for its side effects.
remove_samples()Clears the stored simulation samples (`.samples`) and statistics (`.stats`) from the object, resetting it to an empty list. This might be used to save memory or before running new simulations.
results.generator$remove_samples()The `results` object itself (`self`), invisibly.
plot()Generates diagnostic plots for the estimation results. Currently plots:
The log-likelihood path across iterations.
The convergence paths for popularity coefficients (if present).
The convergence paths for non-popularity coefficients.
Optionally, can also trigger plotting of model assessment results if available.
results.generator$plot(
trace = FALSE,
stats = FALSE,
model_assessment = FALSE,
...
)trace(logical) If `TRUE` (default), plot the trace plots of the estimation (log-likelihood and coefficient paths). Requires model to be estimated.
stats(logical) If `TRUE`, plots the normalized statistics from simulations. Default is `FALSE`.
model_assessment(logical) If `TRUE`, attempts to plot the results stored in the `.model_assessment` field. Requires model assessment to have been run and a suitable `plot` method for `iglm_model_assessment` objects to exist. Default is `FALSE`.
...Additional outputs
Requires estimation results (`private$.estimated == TRUE`) to plot convergence diagnostics. Requires model assessment results for the model assessment plots.
print()Prints a concise summary of the contents of the `results` object, indicating whether various components (coefficients path, variance matrix, Fisher info, score, samples, stats, etc.) are available.
results.generator$print(...)...Additional arguments (currently ignored).
The `results` object itself (`self`), invisibly.
clone()The objects of this class are cloneable with this method.
results.generator$clone(deep = FALSE)deepWhether to make a deep clone.