[R-sig-ME] sample with two weights in different levels

Rodrigo Travitzki r.travitzki at gmail.com
Mon Jun 15 18:59:30 CEST 2015


Hi guys,
the problem of using data with (one) weight in nlme was solved!
(as Ben explained here: 
https://stat.ethz.ch/pipermail/r-sig-mixed-models/2014q3/022570.html).

Now, the problem is how to use two weights, one in individual level and 
other in an aggregated level. Sorry about this basic questions, but 
actually I cound't find reliable information, and did not understand the 
help very well.

So, based on help information, I tried this code, that seems to run ok 
in most data. But I'm not sure this is the right solution, it look likes 
strange to me, because I need to insert the same information twice. 
Also, results of varPower and varExp seems to be similar.

Could you please help me once more?


# variables in dataframe 'dd'
# WT1 - weigth in desaggregated level (level 1)
# WT2 - weigth in aggregated level (level 2)
# ID_L2 - id for each group of level 2

# create object of aggregated weights with their names
ff=aggregate(dd$WT2, list(dd$ID_L2), function(x){1/(x[1])})
ff2=ff$x
names(ff2)=ff$Group.1

# define weights
ww=varComb(varFixed(~I(1/WT1)), varPower(fixed=ff2, form=~I(1/ WT2)|ID_L2))

# fit model
lme(fixed=depend.var~idepend.var, random=~1|ID_L2, weights=ww, 
na.action=na.omit, data=dd)


Thank you,
Rodrigo



More information about the R-sig-mixed-models mailing list