可以查看segmented包求拐点的例子。
R中运行:
library(segmented)
?segmented
。。。。。。
#An example using the default method:
# Cox regression with a segmented relationship
## Not run:
library(survival)
data(stanford2)
o<-coxph(Surv(time, status)~age, data=stanford2)
os<-segmented(o, ~age, psi=40) #estimate the breakpoint in the age effect
summary(os) #actually it means summary.coxph(os)
plot(os) #it does not work
plot.segmented(os) #call explicitly plot.segmented() to plot the fitted piecewise lines
如图,拐点已求出。
y'=1+5x^4/3>0,因此函数在R上单调增y"=20x^3/3=0,得:x=0,所以拐点为(0,0)
x>0时,为凹区间
x<0时,为凸区间
这个函数是用于求多项式求根的。polyroot翻译过来的意思是多项式系数递增的向量,这个函数是r语言中常用函数之一,是属于数学函数中的多项式求根。
r语言是一套完整的数据处理,计算和制图软件系统,功能包括有数据存储和处理系统,数组运算工具,完整连贯的统计分析工具,在向量,矩阵运算方面功能尤其强大。