Title: | Selection Response Analysis |
---|---|
Description: | Artificial selection through selective breeding is an efficient way to induce changes in traits of interest in experimental populations. This package (sra) provides a set of tools to analyse artificial-selection response datasets. The data typically feature for several generations the average value of a trait in a population, the variance of the trait, the population size and the average value of the parents that were chosen to breed. Sra implements two families of models aiming at describing the dynamics of the genetic architecture of the trait during the selection response. The first family relies on purely descriptive (phenomenological) models, based on an autoregressive framework. The second family provides different mechanistic models, accounting e.g. for inbreeding, mutations, genetic and environmental canalization, or epistasis. The parameters underlying the dynamics of the time series are estimated by maximum likelihood. The sra package thus provides (i) a wrapper for the R functions mle() and optim() aiming at fitting in a convenient way a predetermined set of models, and (ii) some functions to plot and analyze the output of the models. |
Authors: | Arnaud Le Rouzic |
Maintainer: | Arnaud Le Rouzic <[email protected]> |
License: | GPL-2 |
Version: | 0.1.4.1 |
Built: | 2025-01-19 05:46:11 UTC |
Source: | https://github.com/lerouzic/sra |
This package (sra
) provides a set of tools to analyse artificial-selection response datasets. The data typically feature for several generations the average value of a trait in a population, the variance of the trait, the population size and the average value of the parents that were chosen to breed. sra
implements two families of models aiming at describing the dynamics of the genetic architecture of the trait during the selection response. The first family relies on purely descriptive (phenomenological) models, based on an autoregressive framework. The second family provides different mechanistic models, accounting e.g.\ for inbreeding, mutations, genetic and environmental canalization, or epistasis. The parameters underlying the dynamics of the time series are estimated by maximum likelihood. The sra
package thus provides (i) a wrapper for the R functions mle
and optim
aiming at fitting in a convenient way a predetermined set of models, and (ii) some functions to plot and analyze the output of the models.
Package: | sra |
Type: | Package |
Version: | 0.1 |
License: | GPL-2 |
Data set The user must provide (i) a vector containing the mean phenotype for all generations, (ii) a vector containing the phenoypic variance, (iii) a vector for the population sizes, (iv) a vector for the mean phenotype of the breeders, (v) (if available) a vector of the phenotypic variances among breeders. Several time series (e.g.\ several lines submitted to similar or different selection pressures) can be analyzed.
Phenomenological models The function sraAutoreg
fits an autoregressive model to the variance trends, and provides a description of the dynamics of the genetic architecture that is not based on a priori biological mechanisms. The complexity of the model can be adjusted by adding extra autoregressive parameters.
Scaling The relevant scale for genetic architecture models is not necessarily the original measurement scale. Autoregressive models can be run from data e.g.\ on a log scale, but the package also provides two additional 'scales' that are specific to genetic architecture properties. sraAutoregHerit
fits the same models as sraAutoreg
, but considering that the dynamics of environmental variance is constrained by the quantity known as "heritability" (ratio between additive and phenotypic variances). sraAutoregEvolv
proposes that both genetic and environmental variances are constrained by the mean of the population ("mean-scaled evolvability").
Mechanistic models Classical quantitative-genetics models are also provided. sraCstvar
implements a "constant-variance" model, sraDrift
considers the effects of inbreeding on the additive genetic variance, sraMutation
introduces some mutational variance, sraCanalization
illustrates the impact of a simple model of genetic and environmental canalization, sraDirepistasis
considers directional epistasis, and sraSelection
models the effect of unavoidable natural (stabilizing) selection competing with directional artificial selection.
Plotting and analysis All the models provide an objet of class srafit
that can be plotted directly (see e.g. plot.srafit
).
Arnaud Le Rouzic
Maintainer: Arnaud Le Rouzic <[email protected]>
Le Rouzic, A., Houle, D., and Hansen, T.F. (2011) A modelling framework for the analysis of artificial selection-response time series. Genetics Research.
########### Generating a dummy dataset ################ m <- c(12,11,12,14,18,17,19,22,20,19) v <- c(53,47,97,155,150,102,65,144,179,126) s <- c(15,14,14,17,21,20,22,25,24,NA) n <- c(100,80,120,60,100,90,110,80,60,100) ########## Making a sra data set ####################### data <- sraData(phen.mean=m, phen.var=v, phen.sel=s, N=n) #################### Data Analysis #################### # Autoregressive models autor <- sraAutoreg(data) # AIC of the model: AIC(autor) # Maximum-likelihood estimates coef(autor) autor.herit <- sraAutoregHerit(data) autor.evolv <- sraAutoregEvolv(data) # Mechanistic models # Constant variance cstvar <- sraCstvar(data) # Inbreeding drift <- sraDrift(data) # Plotting plot(drift) plot(drift, var=TRUE)
########### Generating a dummy dataset ################ m <- c(12,11,12,14,18,17,19,22,20,19) v <- c(53,47,97,155,150,102,65,144,179,126) s <- c(15,14,14,17,21,20,22,25,24,NA) n <- c(100,80,120,60,100,90,110,80,60,100) ########## Making a sra data set ####################### data <- sraData(phen.mean=m, phen.var=v, phen.sel=s, N=n) #################### Data Analysis #################### # Autoregressive models autor <- sraAutoreg(data) # AIC of the model: AIC(autor) # Maximum-likelihood estimates coef(autor) autor.herit <- sraAutoregHerit(data) autor.evolv <- sraAutoregEvolv(data) # Mechanistic models # Constant variance cstvar <- sraCstvar(data) # Inbreeding drift <- sraDrift(data) # Plotting plot(drift) plot(drift, var=TRUE)
The sraAutoreg
functions are wrappers for the maximum-likelihood optimization function mle
. They propose descriptive models for the dynamics of genetic architectures of different complexities based on an auto-regressive framework, additional parameters corresponding to different generation lags. The model can also be fit considering logatithmic, "heritability" and "evolvability" scales.
sraAutoreg(sradata, active = c(FALSE, TRUE, FALSE, FALSE), start = NULL, fixed = NULL, negative.k = FALSE, rand = 0, rep = 1, ...) sraAutoregLog(sradata, active = c(FALSE, TRUE, FALSE, FALSE), start = NULL, fixed = NULL, negative.k = FALSE, rand = 0, rep = 1, ...) sraAutoregHerit(sradata, active = c(FALSE, TRUE, FALSE, FALSE), start = NULL, fixed = NULL, negative.k = FALSE, rand = 0, rep = 1, ...) sraAutoregEvolv(sradata, active = c(FALSE, TRUE, FALSE, FALSE), start = NULL, fixed = NULL, negative.k = FALSE, rand = 0, rep = 1, ...)
sraAutoreg(sradata, active = c(FALSE, TRUE, FALSE, FALSE), start = NULL, fixed = NULL, negative.k = FALSE, rand = 0, rep = 1, ...) sraAutoregLog(sradata, active = c(FALSE, TRUE, FALSE, FALSE), start = NULL, fixed = NULL, negative.k = FALSE, rand = 0, rep = 1, ...) sraAutoregHerit(sradata, active = c(FALSE, TRUE, FALSE, FALSE), start = NULL, fixed = NULL, negative.k = FALSE, rand = 0, rep = 1, ...) sraAutoregEvolv(sradata, active = c(FALSE, TRUE, FALSE, FALSE), start = NULL, fixed = NULL, negative.k = FALSE, rand = 0, rep = 1, ...)
sradata |
A data object generated by |
active |
A vector of four booleans, corresponding to the active lags for both genetic and environmental variances (see Details). By default, only lag 1 is active, corresponding to an exponential change of the variances. |
start |
A named list of starting values for the convergence algorithm. |
fixed |
A named list of the parameters that have to be kept constant. |
negative.k |
Whether or not the k parameters can take negative values. Negtive values for k lead to more complex likelihood functions, and the resulting dynamics may display cyclic patterns. |
rand |
Amount of randomness for the starting values. Useful in case of convergence issues. Although this variable can take any positive value, reasonable figures should not exceed 0.2. |
rep |
Number of convergence attempts. When the likelihood function is complex, which is often the case when the number of parameters exceeds 6 to 8, convergence may often fail or end up on a local maximum. When |
... |
Additional parameters to be passed to |
Model
The following summarizes the models developed in Le Rouzic et al. 2010.
The mean of the population changes according to the Lande equation (Lande and Arnold 1983):
where is the selection gradient at generation t.
The genetic architecture models predict the dynamics of a parameter P as:
Models with time lags > 3 could be easily implemented, but convergence issues increase with the number of parameters. The first time points are calculated as if , e.g.
.
Each model considers the dynamics of two independent parameters, one related to the additive genetic variance (), one related to the residual (environmental) variance
(which actually also accounts for all non-additive genetic variance).
The default model sraAutoreg
considers directly the dynamics of (parameters:
kA0
, kA1
, kA2
, and kA3
) and the dynamics of (parameters
kE0
, kE1
, kE2
, and kE3
).
The log scale turns a multiplicative trait into an additive one, and is particularly relevant for ratio-scale traits (i.e. most quantitative traits such as size, fertility, etc). The original data is transformed assuming log-normality, and the likelihood is computed based on the log-normal density function.
The "heritability" model sraAutoregHerit
focuses on the dynamics of , described by the parameters
kA0
, kA1
, kA2
, and kA3
, and considers that kE0
, kE1
, kE2
, and kE3
describe the dynamics of the phenotypic variance . Therefore,
is constrained both by the dynamics of
and the independent dynamics of
.
The "evolvability" model considers that kA0
, kA1
, kA2
, and kA3
describe the dynamics of , and
kE0
, kE1
, kE2
, and kE3
the dynamics of .
Shortcut for active and inactive parameters
The user will often have to fit models of different complexity. This can be achieve by manipulating the active
vector. c(FALSE,FALSE,FALSE,FALSE)
corresponds to a constant-variance model (no dynamic parameter), c(TRUE,FALSE,FALSE,FALSE)
to a case in which only kA0
and kE0
are active, c(TRUE,TRUE,FALSE,FALSE)
to active parameters for lags 0 and 1 only, etc. The total number of parameters in the model will be , where
is the number of
TRUE
in the vector active
.
To bypass the constrains of this shortcut, it is possible to specify the active and inactive parameters through the list of starting values. A combination such as active=c(TRUE,FALSE,TRUE,
FALSE)
, start=list(kA1=0,kE3=NA)
, fixed=list(kE2=1)
will lead to a model with 8 active parameters (mu0
, varA0
, varE0
, kA0
, kE0
, kA1
(which starting value will be 0), kA2
, and kE3
(which starting value, specified as NA
, will be determined via the function sraStartingvalues
. All other parameters are fixed.
Parameterization
The models thus involve up to 11 parameters: three initial values (,
and
), four parameters to describe the dynamics of the additive variance (or relative variable such as
or
) (
kA0
, kA1
, kA2
, and kA3
), and four parameters for the environmental variance (or , or
):
kE0
, kE1
, kE2
, and kE3
. To make numerical convergence more efficient, the following parameterization was implemented: parameters mu0
, logvarA0
and logvarE0
correspond to the estimates of the initial values of, respectively, the population mean, the logarithm of the additive variance, and the logarithm of the environmental variance. The parameters kA0
and kE0
are calculated as relative to the initial values of the dynamic variable, e.g. relativekA0
= (so that
relativekA0
has the same unit and the same order of magnitude as kA1
, kA2
and kA3
).
The functions return objects of class srafit
, a list containing information about the model, the data, and the parameter estimates. Some standard R functions can be applied to the object, including AIC
(AIC.srafit
), logLik
(logLik.srafit
), vcov
(vcov.srafit
), coef
(coef.srafit
) confint
(confint.srafit
), and plot
(plot.srafit
).
Arnaud Le Rouzic
Le Rouzic, A., Houle, D., and Hansen, T.F. (2011) A modelling framework for the analysis of artificial selection-response time series. Genetics Research.
Lande, R., and Arnold, S. (1983) The measurement of selection on correlated characters. Evolution 37:1210-1226.
sraCstvar
, sraDrift
and all other mechanistic models, sraAutoregTsMinuslogL
and sraAutoregTimeseries
for some details about the internal functions, AIC.srafit
, logLik.srafit
, vcov.srafit
, coef.srafit
, confint.srafit
, plot.srafit
for the analysis of the results.
# Making the example reproducible ########### Generating a dummy dataset ################ m <- c(12,11,12,14,18,17,19,22,20,19) v <- c(53,47,97,155,150,102,65,144,179,126) s <- c(15,14,14,17,21,20,22,25,24,NA) n <- c(100,80,120,60,100,90,110,80,60,100) ########## Making a sra data set ####################### data <- sraData(phen.mean=m, phen.var=v, phen.sel=s, N=n) #################### Data Analysis #################### # Autoregressive models autor <- sraAutoreg(data) # Details of the model: AIC(autor) coef(autor) plot(autor) plot(autor, var=TRUE) # Alternative scales autor.log <- sraAutoregLog(data) autor.herit <- sraAutoregHerit(data) autor.evolv <- sraAutoregEvolv(data) # Changes in the complexity of the model: autor0 <- sraAutoreg(data, active=c(TRUE,TRUE,FALSE,FALSE)) # In case of convergence issues autor1 <- sraAutoreg(data, active=c(TRUE,TRUE,TRUE,TRUE), rep=2, rand=0.1)
# Making the example reproducible ########### Generating a dummy dataset ################ m <- c(12,11,12,14,18,17,19,22,20,19) v <- c(53,47,97,155,150,102,65,144,179,126) s <- c(15,14,14,17,21,20,22,25,24,NA) n <- c(100,80,120,60,100,90,110,80,60,100) ########## Making a sra data set ####################### data <- sraData(phen.mean=m, phen.var=v, phen.sel=s, N=n) #################### Data Analysis #################### # Autoregressive models autor <- sraAutoreg(data) # Details of the model: AIC(autor) coef(autor) plot(autor) plot(autor, var=TRUE) # Alternative scales autor.log <- sraAutoregLog(data) autor.herit <- sraAutoregHerit(data) autor.evolv <- sraAutoregEvolv(data) # Changes in the complexity of the model: autor0 <- sraAutoreg(data, active=c(TRUE,TRUE,FALSE,FALSE)) # In case of convergence issues autor1 <- sraAutoreg(data, active=c(TRUE,TRUE,TRUE,TRUE), rep=2, rand=0.1)
The sra functions for mechanistic model are wrappers for the maximum-likelihood optimization routine mle
. They implement classical quantitative genetics models, fit them to artificial-selection time series, and provide estimates of e.g. the effective population size, the mutational variance, the strength of genetic / environmental canalization, the directionality and strength of epistasis, etc., given some assumptions about the properties of the genetic architecture.
sraCstvar(sradata, start=NULL, fixed=NULL, macroE=FALSE, Bulmer=TRUE, ...) sraDrift(sradata, start=NULL, fixed=NULL, macroE=FALSE, Bulmer=TRUE, ...) sraMutation(sradata, start=NULL, fixed=NULL, macroE=FALSE, Bulmer=TRUE, ...) sraCanalization(sradata, start=NULL, fixed=NULL, macroE=FALSE, Bulmer=TRUE, ...) sraCanalizationOpt(sradata, start=NULL, fixed=NULL, macroE=FALSE, Bulmer=TRUE, ...) sraSelection(sradata, start=NULL, fixed=NULL, macroE=FALSE, Bulmer=TRUE, ...) sraDirepistasis(sradata, start=NULL, fixed=NULL, macroE=FALSE, ...)
sraCstvar(sradata, start=NULL, fixed=NULL, macroE=FALSE, Bulmer=TRUE, ...) sraDrift(sradata, start=NULL, fixed=NULL, macroE=FALSE, Bulmer=TRUE, ...) sraMutation(sradata, start=NULL, fixed=NULL, macroE=FALSE, Bulmer=TRUE, ...) sraCanalization(sradata, start=NULL, fixed=NULL, macroE=FALSE, Bulmer=TRUE, ...) sraCanalizationOpt(sradata, start=NULL, fixed=NULL, macroE=FALSE, Bulmer=TRUE, ...) sraSelection(sradata, start=NULL, fixed=NULL, macroE=FALSE, Bulmer=TRUE, ...) sraDirepistasis(sradata, start=NULL, fixed=NULL, macroE=FALSE, ...)
sradata |
A data object generated by |
start |
A named list of starting values for the convergence algorithm. |
fixed |
A named list of the parameters that have to be kept constant. |
macroE |
Whether or not macro-environmental effects (random deviation of the phenotypic mean each generation) should be included. This might have some side effects. |
Bulmer |
Whether or not the impact of linkage disequilibrium (Bulmer effect) due to selection on variance should be accounted for. |
... |
Additional parameters to be passed to |
All functions (except sraDirepistasis
) rely on the same underlying model, and thus simply provide convenient shortcuts for different sets of parameters to fit.
mu0
is the initial phenotype of the population.
logvarA0
is the logarithm of the initial additive variance in the population.
logvarE0
is the logarithm of the initial environmental variance in the population.
logNe
is the logarithm of the effective population size.
logn
is the logarithm of the effective number of loci.
logvarM
is the logarithm of the mutational variance.
kc
and kg
are the strength of environmental and genetic canalization, respectively.
o
corresponds to the 'optimum' phenotype. When fixed and set to NA
, o
is identical to mu0
. For convenience, the same optimum is used for environmental canalization, genetic canalization and natural stabilizing selection.
s
corresponds to the strength of natural selection.
logvarepsilon
is the logarithm of the variance of the epistatic coefficient (). This parameter is fixed by default, since it is unlikely that realistic data sets contain enough information to estimate it properly.
The dynamic model that is fitted (except of the directional epistasis, detailed in the next paragraph) is:
,
and
are parameters of the model,
is the selection gradient, calculated for each generation from the data set, and
.
The directional epistasis model has its own setting:
Where epsilon
is a key parameter, representing the directionality of epistasis (Hansen and Wagner 2001, Carter et al. 2005). The properties of the likelihood function when epsilon varies makes numerical convergence tricky, and the function SRAdirepistasis
actually performs two model fits: one for positive epsilons (the estimated parameter being logepsilon
) and one for negative epsilons (estimating logminusepsilon
). The likelihood of both models is then compared, and the best model is returned, providing either logepsilon
or logminusepsilon
. Although part of the model, the parameter logvarepsilon
appeared to affect environmental variance only weakly, and its estimation is problematic in most cases.
These models are extensively described in le Rouzic et al 2010.
The functions return objects of class srafit
, a list containing information about the model, the data, and the parameter estimates. Some standard R functions can be applied to the object, including AIC
(AIC.srafit
), logLik
(logLik.srafit
), vcov
(vcov.srafit
), coef
(coef.srafit
) confint
(confint.srafit
), and plot
(plot.srafit
).
Arnaud Le Rouzic
Carter, A.J.R., Hermisson, J. and Hansen, T.F. (2005) The role of epistatic genetic interactions in the response to selection and the evolution of evolvability. Theor. Pop. Biol. 68, 179-196.
Hansen, T.F. and Wagner, G.P. (2001) Modelling genetic architecture: a multilinear theory of gene interaction. Theor. Pop. biol. 59, 61-86.
Le Rouzic, A., Houle, D., and Hansen, T.F. (2010) A modelling framework for the analysis of artificial selection-response time series. in prep.
sraAutoreg
, sraAutoregHerit
and sraAutoregEvolv
for phenomenological models, sraAutoregTsMinuslogL
and sraAutoregTimeseries
for some details about the internal functions, AIC.srafit
, logLik.srafit
,vcov.srafit
, coef.srafit
, confint.srafit
, plot.srafit
for the analysis of the results.
########### Generating a dummy dataset ################ m <- c(12,11,12,14,18,17,19,22,20,19) v <- c(53,47,97,155,150,102,65,144,179,126) s <- c(15,14,14,17,21,20,22,25,24,NA) n <- c(100,80,120,60,100,90,110,80,60,100) ########## Making a sra data set ####################### data <- sraData(phen.mean=m, phen.var=v, phen.sel=s, N=n) #################### Data Analysis #################### cstvar <- sraCstvar(data) drift <- sraDrift(data) direpi <- sraDirepistasis(data) # In case of convergence problems, better starting values can be provided: direpi <- sraDirepistasis(data, start=list(mu0=10, logvarA0=log(20), logvarE0=NA), fixed=list(logNe=log(50))) plot(cstvar) AIC(direpi)
########### Generating a dummy dataset ################ m <- c(12,11,12,14,18,17,19,22,20,19) v <- c(53,47,97,155,150,102,65,144,179,126) s <- c(15,14,14,17,21,20,22,25,24,NA) n <- c(100,80,120,60,100,90,110,80,60,100) ########## Making a sra data set ####################### data <- sraData(phen.mean=m, phen.var=v, phen.sel=s, N=n) #################### Data Analysis #################### cstvar <- sraCstvar(data) drift <- sraDrift(data) direpi <- sraDirepistasis(data) # In case of convergence problems, better starting values can be provided: direpi <- sraDirepistasis(data, start=list(mu0=10, logvarA0=log(20), logvarE0=NA), fixed=list(logNe=log(50))) plot(cstvar) AIC(direpi)
The functions return the output expected from the corresponding R functions, applied to an object of class srafit
.
## S3 method for class 'srafit' logLik(object, ...) ## S3 method for class 'srafit' AIC(object, ...) ## S3 method for class 'srafit' coef(object, ...) ## S3 method for class 'srafit' confint(object, ...) ## S3 method for class 'srafit' vcov(object, ...)
## S3 method for class 'srafit' logLik(object, ...) ## S3 method for class 'srafit' AIC(object, ...) ## S3 method for class 'srafit' coef(object, ...) ## S3 method for class 'srafit' confint(object, ...) ## S3 method for class 'srafit' vcov(object, ...)
object |
An object of class |
... |
Any additional parameters to the corresponding functions. |
The confidence intervals are calculated from the estimate standard errors, and are thus different (less precise) from what would be calculated from the profile likelihood.
sraAutoreg
, sraCstvar
and other mechanistic models, AIC
, coef
, logLik
, confint
, vcov
.
########### Generating a dummy dataset ################ m <- c(12,11,12,14,18,17,19,22,20,19) v <- c(53,47,97,155,150,102,65,144,179,126) s <- c(15,14,14,17,21,20,22,25,24,NA) n <- c(100,80,120,60,100,90,110,80,60,100) ########## Making a sra data set ####################### data <- sraData(phen.mean=m, phen.var=v, phen.sel=s, N=n) #################### Data Analysis #################### cstvar <- sraCstvar(data) AIC(cstvar) logLik(cstvar) coef(cstvar) confint(cstvar) vcov(cstvar)
########### Generating a dummy dataset ################ m <- c(12,11,12,14,18,17,19,22,20,19) v <- c(53,47,97,155,150,102,65,144,179,126) s <- c(15,14,14,17,21,20,22,25,24,NA) n <- c(100,80,120,60,100,90,110,80,60,100) ########## Making a sra data set ####################### data <- sraData(phen.mean=m, phen.var=v, phen.sel=s, N=n) #################### Data Analysis #################### cstvar <- sraCstvar(data) AIC(cstvar) logLik(cstvar) coef(cstvar) confint(cstvar) vcov(cstvar)
These functions plot in a nice way the content of objects of class srafit
, the result of sra
model fitting.
## S3 method for class 'srafit' plot(x, series = levels(x$data$rep), resid = FALSE, variance = FALSE, ...) sraPlotMean(srafit, series=levels(srafit$data$rep), legend=TRUE, xlim=NULL, ylim=NULL, xlab=NULL, ylab=NULL, pch=1, ...) sraPlotMeanResid(srafit, series=levels(srafit$data$rep)) sraPlotVar (srafit, series=levels(srafit$data$rep), legend=TRUE, xlim=NULL, ylim=NULL, xlab=NULL, ylab=NULL, pch=1, ...) sraPlotVarResid (srafit, series=levels(srafit$data$rep)) sraPlotlegend(labels, estimates, AIC=NULL, confint=NULL, location="topleft") sraFormatlegend(names, values, AIC=NULL, ...)
## S3 method for class 'srafit' plot(x, series = levels(x$data$rep), resid = FALSE, variance = FALSE, ...) sraPlotMean(srafit, series=levels(srafit$data$rep), legend=TRUE, xlim=NULL, ylim=NULL, xlab=NULL, ylab=NULL, pch=1, ...) sraPlotMeanResid(srafit, series=levels(srafit$data$rep)) sraPlotVar (srafit, series=levels(srafit$data$rep), legend=TRUE, xlim=NULL, ylim=NULL, xlab=NULL, ylab=NULL, pch=1, ...) sraPlotVarResid (srafit, series=levels(srafit$data$rep)) sraPlotlegend(labels, estimates, AIC=NULL, confint=NULL, location="topleft") sraFormatlegend(names, values, AIC=NULL, ...)
x |
An object of class |
srafit |
An object of class |
series |
The identifier ( |
resid |
Whether or not the residuals (data - model expectation) should be displayed. |
variance |
If |
legend |
If |
xlim |
Same meaning as in |
ylim |
Same meaning as in |
xlab |
Same meaning as in |
ylab |
Same meaning as in |
pch |
Same meaning as in |
labels |
Formatted labels of the names of the estimates in the legend. |
estimates |
Values of the parameter estimates. |
AIC |
Value of the AIC. If |
confint |
Confidence intervals of the parameters. If |
location |
Location of the legend, corresponding to |
names |
Names of the parameters (as defined in the models). |
values |
Values of the parameter estimates (as defined in the models). |
... |
For |
The only function that should be used by the end user is plot.srafit
.
Arnaud Le Rouzic
########### Generating a dummy dataset ################ m <- c(12,11,12,14,18,17,19,22,20,19) v <- c(53,47,97,155,150,102,65,144,179,126) s <- c(15,14,14,17,21,20,22,25,24,NA) n <- c(100,80,120,60,100,90,110,80,60,100) ########## Making a sra data set ####################### data <- sraData(phen.mean=m, phen.var=v, phen.sel=s, N=n) cstvar <- sraCstvar(data) plot(cstvar) plot(cstvar, xlim=c(3,9)) plot(cstvar, var=TRUE, ylab="This is a custom Y axis label") plot(cstvar, resid=TRUE, legend=FALSE, main="Constant variance model fit")
########### Generating a dummy dataset ################ m <- c(12,11,12,14,18,17,19,22,20,19) v <- c(53,47,97,155,150,102,65,144,179,126) s <- c(15,14,14,17,21,20,22,25,24,NA) n <- c(100,80,120,60,100,90,110,80,60,100) ########## Making a sra data set ####################### data <- sraData(phen.mean=m, phen.var=v, phen.sel=s, N=n) cstvar <- sraCstvar(data) plot(cstvar) plot(cstvar, xlim=c(3,9)) plot(cstvar, var=TRUE, ylab="This is a custom Y axis label") plot(cstvar, resid=TRUE, legend=FALSE, main="Constant variance model fit")
The data necessary to analyse selection response time series are, for each generation, (i) the mean phenotype of the population, (ii) the phenotypic variance, (iii) the mean of the breeders, and (iv) the population size. These data have to be grouped into an object of class "sradata", which can be provided to the sra analysis functions such as sraAutoreg
or sraCstvar
.
sraData(phen.mean, phen.var, phen.sel, var.sel=NULL, N=NULL, gen=NULL, rep=NULL)
sraData(phen.mean, phen.var, phen.sel, var.sel=NULL, N=NULL, gen=NULL, rep=NULL)
phen.mean |
The vector of phenotypic means. |
phen.var |
The vector of phenotypic variances. |
phen.sel |
The vector of the mean phenotype of breeders. Can be |
var.sel |
The vector of the phenotypic variances if breeders. If not provided ( |
N |
The vector of population size for each generation (before selection). |
gen |
The generation numbers. Useful when several times series are provided. |
rep |
The repetition identification. Useful when several time series are provided. |
If not provided, the default value for N
is 100. Incorrect values for N
will affect the likelihood value and the maximum-likelihood estimates.
gen
will be assumed to vary from 1 to the maximum number of generations by default.
If more than one time series are provided, it is dangerous not to specify gen
or rep
. rep
can be any unique identifier. For instance, fro two times series of 3 generations each, gen
can be c(1,2,3,1,2,3)
and rep
can be c("up","up","up","down","down","down")
.
An object of class sradata
.
sraAutoreg
, sraCstvar
, and other mechanistic models, sraAutoregTimeseries
.
########### Generating a dummy dataset ################ m <- c(12,11,12,14,18,17,19,22,20,19) v <- c(53,47,97,155,150,102,65,144,179,126) s <- c(15,14,14,17,21,20,22,25,24,NA) n <- c(100,80,120,60,100,90,110,80,60,100) ########## Making a sra data set ####################### data <- sraData(phen.mean=m, phen.var=v, phen.sel=s, N=n)
########### Generating a dummy dataset ################ m <- c(12,11,12,14,18,17,19,22,20,19) v <- c(53,47,97,155,150,102,65,144,179,126) s <- c(15,14,14,17,21,20,22,25,24,NA) n <- c(100,80,120,60,100,90,110,80,60,100) ########## Making a sra data set ####################### data <- sraData(phen.mean=m, phen.var=v, phen.sel=s, N=n)