Description Usage Arguments Details Value Author(s) References Examples
The function pool_multinom
pools multinomial regression estimates obtained on multiple imputation data.
1 | pooling(reslist, VC = F)
|
reslist |
list of fast_multinom objects. |
VC |
logical. Should the variance covariance matrix be pooled? Note that for this all entries of reslist need to have a not null VC component. When VC=T, the fraction of missing information (gamma) is also estimated. |
Pooling of the VC matrix is implemented following Schafer, p. 113-114.
object of class fast_multinom (see fast_multinom
for details).
Johanna Bertl
J L Schafer. Analysis of Incomplete Multivariate Data. Chapman & Hall, 1996
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | # use a subset of the raw dataset that was installed along with the package:
location = system.file("extdata", "set0", package = "multinomutils")
count_table = fread(file=location)
count_table = count_table[count_table$cancer_type %in% c("KICH", "LGG")]
count_table_imp = count_table_prep_multinom(count_table, 2)
# fit the same model to each MI replicate
fitlist = vector("list", 2)
for(i in 1:2){
countmat = count_table_imp[[1]][[i]]
# set factors
countmat$strong = as.factor(countmat$strong)
countmat$cancer_type = as.factor(countmat$cancer_type)
countmat$sample_id = as.factor(countmat$sample_id)
countmat$neighbors = as.factor(countmat$neighbors)
# set contrasts
contrasts(countmat$cancer_type) = contr.sum(nlevels(countmat$cancer_type))
nesting = nested_treatment_contrasts(outer.factor=countmat$cancer_type, inner.factor=countmat$sample_id)
how.many = nlevels(countmat$sample_id) - nlevels(countmat$cancer_type)
contrasts(countmat$sample_id, how.many=how.many) = nesting
# estimation
fitlist[[i]] = fast_multinom(cbind(NO, I, VA, VG) ~ 0 + strong*sample_id + strong*replication_timing*cancer_type + strong*neighbors*cancer_type, data = countmat, refLevel=1, VC=T, loglik=T, subsetmatrix=NULL)
}
# pooling
pooled.fit = pooling(fitlist, VC=T)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.