I am trying to run a logistic regression for a research paper I am writing for a grad class and am struggling to figure out how to fix the errors I am getting. I have been googling and tinkering for hours to avail. I was just introduced to R this semester so there is clearly a lot I do not know. Any help with this would be greatly appreciated. The code I am trying to run is below and the message I am getting.
Data to reproduce the error:
treatment Native Total perc
1 r 409 441 0.9274376
2 r 213 221 0.9638009
3 r 553 583 0.9485420
4 r 1175 1245 0.9437751
5 u 301 369 0.8157182
6 u 52 124 0.4193548
7 u 45 342 0.1315789
8 u 398 835 0.4766467
library(readxl)
Data <- read_excel("Documents/NRES 511 - Applied Ecology/ResearchProject/Data.xlsx")
View(Data)
Data$perc <- Data$Native / Data$Total ##create new variable that is percent native to non-native
model <- glm(Data$perc~Data$treatment, family = "binomial",Data = Data,weights = Data$Total)
summary(model)
exp(cbind(OR = coef(model), confint(model))) ## probability natives are greater in urban areas
1/exp(cbind(OR = coef(model), confint(model)))## probability natives are less abundant in urban areas (easier to interpret)
glm ERROR Here:
Error in glm.control(Data = list(treatment = c("r", "r", "r", "r", "u", :
unused argument (Data = list(c("r", "r", "r", "r", "u", "u", "u", "u"), c(409, 213, 553, 1175, 301, 52, 45, 398), c(441, 221, 583, 1245, 369, 124, 342, 835), c(0.927437641723356, 0.963800904977376, 0.948542024013722, 0.943775100401606, 0.815718157181572, 0.419354838709677, 0.131578947368421, 0.476646706586826)))