lm_parms {QurvE} | R Documentation |
Helper functions for handling linear fits.
Description
lm_window
performs a linear regression with the Theil-Sen estimator on a subset of data.
Usage
lm_parms(m)
lm_window(x, y, i0, h = 5)
Arguments
m |
linear model ( |
x |
vector of independent variable (e.g. time). |
y |
vector of dependent variable (concentration of organisms). |
i0 |
index of first value used for a window. |
h |
with of the window (number of data). |
Value
linear model object of class lm
(lm_window)
resp. vector with parameters of the fit (lm_parms).
References
Hall, B. G., H. Acar and M. Barlow 2013. Growth Rates Made Easy. Mol. Biol. Evol. 31: 232-238 doi:10.1093/molbev/mst197
Examples
# Create random growth dataset
rnd.dataset <- rdm.data(d = 35, mu = 0.8, A = 5, label = "Test1")
# Extract time and growth data for single sample
time <- rnd.dataset$time[1,]
data <- as.numeric(rnd.dataset$data[1,-(1:3)]) # Remove identifier columns
data.log <- log(data/data[1])
# Perform linear fit on 8th window of size 8
linreg <- lm_window(time, data.log, 8, h=8)
summary(linreg)
lm_parms(linreg)
[Package QurvE version 1.1.1 Index]