How can I pass cluster as string in glmmML (R)

45 Views Asked by At

How can I pass cluster columns as string variable in glmmML ?

cluster_column_as_string = 'id'
glmmML(y ~ x, data = data, cluster = cluster_column_as_string)
glmmML(y ~ x, data = data, cluster = as.symbol(cluster_column_as_string))
glmmML(y ~ x, data = data, cluster = .data[[cluster_column_as_string]])

All failed.

The following is working example

library(glmmML)
id <- factor(rep(1:20, rep(5, 20)))
data <- data.frame(y = rbinom(100, prob = 0.1, size = 1), x = rnorm(100), id = id)
glmmML(y ~ x, data = data, cluster = id)
1

There are 1 best solutions below

0
On

I think you can code your cluster column to numeric form

e.g.

data$cluster_column_as_number <- match(data$cluster_column_as_string,unique(data$cluster_column_as_string))

glmmML(y ~ x, data = data, cluster = cluster_column_as_number)