set.seed(12201969)
# Simulate genetic map: one chromosome of length 200 cM with
# a 2 cM marker spacing
mymap <- sim.map(200, 51, anchor.tel=TRUE, include.x=FALSE,
sex.sp=FALSE, eq.spacing=TRUE)
# Simulate data under the chi-square model, no errors
mydata <- sim.cross(mymap, n.ind=250, type="bc",
error.prob=0, m=3, p=0)
# Fit the chi-square model for specified m's
if (FALSE) output <- fitstahl(mydata, m=1:5, p=0, error.prob=0)
output <- fitstahl(mydata, m=1, p=0, error.prob=0,tol=0.001)
plot(output$m, output$loglik, lwd=2, type="b")
# Find the MLE of m in the chi-square model
if (FALSE) mle <- fitstahl(mydata, p=0, error.prob=0)
if (FALSE) {
# Simulate data under the Stahl model, no errors
mydata <- sim.cross(mymap, n.ind=250, type="bc",
error.prob=0, m=3, p=0.1)
# Find MLE of m for the Stahl model with known p
mle.stahl <- fitstahl(mydata, p=0.1, error.prob=0)
# Fit the Stahl model with unknown p and m,
# get results for m=0, 1, 2, ..., 8
output <- fitstahl(mydata, m=0:8, error.prob=0)
plot(output$m, output$loglik, type="b", lwd=2)}
Run the code above in your browser using DataLab