Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

I am current using the package (lme4) for a mixed effect model with random effects.

My model takes the form:

mod <- lmer(response ~ b1(predict1, bp) + b2(predict2, bp) + (1 | site), data = data)

The functions b1 and b2 come from the helpful advice in:

Estimating the break point in a broken stick / piecewise linear model with random effects in R [code and output included]

b1 <- function(x, bp) ifelse(x < bp, bp - x, 0)
b2 <- function(x, bp) ifelse(x < bp, 0, x - bp)

I am wondering, how would I set up my model so that the second part (line) of the broken stick model has a constant gradient?

So for example, I would like something like:

If X < breakpoint, Y = m1X + C1

If X > breakpoint, Y = C2

Hope I am making sense.

Matt.

share|improve this question

1 Answer

I may have found a solution to my problem, but could someone please confirm what I've done?

I slightly modified the above functions b1 and b2. I have called them b3 and b4:

b3 <- function(x, bp) ifelse(x < bp, bp - x, 0)   #Y = mx + c
b4 <- function(x, bp) ifelse(x < bp, 0, 1)        #Y = C

The mixed model is similar, but b3 and b4 are used:

mod2 <- lmer(SIGNAL ~ b3(dci, bp) + b4(dci,bp) + (1 | gauge), data = cand_bug_data)
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.