mixed models - Using custom made weights and structural weight in lme function in R -


i going use structural weight varindent(from = ~1 |sex) , custom made vector of weights called w in lme function in r. wondering if knows how combine weights in function. example (just made question)

n=25 data=data.frame(   y   = rnorm(n),   sex = as.factor(sample(c('male','female','female'),size = n,replace = true)),   age = as.factor(sample(c('1-1-2013','10-3-2013','1-5-2013'),size = n,replace = true)),   area= as.factor(sample(c('a','b','a'),size = n,replace = true)) ) w = runif(n) my_weight_vector = w/sum(w)    l = lme(   fixed = y ~ sex + age,   data = data,   random = ~ 1 |    area,   weights = varident(form =  ~1 | sex)+???my_weight_vector ) 

i believe want this:

data$v <- 1/my_weight_vector^2  l = lme(   fixed = y ~ sex + age,   data = data,   random = ~ 1 |    area,   weights = varcomb(varident(form =  ~1 | sex), varfixed(~ v)) ) 

varfixed takes v vector , uses fixed residual variance. demonstrating indeed results in desired weights:

varfun <- varfixed(~ v) varfun <- initialize(varfun, data) all.equal(varweights(varfun), my_weight_vector) #[1] true 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -