错误glm,NA/NaN/Inf in'y [英] error glm, NA/NaN/Inf in 'y

查看:544
本文介绍了错误glm,NA/NaN/Inf in'y的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将GLM模型适合我的数据.数据(rope_complete)如下所示:

I am trying to fit a GLM model to my data. The data (rope_complete) looks like this:

      rope.X...Sound rope.directional.change rope.Time.of.the.shark.in.the.video
1           5_min_blank                       5              23
2           Snorkeling                        11             37
3                 Fish1                       1              17
4                 Fish1                       6              46
5                 Diving                      6              37

现在我想检查我是否具有NA值:

Now i wanted to check if I have NA values:

table(is.na(rope_complete))

发现我没有:

FALSE  : 3225 

现在我做了我的GLM:

Now I did my GLM:

directional_turn_fit<-glm(rope_complete$rope.directional.change~
                        rope_complete$rope.X...Sound
                      +offset(
          log(rope_complete$rope.Time.of.the.shark.in.the.video))
          , family = poisson)

但我仍然遇到相同的错误:

but i still get the same error:

Error in glm.fit(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  :             
Na/NaN/Inf in 'y'

我有点迷茫,因为我不知道我现在应该做什么.我知道我的数据是泊松分布的.

I am a little bit lost, because i have no idea what i should do now. I know my data is Poisson distributed.

推荐答案

只需尝试在此处完成问题即可.当您将此模型建模为泊松分布并将"rope.time.of.the.shark.in.thevideo"作为偏移量时,您正在有效地建模每数量发生的"rope.directional.change"的计数鲨鱼出现在视频中的时间.当鲨鱼不在视频中时,此构造将不起作用,因此需要丢弃这些数据.

Just trying to complete the question here. When you model this as a poisson distribution and put "rope.Time.of.the.shark.in.the.video" as the offset, you're effectively modeling the counts of "rope.directional.change" that occur per amount of time that the shark is in the video. This construct doesn't work when the shark is never in the video, so those data would need to be discarded.

这篇关于错误glm,NA/NaN/Inf in'y的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆