# NOT RUN {
data(WarblerG)
A<-extractA(WarblerG)
sex<-c(rep("Male", 50), rep("Female", 100))
offspring<-c(rep(0,100), rep(1, 50))
terr<-as.factor(rep(1:50, 3))
id<-1:150
res1<-expression(varPed(x="offspring", restrict=0))
res2<-expression(varPed(x="terr", gender="Female", relational="OFFSPRING",
restrict="=="))
test.data<-data.frame(id, sex, offspring, terr)
PdP<-PdataPed(formula=list(res1, res2), data=test.data)
simped<-simpedigree(PdP)
G<-simgenotypes(A, E1=0, E2=0, ped=simped$ped, no_dup=1)
# remove 25 males at random, leaving 25
rm.males<-sample(1:50, 25, replace=FALSE)
data.rm<-test.data[-rm.males,]
GdPrm<-GdataPed(G=lapply(G$Gobs, function(x){x[-rm.males]}),
id=G$id[-rm.males])
# delete genotype and phenotype records
PdPrm<-PdataPed(formula=list(res1, res2), data=data.rm, USsire=TRUE)
X.listrm<-getXlist(PdP=PdPrm, GdP=GdPrm, A=A, E2=0)
X<-lapply(X.listrm$X, function(x){list(N=c(25,0,1,0),
G=c(sum(x$G[1:25]), 0, x$G[26], 0))})
# each offspring has 1 mother and 25 sampled fathers so the 4 classes are:
# a) 1*25 categories with both parents sampled, 0*25 categries with only
# sires sampled b) 1*1 categories with only dams sired and 0*0 categories
# with both sexes unsampled.
nUS<-seq(10,40, length=100)
nUS_Loglik<-1:100
for(i in 1:100){
nUS_Loglik[i]<-popsize.loglik(X, USsire=TRUE, nUS=nUS[i])
}
plot(nUS_Loglik~nUS, type="l", main="Profile Log-likelihood
for number of unsampled males")
# }
Run the code above in your browser using DataLab