results.generator: iglm Estimation and Simulation Results (R6 Class)

results.generatorR Documentation

iglm Estimation and Simulation Results (R6 Class)

Description

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'.

Active bindings

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-degrees coefficients.

fisher_degrees

('matrix' or 'NULL') Read-only. Fisher information matrix for degrees coefficients.

fisher_nondegrees

('matrix' or 'NULL') Read-only. Fisher information matrix for non-degrees coefficients.

score_degrees

('numeric' or 'NULL') Read-only. Score vector for degrees coefficients.

score_nondegrees

('numeric' or 'NULL') Read-only. Score vector for non-degrees 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.

Methods

Public methods


Method 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.

Usage
results.generator$new(size_coef, size_coef_degrees, file)
Arguments
size_coef

(integer) The number of non-degrees (structural) coefficients in the model.

size_coef_degrees

(integer) The number of degrees 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.

Returns

A new 'results' object, initialized to hold results for a model with the specified dimensions.


Method set_model_assessment()

Stores the results object generated by a model assessment (goodness-of-fit) procedure within this 'results' container.

Usage
results.generator$set_model_assessment(res)
Arguments
res

An object containing the model assessment results, expected to have the class 'iglm_model_assessment'.

Returns

The 'results' object itself ('self'), invisibly. Called for its side effect of storing the assessment results.


Method set_prediction()

Stores prediction results.

Usage
results.generator$set_prediction(prediction)
Arguments
prediction

An object containing the prediction results (is a list of class 'iglm.prediction'.


Method 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.

Usage
results.generator$gather()
Returns

A list containing all the internal fields of the 'results' object.


Method 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.

Usage
results.generator$save(file)
Arguments
file

(character) The file path where the results state should be saved. Must be a valid character string. The file will be saved in RDS format, so it should end with '.rds'.

Returns

The 'results' object itself ('self'), invisibly.


Method 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.

Usage
results.generator$resize(size_coef, size_coef_degrees)
Arguments
size_coef

(integer) The new number of non-degrees coefficients.

size_coef_degrees

(integer) The new number of degrees coefficients. @return The 'results' object itself ('self'), invisibly.


Method 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'.

Usage
results.generator$update(
  coefficients_path = NULL,
  samples = NULL,
  var = NULL,
  fisher_degrees = NULL,
  fisher_nondegrees = NULL,
  score_degrees = NULL,
  score_nondegrees = NULL,
  llh = NULL,
  stats = NULL,
  estimated = FALSE
)
Arguments
coefficients_path

(matrix) A matrix where rows represent iterations and columns represent all coefficients (non-degrees then degrees), 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-degrees coefficients. Replaces existing matrix.

fisher_degrees

(matrix) The Fisher information matrix for degrees coefficients. Replaces existing matrix.

fisher_nondegrees

(matrix) The Fisher information matrix for non-degrees coefficients. Replaces existing matrix.

score_degrees

(numeric) The score vector for degrees coefficients. Replaces existing vector.

score_nondegrees

(numeric) The score vector for non-degrees 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.

Returns

The 'results' object itself ('self'), invisibly. Called for its side effects.


Method 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.

Usage
results.generator$remove_samples()
Returns

The 'results' object itself ('self'), invisibly.


Method plot()

Generates diagnostic plots for the estimation results. Currently plots:

  • The log-likelihood path across iterations.

  • The convergence paths for degrees coefficients (if present).

  • The convergence paths for non-degrees coefficients.

Optionally, can also trigger plotting of model assessment results if available.

Usage
results.generator$plot(
  trace = FALSE,
  stats = FALSE,
  model_assessment = FALSE,
  ...
)
Arguments
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 fits with identical model_assessment terms are currently identified from this argument. The names of the arguments are shown as the legend in the model assessment plots.

Details

Requires estimation results ('private$.estimated == TRUE') to plot convergence diagnostics. Requires model assessment results for the model assessment plots.


Method 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.

Usage
results.generator$print(...)
Arguments
...

Additional arguments (currently ignored).

Returns

The 'results' object itself ('self'), invisibly.


Method clone()

The objects of this class are cloneable with this method.

Usage
results.generator$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


iglm documentation built on April 23, 2026, 5:07 p.m.