Let us say I have data for 300 firms(level 1) in 10 countries (level 2). The level 1 variables are PQ and size. Level 2 variable is the per capita GDP.
library(lme4)
set.seed(1)
PQ <- runif(300,7,21)
id <- (1:300)
country <- sample(1:10,300,replace=T)
size <- sample(1:25000,300,replace=T)
GDP <- sample(800:40000,10,replace=T)
Country1 <- 1:10
L1data <- as.data.frame(cbind(id,country,PQ,size))
L2data <- as.data.frame(cbind(Country1,GDP))
MLdata <- merge(L1data,L2data, by.x = "country", by.y = "Country1")
dummymodel <- lmer(PQ ~ size + GDP + (size|country), data = MLdata, REML = F)
When I run this I get warning messages
Warning messages: 1: Some predictor variables are on very different scales: consider rescaling 2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model failed to converge with max|grad| = 1.77081 (tol = 0.002, component 1) 3: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
Model is nearly unidentifiable: very large eigenvalue - Rescale variables?; Model is nearly unidentifiable: large eigenvalue ratio - Rescale variables?
In fact when I run the model with the original data I get an additional warning message:
Model failed to converge: degenerate Hessian with 1 negative eigenvalues
I guess I need to scale the independent variables to solve this problem. What is the correct way to scale in multilevel regression like this? The question is important as the results of multilevel models are dependent on scaling. Or is there some other problem that I am not able to locate?