R:优化错误 - 提供非有限值

时间:2013-12-27 22:18:06

标签: r

我正尝试使用以下命令在R上执行beta回归:

   DV4.25112013.v2_logit <- betareg(DV4.25112013.v2 ~ 
                                  (Bcorp.Geographic.Proximity +    
                                   Dirty.Industry)^2, data=df, na.action=na.omit) 

但是它给了我以下错误:

Error in optim(par = start, fn = loglikfun, gr = gradfun, method = method,  : 
non-finite value supplied by optim

我的从属变量数据集如下所示:

9.251774e-04 1.226072e-02 9.608363e-04           NA           NA 1.768424e-03 4.506405e-04               
          NA 2.813550e-03 6.301197e-03           NA 2.584045e-02 1.298593e-03 3.279355e-04 
8.840719e-03 1.479985e-04 1.139517e-03 1.261994e-02 1.054185e-02 2.972740e-02 7.572882e-03           
          NA           NA 2.398657e-02 4.605694e-03           NA           NA 6.879709e-03           
          NA 1.177712e-02 4.685408e-02 2.735896e-04           NA 7.779318e-03 1.096625e-05 
8.366171e-04 2.988228e-04 4.226364e-03 4.600874e-04 5.070094e-03 1.004572e-01           NA 
7.904296e-03 1.229791e-04           NA 1.072013e-04 3.022147e-03 6.271264e-03           NA           
          NA 2.714173e-02 5.537466e-04           NA 5.214199e-04 6.207046e-03           NA           
          NA 6.945933e-04           NA 1.376983e-03 7.183495e-04           NA           NA      
4.542490e-05 1.891985e-02 7.712977e-03 6.184493e-04 3.098408e-03 6.969552e-03           NA 
1.480573e-04 1.029175e-02 1.232377e-04           NA 6.540225e-03 3.856216e-02           NA    
1.769285e-00           NA 5.681399e-04 5.862517e-03 8.520513e-03 2.159825e-04 7.045354e-04 
1.129759e-02 5.876718e-04           NA 1.780352e-03 1.071973e-04           NA 1.444186e-02
          NA 1.532570e-02           NA           NA 3.265149e-02 4.457103e-02           NA 
1.163361e-02 1.372521e-02 2.645904e-03 6.539674e-05           NA 9.671331e-03           NA 
1.540429e-03           NA 4.772404e-04 2.452567e-03 4.511210e-03           NA           NA 
7.728757e-03 3.087052e-03 4.169794e-03 1.298330e-03           NA

为什么我会收到此错误,如何解决此问题?

谢谢

1 个答案:

答案 0 :(得分:2)

我有类似的问题。 它是1.你的数据不是满级或2.错误的代码。

如果你认为你的问题是2,那么

##your version
DV4.25112013.v2_logit <- 
  betareg(DV4.25112013.v2 ~ (Bcorp.Geographic.Proximity + Dirty.Industry)^2, 
                             data = df, na.action = na.omit) 

##try
##assuming 'df' is dataframe 
X=(df$Bcorp.Geographic.Proximity+df$Dirty.Industry)^2
Y=DV4.25112013.v2
class(X) #make sure your data is numeric
class(Y) #make sure your data is numeric

DV4.25112013.v2_logit=betareg(Y~X, na.action=na.omit) 
DV4.25112013.v2_logit