Use the chunk of text below to get started on a linear fit to your data. This example loads data from the Leslie method worksheet for fish population estimation by depletion, then seeks a linear fit to that data and reports the results.
#data <- read.csv("Basswood_data_2024_clean1.csv", header = TRUE)
library(readxl)
#data <- read.csv("Basswood_data_2024_clean1.csv", header = TRUE)
#data <- data[, c("TreeID", "Diam_cm", "Height_m")]
colnames(data) <- c("TreeID", "dbh_cm", "total_height_m")
#linfit <- lm(height ~ dbh, data = clean_data)
summary(linfit)
Call:
lm(formula = height ~ dbh, data = clean_data)
Residuals:
Min 1Q Median 3Q Max
-4.9150 -3.0651 0.2877 2.4665 5.0298
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 9.3048 1.7679 5.263 0.000153 ***
dbh 0.2559 0.0389 6.578 1.78e-05 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 3.47 on 13 degrees of freedom
(1 observation deleted due to missingness)
Multiple R-squared: 0.769, Adjusted R-squared: 0.7512
F-statistic: 43.27 on 1 and 13 DF, p-value: 1.775e-05
plot(height ~ dbh, data = clean_data)
abline(linfit, col = "blue")
abline(linfit, col = "blue", lwd = 2)
summary(linfit)
Call:
lm(formula = height ~ dbh, data = clean_data)
Residuals:
Min 1Q Median 3Q Max
-4.9150 -3.0651 0.2877 2.4665 5.0298
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 9.3048 1.7679 5.263 0.000153 ***
dbh 0.2559 0.0389 6.578 1.78e-05 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 3.47 on 13 degrees of freedom
(1 observation deleted due to missingness)
Multiple R-squared: 0.769, Adjusted R-squared: 0.7512
F-statistic: 43.27 on 1 and 13 DF, p-value: 1.775e-05
abline(linfit )