rtmvnormDT3 | R Documentation |
Function to sample from the posterior of estimated genomic cline parameters.
rtmvnormDT3(
nsamp = 1,
meanlogv,
meanlogitcentre,
varlogv,
varlogitcentre,
covlogvlogitcentre,
lower = c(-Inf, -Inf),
upper = c(Inf, Inf)
)
nsamp |
Numeric. Number of random posterior samples. Default 1. |
meanlogv |
Name of the column in a |
meanlogitcentre |
Name of the column in a |
varlogv |
Name of the column in a |
varlogitcentre |
Name of the column in a |
covlogvlogitcentre |
Name of the column in a |
lower |
Numeric vector. If truncation is desired, the lower cutoff for the two variables. |
upper |
Numeric vector. If truncation is desired, the upper cutoff for the two variables. |
rtmvnormDT3
is a generalized version of two internal gghybrid
functions that themselves are designed for sampling from the parameter
proposal distributions for ln(v
) and logit(centre
). Its purpose is to take samples from the joint posterior of the two parameters for one
or more test subjects simultaneously. While the option names are specific to gghybrid
, the column names are left open and so the function can be
used to sample from any set of bivariate normal distributions, including with truncation.
The function must be run from within a data.table
, which can be subsetted by row if desired, as shown in the example.
A data.table
and data.frame
with one row per sample per test subject.
locus |
the name of the chosen test.subject. If a test subject other than locus is chosen, the column will be named accordingly. |
log_v |
posterior samples of ln(v), or another chosen variable. |
logit_centre |
posterior samples of logit(centre), or another chosen variable. |
Richard Ian Bailey richardianbailey@gmail.com
## Not run:
##########################################################################
#Sample from the genomic cline parameter posteriors of a subset of 5 loci#
##########################################################################
#The function must be run from within a data.table, after the comma. Subsetting by row can be carried out.
#In this case I'm sampling from the 'gc' object created in the documentation examples for 'ggcline'.
gcsamp=gc$gc[locus%in%c("ACO1","CLTA","LNPEP","HSDL2","MCCC2"), #subsetting the data.table by row to only include these 5 loci#
rtmvnormDT3(
nsamp=500, #default is 1 sample per locus#
meanlogv=mean_log_v, #no default, column must be specified#
meanlogitcentre=mean_logit_centre, #no default, column must be specified#
varlogv=var_log_v, #no default, column must be specified#
varlogitcentre=var_logit_centre, #no default, column must be specified#
covlogvlogitcentre=cov_log_v_logit_centre, #no default, column must be specified#
lower=c(-Inf,-Inf), #default, not needed for sampling from the ggcline posterior but included in case it's useful in other contexts#
upper=c(Inf,Inf) #default, not needed for sampling from the ggcline posterior but included in case it's useful in other contexts#
), #end of rtmvnormDT3 function#
by="locus"]; #indicate a grouping variable for the sampling. This will be the name of the first column in the resulting table#
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.