bootstrap.test: Estimate confidence intervals using bootstrap

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/EvoRAG_Code.R

Description

Applies bootstrap analyses to each of the packages models as an alternative way to estimate 95

Usage

1
2
bootstrap.test(DIST, TIME, GRAD, model, parameters, meserr1=0, meserr2=0, 
   breakpoint = "NULL", N = c(1000), starting=NULL)

Arguments

DIST

vector of Euclidean distances for sister pair dataset

TIME

vector of evolutionary ages (i.e. node ages ) for sister pair dataset

GRAD

vector of gradient values (i.e. any continuous variable) for sister pair dataset (see Details)

model

The name of the model to bootstrap.

parameters

a vector containing the maximum likelihood estimates of model parameters. These should be in the order indicated in sisterContinuous.

meserr1

a list of measurement errors that correspond to the first of each species in a sister pair. Order of sister pairs is the same as for DIST.

meserr2

a list of measurement errors that correspond to the second of each species in a sister pair. Order of sister pairs is the same as for DIST.

breakpoint

if using the models BM_2rate or OU_2rate, set this to the maximum likelihood estimate of the breakpoint.

N

The number of bootstrap replicates to perform.

starting

List of starting values. If starting=NULL, the built-in starting parameters are used.

Details

N bootstrap samples are generated, and are used to generate two estimates of the 95

Value

A matrix is returned listing the mean, median, variance, and 95

Author(s)

Jason T. Weir

References

Efron, B. and Tibshirani, R. (1986). The Bootstrap Method for standard errors, confidence intervals, and other measures of statistical accuracy. Statistical Science, Vol 1., No. 1, pp 1-35.

See Also

sisterContinuous

Examples

 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
50
## Not run: 
###EXAMPLE 1

  ###simulate data
  set.seed(seed = 3)
  TIME = runif(n=100, min = 0, max = 10)
  GRAD = runif(n=100, min = 0, max = 60)
  DATA1 <- sim.sisters(TIME = TIME, GRAD=GRAD, parameters = c(2, -0.03), 
     model=c("BM_linear"))

  ###Find the MLE of model parameters
  RESULT <- model.test.sisters(DIST=DATA1[,3], TIME=DATA1[,2], 
     GRAD=DATA1[,1], models=c("BM_linear"))
  intercept <- as.numeric(RESULT[5,1])
  slope <- as.numeric(RESULT[6,1])
  model = c("BM_linear")
  parameters=c(intercept, slope)

  ###Run the bootstrap
  RR <- bootstrap.test(DIST=DATA1[,3], TIME=DATA1[,2],
     GRAD=DATA1[,1], model = "BM_linear", parameters, meserr1=0, 
	 meserr2=0, N = c(100))
  summary <- RR$summary #to show only the summary. 
  bootstraps <- RR$bootstraps #to obtain the bootstraps


###EXAMPLE 2
  ###simulate data
  set.seed(seed = 3)
  TIME = runif(n=100, min = 0, max = 10)
  GRAD = runif(n=100, min = 0, max = 60)
  DATA1 <- sim.sisters(TIME = TIME, GRAD=GRAD, parameters = c(2, -0.03, 1, 
      0.1), model=c("OU_linear"))
  ###Find the MLE of model parameters
  RESULT <- model.test.sisters(DIST=DATA1[,3], TIME=DATA1[,2],    
     GRAD=DATA1[,1], models=c("OU_linear"))
  intercept_beta <- as.numeric(RESULT[5,1])
  slope_beta <- as.numeric(RESULT[7,1])
  intercept_alpha <- as.numeric(RESULT[11,1])
  slope_alpha <- as.numeric(RESULT[12,1])
  parameters=c(intercept_beta, slope_beta, intercept_alpha, slope_alpha)

  ###Run the bootstrap
  RR <- bootstrap.test(DIST=DATA1[,3], TIME=DATA1[,2], 
     GRAD=DATA1[,1], model = "OU_linear", parameters, meserr1=0, meserr2=0, 
     N = c(100))
  summary <- RR$summary #to show only the summary. 
  bootstraps <- RR$bootstraps #to obtain the bootstraps
 
## End(Not run)#end dontrun

EvoRAG documentation built on May 2, 2019, 8:57 a.m.