"object not found" error when fitting glmer.nb from lme4

hi there.
I am trying to fit a general mixed model with negative binomial error distribution.
I am familiar with the model and have used it before.

However this time I am getting a strange error, noting that my random effect would "not be found" though it is defined in my df.

first I load the packages

library(lme4)
install.packages("Matrix")
library(Matrix)

df <- read.csv("C:/Users/example/results.csv")

 This is how sed looks like

"ID1"  , "sample.ID"    , "ID"     , "type"    , "date"    , "weight", "MP", "non_fl_fibres", "total.MP", "Mp.Kg", "flow" "pH"    , "EC"       , "Alkalinity", "DOC"    |
     "MB1", "MBC-CR 1"     , "MB1L"   , "sediment", "18-10-19", 35.89   ,  8L , 0L             ,  8L       , 222.9  , 292.2   , 7.75    ,  58L       , 18.07       , 2.233    |
     "MB1", "MBC-CR 2"     , "MB1R"   , "sediment", "18-10-19", 35.27   ,  4L , 1L             ,  5L       , 141.8  , 292.2   , 7.75    ,  58L       , 18.07       , 2.233    |
     "MB2", "MBC-ANBC 1"   , "MB2L"   , "sediment", "18-10-19", 35.6    ,  4L , 0L             ,  4L       , 112.4  , 229.7   , 7.71    ,  72L       , 20.51       , 2.199    |
     "MB2", "MBC-ANBC 2"   , "MB2R"   , "sediment", "18-10-19", 35.9    ,  2L , 1L             ,  3L       , 83.58  , 229.7   , 7.71    ,  72L       , 20.51       , 2.199    |
     "B1" , "BC-O 3"       , "B1L"    , "sediment", "14-10-19", 36.05   ,  2L , 1L             ,  3L       , 83.22  , NA_real_, NA_real_, NA_integer_, NA_real_    , NA_real_ |
     "B1" , "BC-O 4"       , "B1R"    , "sediment", "14-10-19", 36.28   ,  3L , 1L             ,  4L       , 110.3  , NA_real_, NA_real_, NA_integer_, NA_real_    , NA_real_ |
     "B2" , "BC-AFM 1"     , "B2L"    , "sediment", "18-10-19", 35.44   ,  4L , 0L             ,  4L       , 112.9  , 452.8   , 7.77    ,  89L       , 24.92       , 2.012    |
     "B2" , "BC-AFM 2"     , "B2R"    , "sediment", "18-10-19", 35.36   ,  5L , 1L             ,  6L       , 169.7  , 452.8   , 7.77    ,  89L       , 24.92       , 2.012    |
     "B3" , "BC-100 1"     , "B3L"    , "sediment", "18-10-19", 35.2    ,  6L , 0L             ,  6L       , 170.4  , 499.6   , 7.78    , 102L       , 26.56       , 2.018    |
     "B3" , "BC-100 2"     , "B3R"    , "sediment", "18-10-19", 35.7    , 12L , 0L             , 12L       , 336.2  , 499.6   , 7.78    , 102L       , 26.56       , 2.018    |
     "B4" , "BC-AFB 2"     , "B4L"    , "sediment", "17-10-19", 35.27   ,  8L , 2L             , 10L       , 283.6  , 399.7   , 7.79    , 106L       , 26.86       , 1.927    |
     "B4" , "BC-AFB 1"     , "B4R"    , "sediment", "17-10-19", 36.92   ,  5L , 0L             ,  5L       , 135.4  , 399.7   , 7.79    , 106L       , 26.86       , 1.927    |
     "B5" , "BC-9TH 2"     , "B5L"    , "sediment", "17-10-19", 35.32   ,  3L , 1L             ,  4L       , 113.3  , 463.3   , 7.68    , 117L       , 30.04       , 2.116    |
     "B5" , "BC-9TH 1"     , "B5R"    , "sediment", "17-10-19", 35.22   ,  6L , 2L             ,  8L       , 227.2  , 463.3   , 7.68    , 117L       , 30.04       , 2.116    |
     "B6" , "BC-BRO 2"     , "B6L"    , "sediment", "17-10-19", 35.75   ,  8L , 3L             , 11L       , 307.7  , 490.6   , 7.81    , 142L       , 35.25       , 1.917    |
     "B6" , "BC-BRO 1"     , "B6R"    , "sediment", "17-10-19", 36      ,  8L , 1L             ,  9L       , 250    , 490.6   , 7.81    , 142L       , 35.25       , 1.917    |
     "B7" , "BC-AF 2"      , "B7L"    , "sediment", "17-10-19", 35.18   ,  7L , 1L             ,  8L       , 227.4  , 119.4   , 8.16    , 260L       , 45.62       , 1.949    |
     "B7" , "BC-AF 1"      , "B7R"    , "sediment", "17-10-19", 33.31   , 11L , 2L             , 13L       , 390.3  , 119.4   , 8.16    , 260L       , 45.62       , 1.949    |
     "B8" , "BC-30 2"      , "B8L"    , "sediment", "17-10-19", 35.35   ,  5L , 0L             ,  5L       , 141.4  , 140.1   , 7.97    , 264L       , 50.12       , 1.855    |
     "B8" , "BC-30 1"      , "B8R"    , "sediment", "17-10-19", 35.88   ,  4L , 1L             ,  5L       , 139.4  , 140.1   , 7.97    , 264L       , 50.12       , 1.855    |
     "B9" , "BC-FOOT 1(b)" , "B9L"    , "sediment", "16-10-19", 35.87   ,  8L , 2L             , 10L       , 278.8  , NA_real_, NA_real_, NA_integer_, NA_real_    , NA_real_ |
     "B9" , "BC-FOOT 2"    , "B9R"    , "sediment", "16-10-19", 36.11   ,  4L , 0L             ,  4L       , 110.8  , NA_real_, NA_real_, NA_integer_, NA_real_    , NA_real_ |
     "B10", "BC-61ST 2"    , "B10L"   , "sediment", "16-10-19", 35.8    ,  5L , 1L             ,  6L       , 167.6  , 244.5   , 8.29    , 449L       , 92.17       , 3.147    |
     "B10", "BC-61ST 1(b)" , "B10R"   , "sediment", "16-10-19", 35.28   ,  5L , 2L             ,  7L       , 198.4  , 244.5   , 8.29    , 449L       , 92.17       , 3.147    |
     "B11", "BC-75 1(b)"   , "B11L"   , "sediment", "14-10-19", 34.9    ,  7L , 0L             ,  7L       , 200.6  , NA_real


There is 6 NA rows, but these should not have any effect on the model
When I try to fit the glmer this is what I do

md1 <- glmer.nb(total.MP ~ EC + flow +DOC + Alkalinity + pH, (1|ID1), data = sed)

And I receive an error:

Error in glmer(total.MP ~ EC + flow + DOC + Alkalinity + pH, (1 | ID),  : 
  object 'ID' not found

I have defined ID1 and loaded packages that I need (or is there something i have missed?)

Any help with this would be highly appreciated

Thanks

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.