1

I would like to do a piecewise growth regression with my data, based on Raudenbush/Bryk(1992/2002), Hierarchical Linear Models, p178 - 179.

I will have to apply a Multi level Model to do this.

I is the lme4-package I will need to use.

My data contains sales revenues over time per ID. I have two breakpoints: sales>10 and sales>25. I want to analyse the growth in sales before and after the breakpoints.

I have two variables for every ID: var1: 123455555555 (when the salesrevenue exceeds 10 (breakpoint1), the variable stays constant) var2: 000000006789 (when the sales revenue exceeds 25(for breakpoint2), the variable is increasing, before 25 it is 0)

df = data.frame (
ID = c(1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2),
sales = c(1,4,10,12,20,26,28,2,5,9,12,13,18,26,29,35),
var1 = c(1,2,3,3,3,3,3,1,2,3,4,4,4,4,4,4),
var2 = c(0,0,0,0,0,1,2,0,0,0,0,0,0,1,2,3))

My Multi-Level Model has the form:

Y= b0i + b1i*a1ti + b2i*a2ti + eti

(sorry, I m not allow to post images and formulas :( )

a1ti and a2ti are my the coded variables (var1 and var2) which specify the pieces.

Level 1: repeated-observation for each individual level
Level 2: between-subjects level

Could maybe somebody explain me where I have to specify the Level 1 and Level 2 in my lmer()-Code and how I will get the two slopes of my two pieces? Do I have to add specifications between my brackets as O + ..., or 1 + ... to get only the intercept, etc.?

I guess my Code will look something like this:

test <- (lmer(sales ~ ID*var1 + (1|var1) + (1|ID), df))

or this:

test <- (lmer(sales ~ var1 + var2 + (1|var1) + (1|var2), df))

Thank you!

Best wishes Alexa

  • 1
    The `strucchange` and `segmented` packages are two efforts at providing segmented or piecewise regression. You should edit your question to provide R code that is more clear. The meaning of the apostrophes in those digits is unclear, as is the long string of digits which I'm guessing are meant to be vectors. – IRTFM Nov 30 '12 at 21:51
  • How about a simple regression augmented with dummy variables for structural breaks? Also, are you sure that your data is stationary? – chandler Dec 01 '12 at 11:08
  • Thanks a lot for your comment. I edited my post, and I hope it is now clear what I am looking for. I m working on Hierarchical Linear Growth Models, a Multi Level approach. So I will need to work with the lm4-package. – user1845101 Dec 04 '12 at 22:21
  • @DWin, if the OP needs to incorporate a random effect in the model then I think `strucchange` and `segmented` probably aren't going to do it. I think @chandler is on the right track, but the OP may not know how to translate the suggestion into a practical solution ... If I get a chance I will try to answer the question, if the edited version is clear to me when I look at it more carefully ... – Ben Bolker Dec 04 '12 at 22:28
  • Thank you! Hopefully you can follow my informations. – user1845101 Dec 04 '12 at 22:43
  • @BenBolker, I do not remember random or `lme` references being in the question at the time I posted my comment. – IRTFM Dec 04 '12 at 22:43
  • Maybe I can get even clearer with my question: I dont know which variables to take in my lmer-Code. (fixed effect vs. random effect, etc) In this post the orthography is explained pretty good but I still couldnt figure out how to apply it on my data. https://stat.ethz.ch/pipermail/r-sig-mixed-models/2012q4/019347.html – user1845101 Dec 05 '12 at 15:37

0 Answers0