'Error in match.arg(type) : 'arg' must be of length 1 when trying to run an Anova
I am trying to compare two glm-models with the Anova Function in R to test if they are getting better or just more complex but when I try to run the Anova I always get this error message:
Error in match.arg(type) : 'arg' must be of length 1
My code looks like this:
model1 <- glm(Tempus~Typ, data=tempusB, family=binomial)
model2 <- glm(Tempus~Typ+Semantik, data=tempusB, family=binomial)
Anova(model1, model2, test="LRT")
I already looked in the help section of the Anova-Function and if I understand correctly it seems that with glm-models I can only use one argument? Is that the problem here? And does this mean it is not possible to use the Anova-Function in this case?
I am sorry if it's a dumb question, I am an absolute beginner with R and my professor told me to use the Anova-Function, so I tried.
Edit: Here is an example of my data.
dput(head(tempusB)
structure(list(Tempus = structure(c(2L, 2L, 1L, 1L, 2L, 2L), .Label = c("kT",
"T"), class = "factor"), Typ = structure(c(3L, 1L, 3L, 3L, 3L,
3L), .Label = c("K", "M", "V"), class = "factor"), Person = structure(c(3L,
3L, 3L, 3L, 3L, 1L), .Label = c("1", "2", "3", "U"), class = "factor"),
Numerus = structure(c(2L, 1L, 1L, 1L, 1L, 1L), .Label = c("PL",
"SG", "U"), class = "factor"), Aktionsart = structure(c(1L,
1L, 2L, 2L, 2L, 1L), .Label = c("dur", "perf"), class = "factor"),
Semantik = structure(c(3L, 3L, 1L, 1L, 1L, 1L), .Label = c("Tat",
"Vor", "Zust"), class = "factor"),
Satz = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = c("HS",
"NS"), class = "factor"), Klasse = structure(c(3L, 2L, 1L,
1L, 1L, 1L), .Label = c("sch", "st", "unr"), class = "factor"),
Thema = structure(c(2L, 2L, 5L, 5L, 2L, 1L), .Label = c("Arbeit",
"Familie", "Gem", "Leben", "Mission", "Pers", "PNG"), class = "factor"),
Speaker = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = c("AC",
"AH", "BC", "BG", "CW", "DH", "DK", "EHA", "EHI", "EMH",
"EP", "ESE", "EUG", "EWH", "EWO", "HT", "JC", "JE", "JHI",
"JL", "MCA", "MG", "MT", "PK", "RM", "VK", "VR", "WR"), class = "factor"),
Interviewer = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = c("1",
"2", "12", "13"), class = "factor"), Sprache = structure(c(2L,
2L, 2L, 2L, 2L, 2L), .Label = c("SD", "UD", "UDSD"), class = "factor"),
Anzahl_P = c(4, 4, 4, 4, 4, 4), Geschlecht = structure(c(2L,
2L, 2L, 2L, 2L, 2L), .Label = c("m", "w"), class = "factor"),
Alter = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = c("2",
"3"), class = "factor"), Bildung = structure(c(3L, 3L, 3L,
3L, 3L, 3L), .Label = c("C", "HS", "NE", "U"), class = "factor"),
Stolz = structure(c(2L, 2L, 2L, 2L, 2L, 2L), .Label = c("a",
"b", "U"), class = "factor"), Identität = structure(c(3L,
3L, 3L, 3L, 3L, 3L), .Label = c("a", "b", "c", "U"), class = "factor"),
Erstsprache = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = c("L1",
"L2", "U"), class = "factor"), Englisch = c(10.56, 10.56,
10.56, 10.56, 10.56, 10.56)), row.names = c(NA, -6L), class = c("tbl_df",
"tbl", "data.frame"), na.action = structure(c(`12861` = 12861L), class = "omit"))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
