LWR | R Documentation |
This function visualizes and models the relationship between length and weight (or any two continuous variables) using linear regression. It supports both standard and log-transformed models, producing a ggplot2-based plot with a fitted line, optional confidence interval shading, and annotations for the regression equation, R^2, and p-value. When save_output is TRUE, the plot and model summary are saved to the working directory as a PDF and text file, respectively.
LWR(
data,
log_transform = TRUE,
point_col = "black",
line_col = "red",
shade_col = "red",
point_size = 2,
line_size = 1,
alpha = 0.2,
main = "Length-Weight Relationship",
xlab = NULL,
ylab = NULL,
save_output = TRUE
)
data |
A data frame with at least two columns: the first for length, the second for weight. |
log_transform |
Logical. Whether to apply a log-log transformation to the variables. Default is |
point_col |
Color of the data points. Default is |
line_col |
Color of the regression line. Default is |
shade_col |
Color for the confidence interval ribbon. Default is |
point_size |
Size of the data points. Default is |
line_size |
Size of the regression line. Default is |
alpha |
Transparency for the confidence interval ribbon. Default is |
main |
Title of the plot. Default is |
xlab |
Optional. Custom x-axis label. If |
ylab |
Optional. Custom y-axis label. If |
save_output |
Logical. Whether to save the plot as a PDF and the model summary as a text file. Default is |
A list containing:
model |
The fitted |
intercept |
The estimated intercept (back-transformed if log_transform = TRUE) |
slope |
The estimated slope |
r_squared |
R-squared value |
correlation_r |
Correlation coefficient (r) |
p_value |
P-value for slope |
plot |
The |
data(LWdata, package = "aLBI")
result <- LWR(LWdata, log_transform = TRUE, save_output = FALSE)
print(result$plot)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.