R/calc_regres_coef_b.R

Defines functions calc_regres_coef_b

# calculate coefficient b of linear regression model
calc_regres_coef_b <- function(y)
{
  time_count <- seq_along(y)
  ones <- seq(1,1,length=length(y))

  content.matrix <- c(ones, time_count)
  X <- matrix(content.matrix, byrow = FALSE, ncol = 2)

  suppressWarnings({
  fm <- stats::lsfit(x = X, y = y, intercept = FALSE)
  data.b <- fm$coef[[2]]
  })
  
  return(data.b)
}

Try the cmsafops package in your browser

Any scripts or data that you put into this service are public.

cmsafops documentation built on Sept. 18, 2023, 5:16 p.m.