# simulated data (stabilizing selection)
z<-rnorm(200,0,2)
W<-rpois(200,exp(1-1*z^2))
d<-as.data.frame(list(W=W,z=z))
# characterize the fitness function
library(mgcv)
ff<-gam(W~s(z),family='poisson',data=d)
# characterize fitness landscape
fl<-fitness.landscape(mod=ff,phenotype="z",PI.method='n')
# (not run) plotting
# plot(fl$points[,1],fl$Wbar,type='l')
# lines(fl$points[,1],fl$WbarPI[1,],lty='dashed')
# lines(fl$points[,1],fl$WbarPI[2,],lty='dashed')
Run the code above in your browser using DataLab