setwd('C:\\Users\\Jack\\Documents\\AB\\PVA MS Sturgeon 2019')
rawDat <- read.table('USGS Naomi stage cfs.txt', header = TRUE, sep = "\t")
dat <- rawDat
names(dat) <- c("agency", "site", "date", "stage", "stageStatus", "cfs", "cfsStatus")
head(dat)
Make a new data set that only uses the data that are ready for publication, ignoring provisional data
dat2 <- dat[dat$stageStatus == "A" & dat$cfsStatus == "A",]
plot(dat2$cfs, dat2$stage, log = "xy")
fit1 <- lm(log(stage) ~ log(cfs), data = dat2, na.action = na.exclude)
fit1
Call:
lm(formula = log(stage) ~ log(cfs), data = dat2, na.action = na.exclude)
Coefficients:
(Intercept) log(cfs)
-1.9449 0.4525
summary(fit1)
Call:
lm(formula = log(stage) ~ log(cfs), data = dat2, na.action = na.exclude)
Residuals:
Min 1Q Median 3Q Max
-3.09717 0.03726 0.07940 0.12018 0.76888
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -1.94488 0.18622 -10.44 <2e-16 ***
log(cfs) 0.45245 0.02882 15.70 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.4186 on 783 degrees of freedom
Multiple R-squared: 0.2395, Adjusted R-squared: 0.2385
F-statistic: 246.5 on 1 and 783 DF, p-value: < 2.2e-16
plot(dat2$cfs, residuals(fit1))