I am looking for a mixed effect solution to my problem.
I try to model data which contain constant dependent variable $Y$ for each random level
ngame. $Y$ is the sport game outcome,
ngame is the id of a game. A game outcome is obviously just one per game, but I need to estimate it
measurements times as close as possible. You can think of
measurements as a time variable. Variables inside one random instance must be dependent.
All the independent variables are varying. The number of random levels is several thousand.
Without using mixed effect models, I treat it by making
max(measurements) models, where each observation is a distinct random factor and $Y$ is not constant anymore. As an obvious drawback of this solution I keep tens of models and the degrees of freedom are thousand times fewer compared to the total dataset.
I cannot figure out how to design one mixed effect model that would not fail due to signularity related issues.
A toy dataset:
My code which is not good:
library(data.table) library(lme4) x1 = rnorm(20) x2 = rnorm(20) x3 = rnorm(20) ngame = rep(1:2, each = 10) measurements = rep(1:10, 2) y = c(rep(10, 10), rep(5, 10)) dat = data.table( x1 = x1, x2 = x2, x3 = x3, ngame = ngame, measurements = measurements, y = y ) lme4::lmer(y ~ x1 + x2 + x3 + measurements + (1|ngame), data = dat)
I want to supply
c(x1,x2,x3,measurement) to a trained model to get $Y'$.
However what I have built so far does not create a model without errors or warnings, and I can undesratnd why, but cannot understand how to fix it.
I actually created a small real dataset for this problem consisting of 20 random factor levels. https://raw.githubusercontent.com/alexmosc/ds_lectures/master/sample_game_dat.csv When I run my lmer model on it I get the error Error in eval_f(x, ...) : Downdated VtV is not positive definite.