[prev in list] [next in list] [prev in thread] [next in thread]
List: r-sig-mixed-models
Subject: [R-sig-ME] sample with two weights in different levels
From: Rodrigo Travitzki <r.travitzki () gmail ! com>
Date: 2015-06-15 16:59:30
Message-ID: 557F0472.50207 () gmail ! com
[Download RAW message or body]
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
_______________________________________________
R-sig-mixed-models@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic