accrual_linear_model {accrualPlot} | R Documentation |
accrual_linear_model
Description
Creates a weighted linear regression model using an accrual data frame produced by accrual_create_df
.
Usage
accrual_linear_model(
accrual_df,
fill_up = TRUE,
wfun = function(x) seq(1/nrow(x), 1, by = 1/nrow(x))
)
Arguments
accrual_df |
object of class 'accrual_df' or 'accrual_list' produced by |
fill_up |
whether to fill up days where no recruitment was observed, |
wfun |
function to calculate the weights with accrual data frame as argument, default is wfun<-function(x) seq(1 / nrow(x), 1, by = 1/nrow(x)). |
Value
Returns an object of class 'lm' with a weighted linear regression of cumulative accrual on dates.
Examples
data(accrualdemo)
accrual_df<-accrual_create_df(accrualdemo$date)
accrual_linear_model(accrual_df)
#unweighted
accrual_linear_model(accrual_df, wfun=function(x) rep(1,nrow(x)))
#different start and current date
accrual_df<-accrual_create_df(accrualdemo$date,start_date=as.Date("2020-07-08"),
current_date=as.Date("2020-07-15"))
accrual_linear_model(accrual_df)
#accrual_df with by option
accrual_df<-accrual_create_df(accrualdemo$date,by=accrualdemo$site)
accrual_linear_model(accrual_df)
[Package accrualPlot version 1.0.7 Index]