Last data update: 2014.03.03

R: scoresinglemod
scoresinglemodR Documentation

scoresinglemod

Description

Determines the set of scores corresponding to a single model fit to a diversity values of subsamples of a given sample and its nested samples.

Usage

scoresinglemod(fsm, precision.lv=c(0.0001, 0.005, 0.005), plaus.pen=500)

Arguments

fsm

fitsinglemod object

precision.lv

vector of precision level values for each criterion: 1. discrepancy – mean percentage error between rarefaction data points and model predicion, 2. Sample accuracy – percentage error between observed diversity of full rarefaction data and estimated diversity of full data from subsample, 3. local similarity. The scores for each criteria are defined as 1 + (multiples of bin sizes)

plaus.pen

penalty score for breaking the plausibility criterion: a model fit should be monotonically increasing and should have a slowing rate of species accumulation.

Details

The score for a given model is only meaningful when compared with scores of other models. Lower score = better for predicting the population diversity. To assess the performance of a single model, it is more informative to use fitsinglemod function.

Value

A list of class scoresingleMod containing the scores of the fit of the model to the diversity samples. This includes the following:

discrepancy

score for discrepancy, aggregated across all nested subsamples

accuracy

score for accuracy of full sample prediction, aggregated across all nested subsamples

similarity

score for similarity of curves for different samples

plausibility

score for plausibility criterion

binsize

vector of user-specified precision values used to translate values associated with each criterion into scores

plausibility.penalty

penalty score for implausible diversity curve

modname

model name

Author(s)

Daniel Laydon, Aaron Sim, Charles Bangham, Becca Asquith

References

Laydon, D., Melamed, A., Sim, A., Gillet, N. A., Sim, K., Darko, S., Kroll, S., Douek, D. C., Price, D., Bangham, C. R. M., Asquith, B., Quantification of HTLV-1 clonality and TCR diversity, PLOS Comput. Biol. 2014

See Also

fitsinglemod

Examples

require(DivE)
data(Bact1)
data(ModelSet)
data(ParamSeeds)
data(ParamRanges)

testmodels <- list()
testmeta <- list()
paramranges <- list()   

# Choose a single model

testmodels <- c(testmodels, ModelSet[1])
# testmeta <- (ParamSeeds[[1]]) # Commented out for sake of brevity)
testmeta <- matrix(c(0.9451638, 0.007428265, 0.9938149, 1.0147441, 0.009543598, 0.9870419),
                        nrow=2, byrow=TRUE, dimnames=list(c(), c("a1", "a2", "a3"))) # Example seeds
paramranges <- ParamRanges[[1]]

# Create divsubsamples object (NB: For quick illustration only -- not default parameters)
dss_1 <- divsubsamples(Bact1, nrf=2, minrarefac=1, maxrarefac=40, NResamples=5)
dss_2 <- divsubsamples(Bact1, nrf=2, minrarefac=1, maxrarefac=65, NResamples=5)
dss <- list(dss_2, dss_1)

# Fit the model (NB: For quick illustration only -- not default parameters)
fsm <- fitsinglemod(model.list=testmodels, init.param=testmeta, param.range=paramranges,
                    main.samp=Bact1, dssamps=dss, fitloops=1, data.default=FALSE,
                    subsizes=c(65, 40), 
                    numit=2) # numit chosen to be extremely small to speed up example


# Score the model
ssm <- scoresinglemod(fsm)

ssm
summary(ssm)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(DivE)
Loading required package: deSolve

Attaching package: 'deSolve'

The following object is masked from 'package:graphics':

    matplot

Loading required package: FME
Loading required package: rootSolve
Loading required package: coda
Loading required package: rgeos
rgeos version: 0.3-19, (SVN revision 524)
 GEOS runtime version: 3.5.0-CAPI-1.9.0 r4084 
 Linking to sp version: 1.2-3 
 Polygon checking: TRUE 

Loading required package: sp
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/DivE/scoresinglemod.Rd_%03d_medium.png", width=480, height=480)
> ### Name: scoresinglemod
> ### Title: scoresinglemod
> ### Aliases: scoresinglemod scoresinglemod.default print.scoresingleMod
> ###   summary.scoresingleMod print.summary.scoresingleMod
> ### Keywords: diversity
> 
> ### ** Examples
> 
> require(DivE)
> data(Bact1)
> data(ModelSet)
> data(ParamSeeds)
> data(ParamRanges)
> 
> testmodels <- list()
> testmeta <- list()
> paramranges <- list()   
> 
> # Choose a single model
> 
> testmodels <- c(testmodels, ModelSet[1])
> # testmeta <- (ParamSeeds[[1]]) # Commented out for sake of brevity)
> testmeta <- matrix(c(0.9451638, 0.007428265, 0.9938149, 1.0147441, 0.009543598, 0.9870419),
+                         nrow=2, byrow=TRUE, dimnames=list(c(), c("a1", "a2", "a3"))) # Example seeds
> paramranges <- ParamRanges[[1]]
> 
> # Create divsubsamples object (NB: For quick illustration only -- not default parameters)
> dss_1 <- divsubsamples(Bact1, nrf=2, minrarefac=1, maxrarefac=40, NResamples=5)
> dss_2 <- divsubsamples(Bact1, nrf=2, minrarefac=1, maxrarefac=65, NResamples=5)
> dss <- list(dss_2, dss_1)
> 
> # Fit the model (NB: For quick illustration only -- not default parameters)
> fsm <- fitsinglemod(model.list=testmodels, init.param=testmeta, param.range=paramranges,
+                     main.samp=Bact1, dssamps=dss, fitloops=1, data.default=FALSE,
+                     subsizes=c(65, 40), 
+                     numit=2) # numit chosen to be extremely small to speed up example
Fitting loop 1 
Performing fitting routine for sample  1 
Choosing optimal initial parameters for global fit 
Performing global fit 
Performing local fit 
Performing fitting routine for sample  2 
Choosing optimal initial parameters for global fit 
Performing global fit 
Performing local fit 
> 
> 
> # Score the model
> ssm <- scoresinglemod(fsm)
> 
> ssm
Scoring results ($[colnames]):
         discrepancy accuracy similarity plausibility
logistic         162     55.5         69          500
> summary(ssm)
Call:
scoresinglemod.default(fsm = fsm)

Single model scoring setup summary:
     Model.name precision.fit precision.accuracy precision.similarity
[1,] "logistic" "1e-04"       "0.005"            "0.005"             
     Plausibility.penalty
[1,] "500"               
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>