[R] strucchange w dummy variables

Achim Zeileis Achim.Zeileis at uibk.ac.at
Mon Mar 10 19:36:55 CET 2014


On Mon, 10 Mar 2014, Geoffrey Smith wrote:

> Hello, I am having trouble with the output from the strucchange package for
> a dummy variable regression.  Why do I still get an intercept term in the
> output of lm03, below?
>
> library(lmtest)
> library(strucchange)
>
> data(GermanM1)
>
> #regular dummy regression with intercept
> lm01 <- lm(m ~ as.factor(season), data=GermanM1)
> coeftest(lm01)
>
> #regular dummy regression without intercept
> lm02 <- lm(m ~ as.factor(season) - 01, data=GermanM1)
> coeftest(lm02)
>
> #segmented regression for which I would like no intercept, yet the output
> includes an intercept, why?
> lm03 <- lm(m ~ breakfactor(breakpoints(m ~ as.factor(season) - 01,
> data=GermanM1)) / as.factor(season) - 01, data=GermanM1)
> coeftest(lm03)

This has nothing to do with strucchange. In general, regressions of type y 
~ f1/f2 behave like this. In y ~ f1/f2 you get the treatment contrasts of 
both f1 and f2. If you do y ~ f1/f2 - 1 then no treatment contrasts are 
applied for f1 but still for f2.

But strucchange provides dedicated tools to do what you want to do. You 
can simply use the coef() and coeftest() methods for "breakpoints" 
objects:

bp <- breakpoints(m ~ season - 1, data = GermanM1)
coef(bp)
coeftest(bp)

which should be what you are looking for.

> Thank you.
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list