Hello. I am very new for STATA. So, please forgive me if my question is too basic. I am trying to run negative binomial regression with my monthly data (Jan 2018 -Dec 2022) to check if injury depends on sex and age-group (Here I simplified my dataset by removing some other variables). Trend of injury seems to be cyclical in graph. I have attached my data. So, i wanted to include sine and cosine terms into the model. I used the following code to create sine and cosine terms.
gen time = _n
gen period = 12
gen sine_term = sin(2 * _pi * time / period)
gen cosine_term = cos(2 * _pi * time / period)
After that I run nbreg to calculate incidence rate ratio.
nbreg Injury ib0.Age_group ib1.Sex sine_term cosine_term, dispersion(mean) exposure(Pop1) irr
I had following output:
----------------------------------------------------------------------------
Injury | IRR Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
1.Age_group | 1.229485 .0772512 3.29 0.001 1.087027 1.390612
2.Sex | .7773731 .0371441 -5.27 0.000 .707877 .8536921
sine_term | 1.001287 .0337199 0.04 0.970 .937331 1.069607
cosine_term | 1.077418 .0365459 2.20 0.028 1.008119 1.151482
_cons | .0004817 .0000297 -124.04 0.000 .0004269 .0005435
ln(Pop1) | 1 (exposure)
-------------+----------------------------------------------------------------
/lnalpha | -.5951414 .0483545 -.6899145 -.5003684
-------------+----------------------------------------------------------------
alpha | .5514846 .0266668 .5016189 .6063073
Sine term is insignificant here (But if I add another variables both cosine and sine became insignificant).
My question is:
Is it possible that sine and cosine to be insignificant when there is clear cyclical pattern?
Is my code correct (for sine and cosine)?
Thank you very much.
gen time = _n
gen period = 12
gen sine_term = sin(2 * _pi * time / period)
gen cosine_term = cos(2 * _pi * time / period)
After that I run nbreg to calculate incidence rate ratio.
nbreg Injury ib0.Age_group ib1.Sex sine_term cosine_term, dispersion(mean) exposure(Pop1) irr
I had following output:
----------------------------------------------------------------------------
Injury | IRR Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
1.Age_group | 1.229485 .0772512 3.29 0.001 1.087027 1.390612
2.Sex | .7773731 .0371441 -5.27 0.000 .707877 .8536921
sine_term | 1.001287 .0337199 0.04 0.970 .937331 1.069607
cosine_term | 1.077418 .0365459 2.20 0.028 1.008119 1.151482
_cons | .0004817 .0000297 -124.04 0.000 .0004269 .0005435
ln(Pop1) | 1 (exposure)
-------------+----------------------------------------------------------------
/lnalpha | -.5951414 .0483545 -.6899145 -.5003684
-------------+----------------------------------------------------------------
alpha | .5514846 .0266668 .5016189 .6063073
Sine term is insignificant here (But if I add another variables both cosine and sine became insignificant).
My question is:
Is it possible that sine and cosine to be insignificant when there is clear cyclical pattern?
Is my code correct (for sine and cosine)?
Thank you very much.
Comment