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).
fit_variance_law(df_mat, plot_curve = TRUE)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
numeric matrix of data
logical, if TRUE returns ggplot objects