# NOT RUN {
data(fams)
# this data frame contains various families
# getting their famid
fam.ids <- unique(fams$fam);
# creating a list of genotypes corresponding to all individuals in fams
# NA -> 0, 1 or 2
genotypes <- lapply( fams$genotype, function(x) if(is.na(x)) 0:2 else x )
# creating a list of es.pedigree objects
X <- vector("list", length(fam.ids))
for(i in seq_along(fam.ids))
{
w <- which(fams$fam == fam.ids[i])
X[[i]] <- es.pedigree( id = fams$id[w], father = fams$father[w],
mother = fams$mother[w], sex = fams$sex[w], pheno = rep(0, length(w)),
geno = genotypes[w], famid = fam.ids[i] )
}
# }
# NOT RUN {
# computing the likelihood for a single value p
Likelihood(X, modele.di, theta = list( p=0.5), n.cores=1 )
# computing the likelihood for a vector p (Elston-Stewart is ran only once!)
p <- seq(0,1,length=501)
L <- Likelihood(X, modele.di, theta = list( p=p ), n.cores=1 )
plot( p, exp(L), type="l")
# running an optimization algorithm
# Elston-Stewart is ran several times
# here we run the algorithm with 2 cores
L <- function(p) -Likelihood(X, modele.di, theta = list( p=p ), n.cores=2 )
optimize(L , c(0.35,0.45) )
# }
Run the code above in your browser using DataLab