Announcement

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

  • Penalized spline models with -mixed-

    Greetings, all.

    I recently ran across a StataCorp presentation by Roberto Gutierrez that discussed using -xtmixed- to obtain penalized spline estimates (https://www.stata.com/meeting/uk08/gutierrez_mixed.pdf, slides 27 et seq). I am interested in updating this approach to use -mixed-, and to incorporate on multiple subjects per time point (I have states and years in this case, with the outcome being a score for each state/year combination).

    I haven't had much luck beyond fitting the basic crossed effects model : mixed outcome || _all: R.state || all: R.year, which of course is treating years as factors and not providing a smoothed slope.

    Curious to hear if anyone else has tried this and might have some advice.

    Thanks!



  • #2
    Hi, everyone. Pleased to report I have this running in mixed as a multi-level model that adapts the original data and code:
    Code:
    use "http://www.stata-press.com/data/r13/motorcycle.dta", clear
    bys time: gen id=_n // set up an ID to simulate multilevel data. There are multiple measurements for some time points
    
    local i 1
    forvalues k = 1(1)60 {
    gen time_`i' = cond(time - `k' > 0, time - `k', 0)
    local ++i
    }
    
    mixed accel time || _all: R.id || _all: time_*, noconstant cov(identity)
    predict p, fitted
    However, I am not tracking how the time_* variables function in this model. If anyone is able to share some intuition on that point, I would appreciate it. Thanks!

    Comment

    Working...
    X