Learn R Programming

bayespref (version 1.0)

prefPlot: Plot population and individual preferences

Description

This function will plot the posterior densities for population-level and individual-level preferences based upon a bayesPref analysis.

Usage

prefPlot(prefres = NULL, burn = 0, ind = TRUE, pop = TRUE, dist = FALSE, ymax = 5, xmin = 0, xmax = 1, dadj = 2, colors = NULL, leg = FALSE, lx = 0.8, ly = 4, catname = NULL, ps = FALSE, file = "./prefplot.eps")

Arguments

prefres
An object returned by bayesPref.
burn
A value indicating the number of burnin samples discarded.
ind
A boolean indicating whether to plot individual-level preferences.
pop
A boolean indicating whether to plot population-level preferences.
dist
A boolean indicating whether to plot population-level preferences based on density of the posterior (default), or whether to plot population-level preferences based on the estimate of the Dirichlet alphas.
ymax
A value indicating the maximum value for the y-axis.
xmin
A value indicating the minimum value for the x-axis.
xmax
A value indicating the maximum value for the x-axis.
dadj
A value indicating the bandwidth used for the smoothing of the density plot.
colors
A vector indicating the colors used for plotting.
leg
A Boolean indicating whether to include a legend in the plot.
lx
A value indicating where the legend begins on the horizontal (x-axis).
ly
A value indicating where the legend begins on the vertical (y-axis).
catname
A vector indicating the names associated with the legend.
ps
A Boolean indicating whether to write the plot to a file.
file
The name of the file the plot is written to.

Examples

Run this code
## Not run: 
# data(YGGV)
# res <- bayesPref(pData=YGGV,mcmcL=1000)
# 
# prefPlot(prefres=res[[1]],burn=100,pop=TRUE) 
# 
# prefPlot(prefres=res[[1]],burn=100,pop=TRUE,ymax=15,leg=TRUE,
# catname=c("Astragalus"," Lotus","Lupine","Medicago"),lx=0.6,ly=14) #includes legend
# 
# prefPlot(prefres=res[[1]],burn=100,ind=FALSE,pop=TRUE,ymax=15,leg=TRUE,
# catname=c("Astragalus"," Lotus","Lupine","Medicago"),lx=0.6,ly=14) #includes only 
# population posterior and legend
# ## End(Not run)

Run the code above in your browser using DataLab