Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/67.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的Visreg:奇异矩阵';a';在';求解';错误消息_R_Matrix_Glm_Singular_Visreg - Fatal编程技术网

R中GLM的Visreg:奇异矩阵';a';在';求解';错误消息

R中GLM的Visreg:奇异矩阵';a';在';求解';错误消息,r,matrix,glm,singular,visreg,R,Matrix,Glm,Singular,Visreg,我对R相当陌生,但到目前为止,我一直在设法将它用于我的硕士论文 已运行以下GLM: M1 <- glm.nb(abundance ~ temp * fseason * fperiod * fregion + offset(LogRSize) + offset(LogPLength) + offset(LogSLength), data = test_data) visreg(M1, "

我对R相当陌生,但到目前为止,我一直在设法将它用于我的硕士论文

已运行以下GLM:

M1 <- glm.nb(abundance ~ temp * fseason * fperiod * fregion 
                       + offset(LogRSize) + offset(LogPLength) + offset(LogSLength), 
                       data = test_data)

visreg(M1, "temp", by = "fperiod")

此处的最小可复制示例:


建模后您是否收到错误,即与visreg无关?这可能是因为你试图估算的参数比观测值多?请在你的问题中添加
str(测试数据)
。我已经编辑了这篇文章。不,建模运行良好,不会产生错误,只有在我尝试visreg函数后才会出现。谢谢。如果引发错误的是
visreg
代码,则可能值得显示该代码-以防有人使用
visreg
时注意到一些明显的问题。我们可能需要一个调试程序来调试此。。。
summary(M1)
工作正常吗?好的,我会继续-是的,模型摘要工作正常。
    > str(test_data)
tibble [2,660 x 15] (S3: tbl_df/tbl/data.frame)
 $ abundance     : num [1:2660] 0 0 0 0 0 1 0 0 4 0 ...
 $ month         : chr [1:2660] "09" "10" "11" "09" ...
 $ season        : num [1:2660] 1 1 1 1 1 1 1 1 1 1 ...
 $ season_length : num [1:2660] 3 3 3 3 3 3 3 3 3 3 ...
 $ period        : chr [1:2660] "1" "1" "1" "1" ...
 $ period_length : num [1:2660] 10 10 10 10 10 10 10 10 10 10 ...
 $ region        : num [1:2660] 2 2 2 2 2 2 2 2 2 2 ...
 $ region_size_km: num [1:2660] 19157 19157 19157 19157 19157 ...
 $ temp          : num [1:2660] 15.38 9.51 5.03 14.99 8.99 ...
 $ fseason       : Factor w/ 2 levels "1","2": 1 1 1 1 1 1 1 1 1 1 ...
 $ LogSLength    : num [1:2660] 1.1 1.1 1.1 1.1 1.1 ...
 $ fperiod       : Factor w/ 3 levels "1","2","3": 1 1 1 1 1 1 1 1 1 1 ...
 $ LogPLength    : num [1:2660] 2.3 2.3 2.3 2.3 2.3 ...
 $ LogRSize      : num [1:2660] 9.86 9.86 9.86 9.86 9.86 ...
 $ fregion       : Factor w/ 10 levels "1","2","3","4",..: 2 2 2 2 2 2 2 2 2 2 ...