[R] Segmented regression
vmuggeo at dssm.unipa.it
Thu Dec 6 10:54:36 CET 2007
I am not sure to understand your code..
It seems to me that your are interested in fitting a one-breakpoint
segmented relationship in each level of your grouping variable
If this is the case, the correct code is below.
In order to fit a segmented relationship in each group you have to
define the relevant variable before fitting, and to constrain the last
slope to be zero you have to consider the `minus' variable..(I discuss
these points in the submitted Rnews article..If you are interested, let
me know off list).
If my code does not fix your problem, please let me know,
##--define the group-specific segmented variable:
##-fit the unconstrained model
#have a look to results:
#constrain the last slope in group KW
Power, Brendan D (Toowoomba) ha scritto:
> Hello all,
> I have 3 time series (tt) that I've fitted segmented regression models
> to, with 3 breakpoints that are common to all, using code below
> (requires segmented package). However I wish to specifiy a zero
> coefficient, a priori, for the last segment of the KW series (green)
> only. Is this possible to do with segmented? If not, could someone point
> in a direction?
> The final goal is to compare breakpoint sets for differences from those
> derived from other data.
> Thanks in advance,
> init.bp <- c(297.4,639.6,680.6)
> lm.1 <- lm(y~tt+group,data=df)
> seg.1 <- segmented(lm.1, seg.Z=~tt, psi=list(tt=init.bp))
> platform i386-pc-mingw32
> arch i386
> os mingw32
> system i386, mingw32
> major 2
> minor 6.0
> year 2007
> month 10
> day 03
> svn rev 43063
> language R
> version.string R version 2.6.0 (2007-10-03)
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Vito M.R. Muggeo
Dip.to Sc Statist e Matem `Vianelli'
Università di Palermo
viale delle Scienze, edificio 13
90128 Palermo - ITALY
tel: 091 6626240
fax: 091 485726/485612
More information about the R-help