2
$\begingroup$

I would like to use weights in a model that I'm fitting with the glmmLasso package, but it looks like there isn't an option for it. I've previously fit models with the glm() and glmer() functions, which both have a weights = option. However, it looks like glmmLasso doesn't have such an option, and the older version (glmmlasso with a lowercase L) which did have a weights option is unfortunately now defunct. Alternatively, if there's a way to use LASSO on glmer() that would work too.

In summation: I'd like to fit a GLMM in R that uses both sampling weights and LASSO variable selection. Is there a way to do this? I'm open to any/all solutions.

$\endgroup$

1 Answer 1

0
$\begingroup$

Supplying a vector, $w$ to the weights argument in glm returns the same result as first scaling both the response variable and design matrix by $\sqrt{w}$ and fitting without the weights argument. e.g.

set.seed(1234)
toy_data <- data.frame(x = 1:20, y = 1:20 + rnorm(20), w = runif(20, 5, 25))
m1 <- lm(y ~ x, weights = w, data = toy_data)
dmat <- matrix(c(rep(1, 20), toy_data$x), ncol = 2) #design matrix
dmat_w <- dmat * sqrt(toy_data$w)
y_w <- toy_data$y * sqrt(toy_data$w)
m2 <- lm(y_w ~ 0 + dmat_w)
summary(m1)
summary(m2)

You may be able to do the same thing with glmmLasso

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.