segmented: Regression Models with Breakpoints/Changepoints Estimation

> library(segmented)

バージョン: 0.5.1.2


関数名 概略
broken.line Fitted values for segmented relationships
confint.segmented Confidence intervals for breakpoints
davies.test Testing for a change in the slope
down Down syndrome in babies
draw.history History for the breakpoint estimates
intercept Intercept estimates from segmented relationships
lines.segmented Bars for interval estimate of the breakpoints
plant Plan organ dataset
plot.segmented Plot method for segmented objects
points.segmented Points method for segmented objects
predict.segmented Predict method for segmented model fits
print.segmented Print method for the segmented class
seg.control Auxiliary for controlling segmented model fitting
seg.lm.fit Fitter Functions for Segmented Linear Models
segmented Segmented relationships in regression models
segmented-package Segmented relationships in regression models with breakpoints/changepoints estimation
slope Slope estimates from segmented relationships
stagnant Stagnant band height data
summary.segmented Summarizing model fits for segmented regression
vcov.segmented Variance-Covariance Matrix for a Fitted Segmented Model

broken.line

> set.seed(1234)
> z<-runif(100)
> y<-rpois(100,exp(2+1.8*pmax(z-.6,0)))
> o<-glm(y~z,family=poisson)
> o.seg<-segmented(o,seg.Z=~z,psi=.5)
> plot(z,y)
> points(z,broken.line(o.seg,link=FALSE)$fit,col=2,pch=20)

confint.segmented

信頼区間の算出

davies.test

segmented

Arguments

  • obj
  • seg.z
  • psi
  • control
  • model
  • ...
> set.seed(12)
> xx <- 1:100
> zz <- runif(100)
> yy <- 2 + 1.5 * pmax(xx - 35, 0) - 1.5 * pmax(xx - 70, 0) + 15 * pmax(zz - .5, 0) + rnorm(100, 0, 2)
> dati <- data.frame(x = xx, y = yy , z = zz)
> out.lm <- lm(y ~ x, data = dati)
> o <- segmented(out.lm, 
+                seg.Z = ~x, 
+                psi = list(x = c(30, 60)),
+                control = seg.control(display = FALSE))
> slope(o)
$x
           Est. St.Err. t value CI(95%).l CI(95%).u
slope1 -0.05899 0.06210 -0.9499   -0.1823 0.0643200
slope2  1.41500 0.04615 30.6500    1.3230 1.5060000
slope3 -0.14280 0.07199 -1.9830   -0.2857 0.0001473
> # dat2 <- data.frame(x = xx, y = broken.line(o)$fit)
> # library(ggplot2)
> # ggplot(dati, aes(x = x, y = y)) +
> #   geom_point() +
> #   geom_line(data = dat2, color = 'blue')