Cviko v R - polynomialne lm
Created: 2012-04-30 - 12:14
utils:::menuInstallPkgs()
utils:::menuInstallPkgs()
y= c(2.717,2.708,2.684,2.683,2.822,2.800)
x = c(4.6,4.6,4.9,4.9,5.2,5.2)
x
y
plot(x,y)
plot(y~x)
v1 = lm (y ~ 1 + x + I(x^2))
v1
summary(v1)
?I
#I berie objekty tak ako su
v1 = lm (y ~ 1 + x + I(x^2) + I(x^3))
summary(v1)
x = c(4.6,4.6,4.9,4.9,5.2,5.2,5.3)
y= c(2.717,2.708,2.684,2.683,2.822,2.800,3)
v1 = lm (y ~ 1 + x + I(x^2) + I(x^3))
summary(v1)
y= c(2.717,2.708,2.684,2.683,2.822,2.800,2.800)
v1 = lm (y ~ 1 + x + I(x^2) + I(x^3))
summary(v1)
ploty(x,y)
plot(x,y)
lines(x,v1)
lines(v1)
lines(v1 ~ y)
v1
a0 = v1$coefficients[0]
a1 = v1$coefficients[1]
a2 = v1$coefficients[2]
a0
a1
a2
a0 = v1$coefficients[1]
a1 = v1$coefficients[2]
a2 = v1$coefficients[3]
a3 = v1$coefficients[4]
h = seq(from=4.6, to=5.3,by=0.1)
vysl = a0 + a1*(h) + a2*(h^2) + a3*I(h^3)
lines(h,vysl)
h = seq(from=4.6, to=5.3,by=0.001)
vysl = a0 + a1*(h) + a2*(h^2) + a3*I(h^3)
lines(h,vysl)
lines(h,vysl, col='red')
history(1000)