0
$\begingroup$

How should I define a model formula in "R", when one (or more) exact linear restrictions binding the coefficients is available.

Equation: y = b1*x1 + b2*x1

where y = b1*x1 for t < t1 and y = b2*x1 for t > t1

Thank You..!

$\endgroup$
1
$\begingroup$

Avoiding difficult formulas may be the simplest: just create two new vectors:

x2 <- ifelse(t<t1, x1, 0)
x3 <- ifelse(t<t1, 0, x1)

Now you can simply fit y ~ x2 + x3 -1 (I'm using R formula notation here).

Different solutions are possible (this comes down to a different dummy coding scheme). The best may depend on the correctness of the matching assumptions, and of course on your goals for the research.

$\endgroup$
2
  • $\begingroup$ I edited your LaTeX to code-format (LaTeX mathematics, among other things, insists on making " <- " into "< -", which is quite a different thing in R). If you want to change it back, you should be able to revert without making the individual changes. $\endgroup$ – Glen_b Mar 29 '13 at 15:14
  • $\begingroup$ Much obliged. I'm swapping technologies a lot lately, so obfuscation tends to happen :) $\endgroup$ – Nick Sabbe Mar 29 '13 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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