# What value to put in lm() function when testing for cointegration (R)

I'm a CS student working on a financial computing project + have a question regarding cointegration testing using linear regression with the lm() function.

Data:

I've seen many examples through different strategies/notes online and was wondering which is the correct one to use under certain scenarios ( +0, +1, or nothing)

eg:

  m <- lm(series[[9]] ~ series[[1]] + 0)
beta <- m$$coefficients[1] cat ("Assumed hedge ratio is ", beta, "\n") sprd <- series[[9]] - beta * series[[1]] adf.test(sprd, alternative = 'stationary', k=0)$$p.value #0.6647128

m <- lm(series[[9]] ~ series[[1]] + 1)
beta <- m$$coefficients[1] cat ("Assumed hedge ratio is ", beta, "\n") sprd <- series[[9]] - beta * series[[1]] adf.test(sprd, alternative = 'stationary', k=0)$$p.value #0.5656023

model <- lm(series[[9]] ~ series[[1]])
b <- model$$coefficients[2] spreadp1 <- series[[9]] - b*series[[1]] adf.test(spreadp1, k=0)$$p.value # 0.4339312