Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 在GLM中,为什么即使给出了数据,一些系数也不适用?_R_Glm - Fatal编程技术网

R 在GLM中,为什么即使给出了数据,一些系数也不适用?

R 在GLM中,为什么即使给出了数据,一些系数也不适用?,r,glm,R,Glm,在下面的示例中 df <- data.frame(place = c("South","South","North"), temperature = c(30,30,20), outlookfine=c(TRUE,TRUE,FALSE) ) glm.fit <- glm(outlookfine ~ .,df, family=

在下面的示例中

df <- data.frame(place = c("South","South","North"),
                 temperature = c(30,30,20),
                 outlookfine=c(TRUE,TRUE,FALSE)
                 )
glm.fit <- glm(outlookfine ~ .,df, family=binomial)

glm.fit
为什么温度是NA

[更新]

我尝试了更多的数据

df <- data.frame(place = c("South","South","North","East","West"),
                 temperature = c(30,17,20,12,15),
                 outlookfine=c(TRUE,TRUE,FALSE,FALSE,TRUE)
                 )
glm.fit <- glm(outlookfine ~ .,df, family= binomial )
glm.fit

我认为这是因为
地点
温度
高度相关

您将获得相同的
fitted(glm.fit)

glm.fit <- glm(outlookfine ~ place,df, family=binomial)
Call:  glm(formula = outlookfine ~ ., family = binomial, data = df)

Coefficients:
(Intercept)   placeNorth   placeSouth    placeWest  temperature  
 -2.457e+01   -7.094e-07    4.913e+01    4.913e+01    8.868e-08  

Degrees of Freedom: 4 Total (i.e. Null);  0 Residual
Null Deviance:      6.73 
Residual Deviance: 2.143e-10    AIC: 10
glm.fit <- glm(outlookfine ~ place,df, family=binomial)
glm.fit <- glm(outlookfine ~ temperature, df, family=binomial)
df <- iris
df$SL <- df$Sepal.Length * 2 + 1
glm(Sepal.Width ~ Sepal.Length + SL, data  = df)
Call:  glm(formula = Sepal.Width ~ Sepal.Length + SL, data = df)

Coefficients:
 (Intercept)  Sepal.Length            SL  
     3.41895      -0.06188            NA  

Degrees of Freedom: 149 Total (i.e. Null);  148 Residual
Null Deviance:        28.31 
Residual Deviance: 27.92  AIC: 179.5