estimateIntervals: Function to estimate temporal changes in isotopic values

Description Usage Arguments Value See Also Examples

View source: R/estimateIntervals.R

Description

Given renewal rates for different isotopic probes over time, a model estimates a normal distribution of the isotopic values for each time interval. Out of the given rates of renewal, first the influence of each time interval on the final isotopic value is calculated. This proportion is used as a regressor in a fully Bayesian linear model. The variance is estimated as rbf-Kernel-Matrix, where the hyperparameters are chosen such that the correlation between time intervals close to each other is about 0.5. The estimation is implemented using link[rstan]{rstan}.

Usage

1
2
3
4
5
estimateIntervals(renewalRates, timeVars, boneVars = NULL, isoMean,
  isoSigma, mu_df = 1, mu_mean = 0, mu_sd = 10, rho_mean = 1,
  rho_sd = 0.25, alpha_mean = 2, alpha_sd = 0.5, mc = TRUE,
  adapt_delta = 0.9999, max_treedepth = 25, chains = 4,
  iter = 2000, ...)

Arguments

renewalRates

A dataframe specifying the renewal rates of different probes for each time interval. The renewalRates should be between 0 and 100 (percentages). The dataframe should include a column specifying a time-index (e.g. 1, 2, 3, ...) as well as columns for the different bones. The renewal rates should contain the times of origin, containing 100.

timeVars

A character string specifying the name of the column indicating the time.

boneVars

A vector of character strings indicating the relevant variables containing the renewal rates of bones and teeth. If not given, the variables with bones are all variables of the dataframe apart from the time variables.

isoMean

A numeric number indicating the mean of the isotopic values measured.

isoSigma

A numeric, positive number indicating the standard deviation of the isotopic values measured.

mu_df

Hyperparameter for the mean of the interval estimates: degrees of freedom of a non-standardized t-Student distribution. Defaults to 1.

mu_mean

Hyperparameter for the mean of the interval estimates: mean of a non-standardized t-Student distribution. Defaults to 0.

mu_sd

Hyperparameter for the mean of the interval estimates: standard deviation of a non-standardized t-Student distribution. Defaults to 10.

rho_mean

Hyperparameter for the length scale of the rbf-kernel: mean of a normal. Defaults to 1.

rho_sd

Hyperparameter for the length scale of the rbf-kernel: standard deviation of a normal. Defaults to 0.25.

alpha_mean

Hyperparameter for the signal variance of the rbf-kernel: mean of a normal. Defaults to 2.

alpha_sd

Hyperparameter for the signal variance of the rbf-kernel: standard deviation of a normal. Defaults to 0.5.

mc

A boolean indicating if multiple cores should be used. If TRUE, which is the default, 4 cores are used.

adapt_delta

A numeric value between 0 and 1 controlling the samplers behavior. Defaults to 0.9999. See stan for more details.

max_treedepth

A numeric, positive value controling the NUTS sampler. Defaults to 25. See stan for more details.

chains

Number of chains for mcmc. Defaults to 4

iter

Number of iterations per chain for mcmc. Defaults to 2000

...

Arguments passed to rstand sampling

Value

A fitted object of class TemporalIso.

See Also

sampling

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
## Not run: 
data <- data.frame(
intStart = 0:5,
intEnd = 1:6,
bone1 = c(100, 50, 20, 10, 5, 2),
bone2 = c(100, 10, 5, 1, 1, 1),
tooth1 = c(0, 100, 0, 0, 0, 0),
tooth2 = c(0, 0, 100, 0, 0, 0)
)
y_mean <- c(-10, -7, -12, -9)
y_sigma <- c(2, 1.5, 2.5, 2.5)
fit <- estimateIntervals(renewalRates = data,
                         timeVars = "intStart",
                         boneVars = c("bone1", "bone2", "tooth1", "tooth2"),
                         isoMean = y_mean,
                         isoSigma = y_sigma)
print(fit)
plot(fit)
plotTime(fit)

# get estimates for specific time points
estimateTimePoint(fit, time = seq(0,5, by = 0.5))

# shift point estimation
plotTime(fit, plotShifts = TRUE, threshold = 0.5)
getShiftTime(fit, threshold = 0.5)

#Staying time estimation
estimatedStayTimes <- getSiteStayTimes(object = fit,
siteMeans = c(-8, -10),
siteSigma = c(1, 1.5))

## End(Not run)

OsteoBioR documentation built on May 1, 2019, 10:18 p.m.