Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cosinor analysis on iodine dispersion

    Hello stata users,

    I am trying to perform a cosinor analysis to determine the effect of season on iodine dispersion.
    Here is my code:
    Click image for larger version

Name:	stata.PNG
Views:	1
Size:	26.2 KB
ID:	1508083

    This code produces this graph:
    Click image for larger version

Name:	badstatagraph2.JPG
Views:	1
Size:	27.5 KB
ID:	1508084


    The problem is that I am trying to produce a graph similar to the one pictured here:
    Click image for larger version

Name:	goodstatagraphmodel.JPG
Views:	1
Size:	50.1 KB
ID:	1508085

    (plucked from https://www.statalist.org/forums/forum/general-stata-discussion/general/1223983-trigonometric-regression)

    but I cannot seem to get this code to produce a graph like this. Does anyone have any suggestions?


    Thank you for your time and help!!

  • #2
    As you have predictors other than the sine and cosine terms the predicted values from the regression won't be one-to-one functions of time. You are probably best advised to use margins and marginsplot to hold sex and age and GOR to selected values. Alternatively the part of the prediction equation that varies with time for all predictors being zero is just

    Code:
    _b[_cons] + _b[cos1] * cos1 + _b[sin1] * sin1 

    Comment


    • #3
      Hi Nick, Thank you so much for your response.

      I tried to remove the other predictors (sex, age, and GOR) from my model and run the graph, just to see what would happen, and it produced the same straight lines as before. Unfortunately, margins and marginsplot also did not work, as this requires a factor-variable with interaction term, which I do not need here. Could you elaborate on the prediction equation code you included above? Where does this go in the code?

      Comment


      • #4
        No example data here. If sine and cosine terms are functions of month then the results of

        Code:
        regress logi sin1 cos1
        predict whatever
        twoway connected whatever month
        should make sense. In practice I would use instead

        Code:
        twoway mspline whatever month, sort
        as twoway connected doesn't have any idea other than straight-line connections.

        If this doesn't help I think you will need to give a data example. Please see FAQ Advice #12

        The constants for the curve you've calculated are on quite different scales. I see no point in plotting them.

        Comment


        • #5
          Hi Nick,

          Again, thank you so much for your help! This works perfectly. I really appreciate the time you've taken!

          Comment

          Working...
          X