# Unable to show cointegration between two lagged sine waves with statsmodels cointegration function, why?

When using the statstools cointegration function to test for cointegration with default parameters between two sine waves with a 1 period lag, coint() returns that there is no cointegration. Running a manual ADF test on residuals of the two waves shows that of course there is.

import statsmodels.tsa.stattools as ts
import statsmodels.api as sm

sin = pd.DataFrame(pd.Series([np.sin(x) for x in np.arange(0,50,0.1)]).rename('sin1'))
sin['sin2'] = sin['sin1'].shift(1)
sin['resid'] = sin['sin1'] - sin['sin2']
sin = sin.dropna()

def cointegration_test(y, x):
ols_result = sm.OLS(y, x).fit()

# No cointegration found
ts.coint(sin['sin1'], sin['sin2'])
#(-0.0012969, 0.9858, array([-3.91856695, -3.34842679, -3.05297743]))

#Cointegration found
cointegration_test(sin['sin1'],sin['sin2'])
#(-388.12, 0.0, 1, 497, {'1%': -3.443,  '5%': -2.86,  '10%': -2.56}, -30440.043)


I believe this is down to the underlying lag logic in coint(), setting maxlag=1 does enable coint() to find cointegration however maxlag=2 and it reverts to finding nothing.

Is this behaviour correct? And if so what is the correct way of parameterising coint() such that it returns the result I expect (The two waves are cointegrated)?

Two sine waves cannot be cointegrated because a sine wave is not an integrated process; a sine wave does not have a unit root. Only integrated processes can be cointegrated. Therefore, the fact that the Dickey-Fuller test rejects a unit root in the residuals of a regression of $$Y$$ (e.g. sine wave number 1) on $$X$$ (e.g. sine wave number 2) does not automatically mean $$Y$$ and $$X$$ are cointegrated. I do not know how the different Python functions work, but I suppose that if you supply non-integrated series where integrated ones are expected and this problem is not checked internally in the function, the function may falsely conclude there is cointegration.