Learn R Programming

optsize (version 0.1.0)

fit_variance_law: Fit Fairfield-Smith's variance law to matrix data with ggplot2 plots

Description

This function fits the Fairfield-Smith variance law, computes weighted R^2 on the log-log scale, identifies the optimum plot size and recommended shape, and produces two ggplot2 visualisations (original and log scale).

Usage

fit_variance_law(df_mat, plot_curve = TRUE)

Value

list with results:

  • df_shapes: data.frame of plot shapes

  • V1: variance at 1x1

  • b_hat: estimated variance law coefficient

  • R2_log: weighted R^2 on log-log scale

  • x_opt: optimum plot size (units)

  • Vx_opt: predicted variance at optimum

  • best_shape: recommended shape for optimum plot size

  • plots: list of ggplot objects if plot_curve = TRUE

Arguments

df_mat

numeric matrix of data

plot_curve

logical, if TRUE returns ggplot objects