I'm fairly new to R but have so far been managing to use it for my master's thesis.
Having run the following GLM:
M1 <- glm.nb(abundance ~ temp * fseason * fperiod * fregion
+ offset(LogRSize) + offset(LogPLength) + offset(LogSLength),
data = test_data)
visreg(M1, "temp", by = "fperiod")
I am trying to visualise the regression using visreg, however am getting the following error message. I have used visreg to run a model of the same structure and the data in the same format and it works fine - the only difference was that the dataset is for a different time period, so I am not sure what is different this time.
Error in qr.solve(qr.R(qr.lm(object))[p1, p1]) :
singular matrix 'a' in solve
> 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 ...
Minimum reproducible example here:
https://drive.google.com/drive/folders/1p3-0BqKvErtedbT2PIr0J_FKSxihg4Td?usp=sharing