Fits a three-parameter Weibull distribution to diameter data and optionally visualizes the fit with a histogram, fitted density curve, and confidence bands.
fit_weibull_plot(
x,
amplitude = 10,
shape = 2,
plot = TRUE,
show_ci = TRUE,
ci_level = 0.95,
ci_method = "delta",
n_boot = 1000,
main = NULL,
title.col = "black",
mid = TRUE,
line.col = "blue",
ci.col = "lightblue",
ci.alpha = 0.3,
legendPos = "topright",
lowLim = NULL,
ymax = NULL,
bg = "aliceblue",
method = "mle",
ties_method = "cheng_amin",
cex.axis = 0.6,
cex.lab = 0.8,
las = 1,
xlab = "Diameter class (cm)",
ylab = "Relative frequency (%)",
cex.legend = 1,
...
)adjWeibull(
x,
amplitude = 10,
shape = 2,
plot = TRUE,
show_ci = TRUE,
ci_level = 0.95,
ci_method = "delta",
n_boot = 1000,
main = NULL,
title.col = "black",
mid = TRUE,
line.col = "blue",
ci.col = "lightblue",
ci.alpha = 0.3,
legendPos = "topright",
lowLim = NULL,
ymax = NULL,
bg = "aliceblue",
method = "mle",
ties_method = "cheng_amin",
cex.axis = 0.6,
cex.lab = 0.8,
las = 1,
xlab = "Diameter class (cm)",
ylab = "Relative frequency (%)",
cex.legend = 1,
...
)
A list (invisibly) containing:
Named vector of parameter estimates (shape, scale, location)
Standard errors (NULL if unavailable or method doesn't support it)
Variance-covariance matrix (NULL if unavailable)
Confidence intervals for parameters at specified level (NULL if unavailable)
Named vector of goodness-of-fit statistics (KS statistic, p-value, AIC, BIC)
Integer convergence code (0 = successful)
Character string of estimation method used
Character string of confidence interval method used
Numeric confidence level used
Character string with interpretation note for KS test
numeric vector of diameter observations (typically tree diameters in cm).
numeric bin width for histogram (default: 10).
numeric initial value for shape parameter (default: 2).
logical; if TRUE, produces a histogram with fitted curve (default: TRUE).
logical; if TRUE, displays confidence bands around fitted curve (default: TRUE). Only applicable when plot = TRUE and standard errors are available.
numeric confidence level for bands (default: 0.95).
character string for CI computation: "delta" (delta method using vcov), "bootstrap" (parametric bootstrap), or "both" (default: "delta").
integer number of bootstrap samples (default: 1000). Only used if ci_method is "bootstrap" or "both".
character string for plot title (default: NULL).
color for legend title (default: "black").
logical; if TRUE, curve is drawn from min to max of bin midpoints; if FALSE, from min to max of bin breaks (default: TRUE).
color for fitted curve (default: "blue").
color for confidence bands (default: "lightblue").
numeric transparency for confidence bands (default: 0.3).
position of legend (default: "topright").
numeric lower limit for histogram breaks (default: NULL, uses min(x)).
numeric upper limit for y-axis (default: NULL, auto-computed).
background color for legend box (default: "aliceblue").
character string specifying estimation method. Options: "mle" (Maximum Likelihood - default), "mps" (Maximum Product Spacing), "mom" (Method of Moments).
character string for ties correction in MPS: "cheng_amin", "none", or "cheng_stephens" (default: "cheng_amin"). Only used when method = "mps".
numeric character expansion factor for axis annotation (default: 0.6).
numeric character expansion factor for axis labels (default: 0.8).
numeric orientation of axis labels (default: 1).
character string for x-axis label (default: "Diameter class (cm)").
character string for y-axis label (default: "Relative frequency (%)" ).
numeric character expansion factor for legend (default: 1).
additional graphical parameters passed to plot
.
fit_dist
# Simulate tree diameter data
set.seed(123)
diameters <- rweibull3(100, shape = 2.5, scale = 25, loc = 10)
# Fit with confidence bands
fit1 <- fit_weibull_plot(diameters, amplitude = 5, show_ci = TRUE)
# Fit without confidence bands
fit2 <- fit_weibull_plot(diameters, amplitude = 5, show_ci = FALSE)
# Use bootstrap confidence bands
fit3 <- fit_weibull_plot(diameters,
amplitude = 5,
ci_method = "bootstrap", n_boot = 500
)
Run the code above in your browser using DataLab