Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/23-hzarMorphoCLT.R
Create a hzar.obsData
object using a table of individual
traits.
1 2 3 | hzar.doCLTData1DRaw(distance, traitValue)
hzar.doNormalData1DRaw(site.dist, traitSite, traitValue)
hzar.mapSiteDist(siteID, distance)
|
distance |
The distance of the sampling site. For
|
traitValue |
The value of the trait of the individual sampled. |
traitSite |
The id of site where the individual was found. |
site.dist |
A named vector mapping site id codes to the distance of the sampling
site. The function |
siteID |
The list of id codes associated with the sampling site. This list
should be identical in length to |
For hzar.doCLTData1DRaw
:
If for any locality, there is only a small number of samples taken, warnings will be issued.
If at any locality, the sample variance is 0, a warning is issued, and additional variance is included by estimating the amount of variance ignored due to measurement error.
For hzar.doNormalData1DRaw
:
Use the helper function hzar.mapSiteDist
to generate
site.dist
.
The hzar.obsData
object created is meant for use with
the models constructed using hzar.makeCline1DNormal
.
A hzar.obsData
object, using the site dinstances and
sample means and variances as calculated from the values given.
Graham Derryberry asterion@alum.mit.edu
hzar.obsData
For a description of this object structure.
hzar.makeCline1DNormal
Make models of normal data.
hzar.first.fitRequest.gC
For compiling those models.
hzar.doFit
For fitting the compiled models.
hzar.doFit.multi
For quickly fitting multiple models.
hzar.mcmc.bindLL
For viewing the mcmc trace.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | data(manakinMorphological);
data(manakinLocations);
mknBL <-
hzar.doNormalData1DRaw(
hzar.mapSiteDist(siteID=manakinLocations$LocalityID,
distance=manakinLocations$distance),
traitSite=manakinMorphological$Locality,
traitValue=manakinMorphological$beard.length)
hzar.plot.obsData(mknBL)
mknBLm <-
hzar.makeCline1DNormal(mknBL, tails="none");
mknBLm <-
hzar.model.addBoxReq(mknBLm,-30,600);
## A quick way to reduce the number of variables
## Assume the observed means to left and right are the
## population means
hzar.meta.fix(mknBLm)$muL <- TRUE
hzar.meta.fix(mknBLm)$muR <- TRUE
## Make the initial variance to the left and right match the
## observed local variance at the left (site A) and right (site L).
hzar.meta.init(mknBLm)$varL<-mknBL$frame["A","var"]
hzar.meta.init(mknBLm)$varR<-mknBL$frame["L","var"]
## Assume the observed variance to left and right is the
## the respective population variance.
hzar.meta.fix(mknBLm)$varL <- TRUE
hzar.meta.fix(mknBLm)$varR <- TRUE
## Now mknBLm has only 3 free parameters instead of 7.
mknBLFR <-
hzar.first.fitRequest.gC(gModel=mknBLm,
obsData=mknBL,
verbose=FALSE);
mknBLFR$mcmcParam$chainLength <- 2e3;
mknBLFR$mcmcParam$burnin <- 5e2;
mknBLF <- hzar.doFit(mknBLFR)
plot(hzar.mcmc.bindLL(mknBLF))
## Not run:
mknBLFR2 <- hzar.next.fitRequest(mknBLF)
## Do more fitting
mknBLFR2$mcmcParam$chainLength <- 1e5;
mknBLFR2$mcmcParam$burnin <- 1e3;
mknBLF2 <- hzar.doFit(mknBLFR2)
plot(hzar.mcmc.bindLL(mknBLF2))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.