Thank you so much! In fact, I created a weight based on fitted values from lmer.
num.mod <- lmer(CCW4 ~ (1|S4_ID), data =M)
den.mod <- lmer(CCW4 ~ (1|S4_ID) + STHLTHW2 + IRTRW2 + IRTMW2 + IRTSW2 + SINP_W2 + INC_W2 + SIB_W2 + BRTHWW12 + MALE + AGE_W2 + CNTCRW12 + PED1_W12 + HNOENGW2 + PEDEXPW1 + CityW2 + TownW2 + RuralW2 + EtcCCW2 , data =M)
num.p_op1 <- dnorm(M$CCW4, mean = fitted(num.mod), sd = attr(VarCorr(num.mod), "sc"))
num.p_op2 <- dnorm(M$CCW4, mean = mean(M$CCW4), sd = sd(M$CCW4))
den.p <- dnorm(M$CCW4, mean = fitted(den.mod), sd = attr(VarCorr(den.mod), "sc"))
Tps_MLM_op1 <- num.p_op1/den.p
"Tps_MLM_op1" is the weight variable that I want to merge with the original data. However, I received the following error message with "broom" Would you help me to solve this issue? Other approaches will also be appreciated. Thank you again,
library(broom) # for adding predictions to original data
M <- augment(Tps_MLM_op1)
Error: No augment method for objects of class numeric