I am using RMark to run Robust Design (RDHuggins) models. I used this great forum to figure out how to model average the N estimates (derived parameters), but I can't figure how to get it to calculate the confidence intervals.
Can someone help me?
Thanks!
Here is the code we are using (basically taken from forum):
#Average models - derived parameters - Nhat
derNavg = function(fil)
{
num.models=nrow(fil$model.table) #stores num models for loop
num.years=length(fil[[1]]$results$derived$estimate)
estimate=matrix(0,ncol=num.years, nrow=num.models) #stores ests
se=matrix(0,ncol=num.years, nrow=num.models) #stores se
vcv = vector("list",length = num.models) #stores vcv
weight=fil$model.table$weight
#create list containing estimate and se for derived param for each model
for(i in 1:num.models)
{
# The actual model number is the row number for the model.table
model.numbers= as.numeric(row.names(fil$model.table))
# For each model extract the derived parameter valuess and their se
x=fil[[model.numbers[i]]]$results
estimate[i,]=x$derived$estimate
vcv[[i]]= x$derived.vcv
se[i,]=x$derived$se
}
#Call model.average using the list which includes est, wt, vcv list
# using vcv didn't work for 37213...don't know why, using se works
# vcv worked for all other meadows
# return(model.average(list(estimate=estimate,weight=weight,vcv=vcv)))
#didn't work, vcv wants list..not same as marklist
#return(model.average(list(estimate=estimate,weight=weight,se=se, vcv=TRUE)))
return(model.average(list(estimate=estimate,weight=weight,se=se)))
}
#call
m15Navg = derNavg(m15malesrobhSess.results_v2)