我正在尝试 运行 对 R 进行逻辑回归并收到此错误
I'm trying to run a logistic regression on R and am getting this error
model <- glm(morning ~ time since arrival this dry season (days).,family=binomial(link='logit'),data=raw_data_1)
Error: unexpected symbol in "model <- glm(morning ~ time since"
下面是我的数据的标题:
熊证/
日期 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"))
我正在尝试进行逻辑回归,以模拟自这个旱季到来以来相对于时间在早上出现的概率。大R菜鸟,我不得不做的第一个模型。
尝试使用评论中提到的方法:
#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)
输出:
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
model <- glm(morning ~ time since arrival this dry season (days).,family=binomial(link='logit'),data=raw_data_1) Error: unexpected symbol in "model <- glm(morning ~ time since"
下面是我的数据的标题:
熊证/
日期 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"))
我正在尝试进行逻辑回归,以模拟自这个旱季到来以来相对于时间在早上出现的概率。大R菜鸟,我不得不做的第一个模型。
尝试使用评论中提到的方法:
#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)
输出:
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