#ZAD3
dane = read.csv2("test_regresji.csv")
attach(dane)
plot(x,y)
reg4 = nls(y~a*x^2+b*x+d, start=list(a=0, b=0, d=0))
summary(reg4)
ndane = data.frame(x = seq(min(x), max(x), length = 300))
lines(ndane$x, predict(reg4, ndane), lwd = 2, col = "red")
detach(dane)
#ZAD4
dane = read.csv2("test_regresji.csv")
attach(dane)
reg8 = loess(y~x)
summary(reg8)
plot(x, y)
ndane = data.frame(x = seq(min(x), max(x), length = 300))
lines(ndane$x, predict(reg8, ndane), lwd = 2, col = "green")
lines(ndane$x, predict(loess(y~x, span = 0.4, degree = 2), ndane), lwd = 2, col = "blue")
lines(ndane$x, predict(loess(y~x, span = 0.8, degree = 1), ndane), lwd = 2, col = "violet")
detach(dane)
#Zad5
dane = read.csv2("test_regresji.csv")
attach(dane)
reg9 = smooth.spline(x, y)
print(reg9)
plot(x, y)
lines(predict(reg9, x = seq(min(x), max(x), length = 400)), lwd = 2, col = "red")
reg10 = smooth.spline(x, y, spar = 0)
lines(predict(reg10, x = seq(min(x), max(x), length = 400)), lwd = 2, col = "blue")
print(reg10)
reg11 = smooth.spline(x, y, spar = 1)
lines(predict(reg11, x = seq(min(x), max(x), length = 400)), lwd = 2, col = "brown")
#praktycznie to samo, co regresja liniowa
print(reg11)
detach(dane)
Wyszukiwarka
Podobne podstrony:
Zadania 7bAnaliza Matematyczna 2 ZadaniaZARZĄDZANIE FINANSAMI cwiczenia zadania rozwiazaneEZADANIE (11)zadanie domowe zestawZadania 1W 4 zadanie wartswa 2013Sprawdzian 5 kl 2 matematyka zadaniazadania1Zadania 2015 9Logika W8 zadaniaLogika troch teorii zadania06 Zadania z rozwiązaniamiidd47więcej podobnych podstron