Skip to content
Prev 6286 / 20628 Next

code for multiple membership models?

Hi,

MCMCglmm solution below, I think. It's a bit ugly:


library(foreign); lips <-  
read.dta("http://www.bristol.ac.uk/cmm/media/runmlwin/lips1.dta")[,c(1,3,5,9:30)]

neigh.factors<-unique(unlist(lips[,4:14]))
neigh.factors<-neigh.factors[-which(neigh.factors==0)]

# vector of all potential neighbours (0 really means missing)

for(i in 4:14){
lips[,i]<-factor(lips[,i], levels=neigh.factors)
# make sure neigh1, neigh2 ... all have the same potential levels
lips[,i][which(is.na(lips[,i]))]<-neigh.factors[1]
# change missing values to arbitrary neighbour (makes no difference  
since weight is zero). I should probably allow missing values!
}

m1<-MCMCglmm(obs~1,  
random=~idv(mult.memb(~weight1:neigh1+weight2:neigh2+weight3:neigh3+weight4:neigh4+weight5:neigh5+weight6:neigh6+weight7:neigh7+weight8:neigh8+ weight9:neigh9+weight10:neigh10+weight11:neigh11)),  
data=lips)

# It might make more sense to square root the weights depending on  
model assumptions.

Cheers,

Jarrod



Quoting Malcolm Fairbrother <m.fairbrother at bristol.ac.uk> on Fri, 24  
Jun 2011 13:18:05 +0100: