Learn R Programming

topolow (version 1.0.0)

scatterplot_fitted_vs_true: Plot Fitted vs True Distances

Description

Creates diagnostic plots comparing fitted distances from a model against true distances. Generates both a scatter plot with prediction intervals and a residuals plot.

Usage

scatterplot_fitted_vs_true(
  distance_matrix,
  p_dist_mat,
  scenario_name,
  ndim,
  save_plot = FALSE,
  output_dir,
  confidence_level = 0.95
)

Value

A list containing the scatter_plot and residuals_plot ggplot objects.

Arguments

distance_matrix

Matrix of true distances

p_dist_mat

Matrix of predicted/fitted distances

scenario_name

Character string for output file naming. Used if save_plot is TRUE.

ndim

Integer number of dimensions used in the model

save_plot

Logical. Whether to save plots to files. Default: TRUE

output_dir

Character. Directory for output files. Required if save_plot is TRUE.

confidence_level

Numeric confidence level for prediction intervals (default: 0.95)

Examples

Run this code
# Create sample data
true_dist <- matrix(runif(100, 1, 10), 10, 10)
pred_dist <- true_dist + rnorm(100)

# Create plots without saving
plots <- scatterplot_fitted_vs_true(true_dist, pred_dist, save_plot = FALSE)

# You can then display a plot, for instance:
# plots$scatter_plot

Run the code above in your browser using DataLab