X=c(- 0.000000446,0.000006498,0.00001344,0.00002039,0.00002733,0.00003427,0.00004122,0.00004816,0.00005511,0.00006205,0.000069,0.0000836,0.00009821,0.0001128,0.0001274,0.000142,0.0001566,0.0001713,0.0001859,0.0002005,0.0002151,0.0002297,0.0002443,0.0002589,0.0002735,0.0002881,0.0003027,0.0003173,0.000332,0.0003466,0.0003612,0.0003758,0.0003904,0.000405,0.0004196,0.0004342,0.0004488,0.0004634,0.000478,0.0004926,0.0005073,0.0005219,0.0005365,0.0005511,0.0005657,0.0005803,0.0005949,0.0006095,0.0006241,0.0006387,0.0006533,0.000668,0.0006826,0.0006972,0.0007118,0.0007264,0.000741,0.0007556,0.0007664)
Y=c(0,61820,73630,83830,93720,103600,109000,112700,116100,119500,120900,122100,123300,124300,125300,126600,127800,129000,130100,131200,132300,133300,134200,135200,136100,136900,137800,138600,139400,140100,140900,141500,142200,142800,143500,144000,144600,145100,145600,146100,146600,147000,147400,147800,148200,148500,148800,149100,149300,149600,149800,149800,149900,149800,149700,149300,148500,148000,147600)
plot(X,Y)
linear1=lm(Y~X)
linear2=segmented(linear1,seg.Z=~X, psi = 0.0005,data=d)
plot(linear2)
points(X,Y)
slope(linear2)
我要做的是获得此处给出的曲线的双线性表示。首先,我想询问是否有比我的代码更好的方法?第二个也是重要的是我不知道什么函数或命令显示线的交点和每条线的方程。所以问题是如何从这个分段命令中得到线方程。
答案 0 :(得分:2)
是不清楚曲线的bilinear
表示是什么意思。要获得线方程式,您可以使用intercept
和slope
,如下所示:
intercept(linear2)
$X
Est.
intercept1 22730
intercept2 119200
> slope(linear2)
$X
Est. St.Err. t value CI(95%).l CI(95%).u
slope1 2.938e+09 288100000 10.20 2.360e+09 3.515e+09
slope2 4.872e+07 3840000 12.69 4.103e+07 5.642e+07
答案 1 :(得分:0)
这是一个老问题,但是我在寻找使用分段的信息时,我自己也在四处寻找,因为我觉得我理解你所要求的,可以提供一个快速的答案。两条曲线相遇的'x'值是断点。使用您的示例:
linear2
调用:segmented.lm(obj = linear1,seg.Z = ~X,psi = 5e-04,data = d)
线性项的有意义系数:
(拦截)X U1.X
2.997e + 04 2.212e + 09 -2.167e + 09
估计断点psi1.X:4.215e-05
为您的模型设置的线性方程式为:
当p <=断点时,y = slope1 * x + intercept1 当p> 0时,
y = slope2 * x + intercept2;断点