Thanks! that worked.

I also tested with the below method although your solution is faster
and done in fewer steps.

  inter <- intercept(segmented.mod)
  inter.m <- as.matrix(inter$x)
  inter.row <- nrow(inter.m)
  answer <- inter.m[inter.row,1]

PD

On Tue, Jul 5, 2016 at 2:28 PM,  <ruipbarra...@sapo.pt> wrote:
> Hello,
>
> Try
>
> dimnames(inter$x)[[1]]
>
> You could have seen this by inspecting 'inter':
>
> str(inter)
>
> Hope this helps,
>
> Rui Barradas
>
>
> Citando Narendra Modi <bjpmodi2...@gmail.com>:
>
> I am able to perform regression on a dataset as below:
>
> plot(x,y)
> lin.mod <- lm(y~x)
> m <- mean(x)
> m
>
> segmented.mod <- segmented(lin.mod, seg.Z = ~x, psi= m)
>
> plot(segmented.mod, add=T)
> sl <- slope(segmented.mod)
> inter <- intercept(segmented.mod)
>
> summary(segmented.mod)    # Show Summary
> sl                        # show all the slopes
> inter                     # show all the intercepts
>
>
> In my dataset, the above method correctly identifies the breakpoints and
> hence I get two intercepts.
>
> inter
>
> $x
>              Est.
> intercept1  -3.269
> intercept2 -19.980
>
> What I am interested is the "intercept2" value. How can I obtain this?
>
> The method needs to be dynamic as in if the next dataset has 3 intercepts,
> I would like to get "intercept3 value.
>
> PD
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.htmland provide commented, minimal,
> self-contained, reproducible code.
>
>
>

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to