I am trying to run a multiple regression analysis to find the impact of water quality on plankton abundance in a specific location (aka Guzzler). I was able to get my model to run and the summary, however the data is non-parametric so a typical summary would not be reliable. This is mainly due to having a small sample size as it was done over the course of a few weeks and one sample each week.
I was then thinking the non-parametric version of this could be a bootstrap. I've run bootstraps on other data before but never a multiple regression model. I can't seem to find code on how to go about this so began with how I've performed bootstraps in the past. I was curious what I would need to edit in order to get this bootstrap to run.
Here is the output from dput(head(Guzzler1):
structure(list(Abundance = c(98L, 43L, 65L, 55L, 54L), Phospates = c(2L,
2L, 2L, 2L, 2L), Nitrates = c(0, 0.3, 0, 0.15, 0), pH = c(7.5,
8, 7.5, 7, 7)), .Names = c("Abundance", "Phospates", "Nitrates",
"pH"), row.names = c(NA, 5L), class = "data.frame")
Here is my model & the summary:
Guzzler1model<-lm(Abundance ~ Phospates + Nitrates + pH, data=Guzzler1)
> summary(Guzzler1model)
Call:
lm(formula = Abundance ~ Phospates + Nitrates + pH, data = Guzzler1)
Residuals:
1 2 3 4 5
20.75 -4.25 -12.25 8.50 -12.75
Coefficients: (1 not defined because of singularities)
Estimate Std. Error t value Pr(>|t|)
(Intercept) -80.25 209.62 -0.383 0.739
Phospates NA NA NA NA
Nitrates -135.00 90.02 -1.500 0.272
pH 21.00 28.87 0.727 0.543
Residual standard error: 20.41 on 2 degrees of freedom
Multiple R-squared: 0.5302, Adjusted R-squared: 0.06032
F-statistic: 1.128 on 2 and 2 DF, p-value: 0.4698
***Please note: I believe phosphates have NA because each value was equal to 2 in this particular location.
Here is how I was originally performing a bootstrap and unsure what to change:
n=length(Guzzler1Abundance)
B = 1000
results = numeric(B)
for(b in 1:B){
i = sample(x = 1:n, size=n, replace=TRUE)
bootSample = Guzzler1Abundance[i]
thetahat= mean(bootSample)
results[b] = thetahat
}
Thank you so much in advance!