繁体   English   中英

我正在尝试对 R 运行逻辑回归并收到此错误

[英]I'm trying to run a logistic regression on R and am getting this error

model <- glm(早上〜从这个旱季到达的时间(天)。,family=binomial(link='logit'),data=raw_data_1)错误:“模型<-glm(早上〜时间以来”中的意外符号)

以下是我的数据的标题:
熊 ID/ 日期 DMY/ 目击发生在早上 (0/1)/ 自到达这个旱季以来的时间(天)

这是我的数据样本:

dput(head(raw_data_1,10))

structure(list(`Bear ID` = c("Cobalt", "Pazu", "Fang", "McQueen", 
"Mushroom", "Umber", "Umber", "Fang", "Teto", "Eggplant"), `Date DMY` = structure(c(1463011200, 
1464480000, 1464825600, 1464825600, 1465084800, 1466380800, 1466467200, 
1467590400, 1468886400, 1470182400), tzone = "UTC", class = c("POSIXct", 
"POSIXt")), `sighting occurred in morning (0/1)` = c(0, 1, 1, 
0, 0, 1, 1, 0, 1, 1), `time since arrival this dry season (days)` = c(72, 
89, 93, 93, 96, 111, 112, 125, 140, 155)), row.names = c(NA, 
-10L), class = c("tbl_df", "tbl", "data.frame"))

我正在尝试对 model 进行逻辑回归,即相对于这个旱季到达后的时间,早上出现的概率。 海量 R 菜鸟,第一个 model 我不得不做。

如评论中所述尝试这样做:

#Code
glm(raw_data_1$'sighting occurred in morning (0/1)' ~
      raw_data_1$'time since arrival this dry season (days)',
    family=binomial(link='logit'),data=raw_data_1)

Output:

Call:  glm(formula = raw_data_1$"sighting occurred in morning (0/1)" ~ 
    raw_data_1$"time since arrival this dry season (days)", family = binomial(link = "logit"), 
    data = raw_data_1)

Coefficients:
                                           (Intercept)  
                                              -4.17519  
raw_data_1$"time since arrival this dry season (days)"  
                                               0.04337  

Degrees of Freedom: 9 Total (i.e. Null);  8 Residual
Null Deviance:      13.46 
Residual Deviance: 11.58    AIC: 15.58

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM