我需要一个r中的脚本来拟合这个数据吗?

时间:2014-02-03 21:08:15

标签: r

我需要你的帮助,我想对这些数据进行曲线拟合,我在r中无法做到,行为就像你看到的那样,我会很感激任何能够帮助我们编写脚本的人图片http://subefotos.com/ver/?db13ac6b32e49b58166a4776af7fbf19o.jpg

0.1 840.31
10.1    453.28
20.1    149.24
30.1    70.09
40.1    36.30
50.1    75.39
60.1    106.90
70.1    114.37
80.1    176.00
90.1    127.59
100.1   135.46
110.1   160.78
120.1   192.03
130.1   237.78
140.1   240.29
150.1   249.72
160.1   202.19
170.1   197.31
180.1   230.31
190.1   220.82
200.1   269.37
210.1   241.16
220.1   264.44
230.1   270.64
240.1   258.10
250.1   231.00
260.1   279.05
270.1   295.91
280.1   378.09
290.1   370.97
300.1   355.54
310.1   378.67
320.1   360.45
330.1   470.40
340.1   469.11
350.1   374.42
360.1   545.41
370.1   427.27
380.1   430.35
390.1   356.31
400.1   444.99
410.1   388.19
420.1   534.55
430.1   456.40
440.1   435.48
450.1   511.14
460.1   484.70
470.1   532.63
480.1   549.11
490.1   607.22

2 个答案:

答案 0 :(得分:3)

从视觉上看,10度多项式似乎运行得相当好。你也可以尝试其他学位。 (DF在最后给出):

plot(y ~ x, DF, pch = 20)
fm <- lm(y ~ poly(x, 10), DF)
lines(fitted(fm) ~ DF$x, col = "red")

enter image description here

以下是DF

DF <- 
structure(list(x = c(0.1, 10.1, 20.1, 30.1, 40.1, 50.1, 60.1, 
70.1, 80.1, 90.1, 100.1, 110.1, 120.1, 130.1, 140.1, 150.1, 160.1, 
170.1, 180.1, 190.1, 200.1, 210.1, 220.1, 230.1, 240.1, 250.1, 
260.1, 270.1, 280.1, 290.1, 300.1, 310.1, 320.1, 330.1, 340.1, 
350.1, 360.1, 370.1, 380.1, 390.1, 400.1, 410.1, 420.1, 430.1, 
440.1, 450.1, 460.1, 470.1, 480.1, 490.1), y = c(840.31, 453.28, 
149.24, 70.09, 36.3, 75.39, 106.9, 114.37, 176, 127.59, 135.46, 
160.78, 192.03, 237.78, 240.29, 249.72, 202.19, 197.31, 230.31, 
220.82, 269.37, 241.16, 264.44, 270.64, 258.1, 231, 279.05, 295.91, 
378.09, 370.97, 355.54, 378.67, 360.45, 470.4, 469.11, 374.42, 
545.41, 427.27, 430.35, 356.31, 444.99, 388.19, 534.55, 456.4, 
435.48, 511.14, 484.7, 532.63, 549.11, 607.22)), .Names = c("x", 
"y"), row.names = c(NA, -50L), class = "data.frame")

答案 1 :(得分:2)

您的示例图片不适合数据。这只是一个线图。您可以使用plot(X-values,Y-values,type="o")

创建此类图表