Announcement

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

  • Creating a spline

    Hi Statalist users,

    I would like to create a spline variable of year so that I can look at the period between 2001 and 2008; 2009; 2010 - 2016. I've tried using the mkspline command, which successfully creates the spline variables but when I enter them all in at once, one is left out due to collinearity so I fear I may be creating them wrong. The command i am using is this:

    mkspline year1 2001 year2 2008 year3 2008 year4 2009 year5 2016 year6 = year, marginal

    I am using it for an OLS regression on full-time employment:

    Code:
    * Example generated by -dataex-. To install:    ssc    install    dataex
    clear
    input byte activity_gendered1 int year
    1 2012
    0 2006
    1 2002
    0 2016
    0 2014
    1 2013
    1 2008
    1 2010
    1 2016
    1 2016
    1 2002
    0 2010
    1 2010
    0 2011
    0 2010
    1 2014
    1 2016
    0 2001
    1 2016
    1 2009
    1 2004
    1 2016
    1 2001
    1 2012
    1 2015
    1 2015
    1 2011
    1 2005
    0 2001
    1 2013
    1 2001
    1 2014
    1 2009
    1 2002
    1 2013
    1 2016
    1 2015
    0 2013
    1 2011
    1 2006
    1 2005
    0 2012
    1 2016
    1 2013
    0 2001
    0 2006
    1 2015
    1 2011
    0 2004
    1 2007
    1 2008
    1 2016
    1 2012
    0 2013
    0 2013
    1 2012
    1 2010
    1 2007
    1 2014
    1 2004
    1 2009
    0 2014
    1 2009
    0 2013
    1 2013
    1 2010
    1 2015
    1 2013
    1 2006
    0 2009
    1 2006
    1 2011
    1 2005
    1 2008
    1 2001
    0 2014
    0 2011
    1 2009
    0 2014
    1 2008
    0 2005
    0 2014
    0 2010
    1 2004
    1 2007
    0 2016
    1 2003
    1 2013
    0 2002
    1 2005
    1 2009
    1 2011
    1 2013
    1 2004
    1 2005
    1 2001
    0 2007
    0 2013
    0 2013
    1 2016
    end




  • #2
    First, you created two variables both for margins after 2008. Then you also included joinpoints for 2001, which is the minimum value of year, and 2016 which is the maximum value of year. Those are not what you want and all of them contribute to the colinearity. Also, you did not include one for 2010 (which is not a problem from a colinearity perspective, but you did say you wanted a joinpoint there). What you want here is just

    [/code]
    mkspline year1 2008 year2 2009 year3 2010 year4 = year, marginal
    [/code]

    This will give you joinpoints at 2008, 2009, and 2010 and will not cause you a colinearity problem.

    Comment

    Working...
    X