我正在尝试绘制logit曲线。下面的代码运行良好,除了最后一行引发此错误:“ xy.coords(x,y)中的错误:'x'和'y'的长度不同”。下面是数据集的结构。怎么了?
Observations: 532
Variables: 14
$ `N Personal` <chr> "P001", "P002", "P005", "P007", "P008", "P010", "P011", "P012", "P...
$ Binaria <dbl> 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, ...
$ Rendimiento <dbl> 0.81, 0.75, 0.75, 0.60, 0.80, 1.00, 0.75, 0.85, 0.86, 0.86, 0.85, ...
$ Edad <dbl> 2, 3, 2, 3, 3, 2, 2, 1, 2, 2, 1, 2, 2, 3, 2, 3, 3, 2, 3, 3, 3, 4, ...
$ Posición <dbl> 2, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 1, 1, 3, 1, 1, 4, 2, 5, 1, 2, 2, ...
$ Sexo <dbl> 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, ...
$ Nacional <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, ...
$ Distancia <dbl> 1, 4, 3, 5, 3, 1, 4, 1, 1, 2, 3, 4, 2, 2, 5, 4, 4, 5, 4, 1, 2, 4, ...
$ Estrato <dbl> 3, 2, 3, 2, 5, 3, 5, 3, 3, 3, 3, 1, 3, 5, 3, 2, 4, 5, 6, 3, 3, 6, ...
$ `Estado civil` <dbl> 1, 4, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 1, 2, 1, 3, 1, 1, 1, ...
$ Hijos <dbl> 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, ...
$ Formación <chr> NA, NA, NA, "PREGRADO", "PREGRADO", NA, NA, "PREGRADO", "PREGRADO"...
$ Educación <dbl> NA, NA, NA, 3, 3, NA, NA, 3, 3, NA, 3, NA, 3, 4, NA, 3, NA, 3, 3, ...
$ Performance <dbl> 2, 3, 3, 4, 3, 1, 3, 2, 2, 2, 2, 2, 3, 1, 2, 2, 1, 1, 2, 3, 2, 2, ...
logit1=glm(RH$Binaria ~ RH$Posición, data=RH, family = "binomial" )
plot(RH_train$Posición, RH_train$Binaria, pch = 16, xlab = "Posicion", ylab = "Binaria")
xPosicion <-seq (1, 5, 0.5)
yPosicion <- predict(logit1, list(Posi= xPosicion), type="response")
lines(xPosicion, yPosicion)
xy.coords(x,y)中的错误:'x'和'y'的长度不同