{"action":"created","issue":{"url":"https://api.github.com/repos/lme4/lme4/issues/340","repository_url":"https://api.github.com/repos/lme4/lme4","labels_url":"https://api.github.com/repos/lme4/lme4/issues/340/labels{/name}","comments_url":"https://api.github.com/repos/lme4/lme4/issues/340/comments","events_url":"https://api.github.com/repos/lme4/lme4/issues/340/events","html_url":"https://github.com/lme4/lme4/issues/340","id":121752236,"number":340,"title":"invalid assignment for reference class field ‘Ut’","user":{"login":"timflutre","id":607508,"avatar_url":"https://avatars.githubusercontent.com/u/607508?v=3","gravatar_id":"","url":"https://api.github.com/users/timflutre","html_url":"https://github.com/timflutre","followers_url":"https://api.github.com/users/timflutre/followers","following_url":"https://api.github.com/users/timflutre/following{/other_user}","gists_url":"https://api.github.com/users/timflutre/gists{/gist_id}","starred_url":"https://api.github.com/users/timflutre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timflutre/subscriptions","organizations_url":"https://api.github.com/users/timflutre/orgs","repos_url":"https://api.github.com/users/timflutre/repos","events_url":"https://api.github.com/users/timflutre/events{/privacy}","received_events_url":"https://api.github.com/users/timflutre/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-11T17:10:01Z","updated_at":"2016-03-15T15:17:31Z","closed_at":"2016-03-15T15:17:31Z","body":"I [managed](http://stats.stackexchange.com/a/162284/3459) to understand how to fit an \"animal model\" (a kind of linear mixed model used by geneticists) with lme4 (>=1.7). But this was in the case with no \"fixed effect\" (only an intercept; a single observation per animal/individual). I tried in the case with one fixed effect: the code runs successfully, but the genetic variance isn't estimated anymore (its estimate is equal to zero). The attached script, test.txt, provides an example that works (set I=1000 on line 23) and one that doesn't (set I=500 on line 24). But, as there is no error, it's hard to know where the problem comes from.\r\n\r\nWhat's the link with the title of the issue? Well, I discovered this problem while wrapping up my code into a function and adding it to my \"personal R package\". While doing this, the code doesn't even work, even though no change was made in the code instead adding `lme4::` in front of the functions needing it. Nevertheless, an error occurs inside `devianceFunction <- do.call(mkLmerDevfun, parsedFormula)`, and the message is:\r\n`Error: invalid assignment for reference class field ‘Ut’, should be from class “dgCMatrix” or a subclass (was class “dgeMatrix”)`\r\n\r\nFrom this error, my guess is that the problem comes from the design matrix of the random genetic effect (Z). It's not clear to me why the error is \"hidden\" in the script, though.\r\n\r\nI can provide more details if necessary.\r\n\r\n[test.txt](https://github.com/lme4/lme4/files/59649/test.txt)\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/lme4/lme4/issues/comments/196871400","html_url":"https://github.com/lme4/lme4/issues/340#issuecomment-196871400","issue_url":"https://api.github.com/repos/lme4/lme4/issues/340","id":196871400,"user":{"login":"timflutre","id":607508,"avatar_url":"https://avatars.githubusercontent.com/u/607508?v=3","gravatar_id":"","url":"https://api.github.com/users/timflutre","html_url":"https://github.com/timflutre","followers_url":"https://api.github.com/users/timflutre/followers","following_url":"https://api.github.com/users/timflutre/following{/other_user}","gists_url":"https://api.github.com/users/timflutre/gists{/gist_id}","starred_url":"https://api.github.com/users/timflutre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timflutre/subscriptions","organizations_url":"https://api.github.com/users/timflutre/orgs","repos_url":"https://api.github.com/users/timflutre/repos","events_url":"https://api.github.com/users/timflutre/events{/privacy}","received_events_url":"https://api.github.com/users/timflutre/received_events","type":"User","site_admin":false},"created_at":"2016-03-15T15:17:31Z","updated_at":"2016-03-15T15:17:31Z","body":"The only way I found to finally solve this problem is by explicitly importing lme4 by my package (i.e. add `@import lme4` and `@import matrix` which Roxygen2 understands so that it adds `import(lme4)` and `import(Matrix)` to `NAMESPACE`)."}}