#Construcción de la Base de Datos
y = c(35, 63, 103, 121.8, 163.8, 373.0)
x1 = c(0, 4, 10, 10.72, 16, 21)
x2 = c(13, 9, 20, 10, 17, 19)
datos=data.frame(y,x1,x2)
pairs(ChickWeight)# diagramas de dispersion
summary(ChickWeight)
## weight Time Chick Diet
## Min. : 35.0 Min. : 0.00 13 : 12 1:220
## 1st Qu.: 63.0 1st Qu.: 4.00 9 : 12 2:120
## Median :103.0 Median :10.00 20 : 12 3:120
## Mean :121.8 Mean :10.72 10 : 12 4:118
## 3rd Qu.:163.8 3rd Qu.:16.00 17 : 12
## Max. :373.0 Max. :21.00 19 : 12
## (Other):506
#Acabo de realizar un resumen descriptivo de mi base de datos y encuentro que la media es de
cor(datos) # Correlacion
## y x1 x2
## y 1.0000000 0.9051452 0.5519687
## x1 0.9051452 1.0000000 0.6088234
## x2 0.5519687 0.6088234 1.0000000
## y x1 x2
modelo=lm(y~x1)
summary(modelo)
##
## Call:
## lm(formula = y ~ x1)
##
## Residuals:
## 1 2 3 4 5 6
## 39.142 9.822 -36.159 -27.676 -61.339 76.210
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -4.142 41.848 -0.099 0.9259
## x1 14.330 3.365 4.258 0.0131 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 57.6 on 4 degrees of freedom
## Multiple R-squared: 0.8193, Adjusted R-squared: 0.7741
## F-statistic: 18.13 on 1 and 4 DF, p-value: 0.01307
##
## Call:
## lm(formula = y ~ x1)
par(mfrow=c(1,1))
plot(x1,y, type="p", xlim=c(0,200), ylim=c(0,1000))
abline(lm(y~x1), col="blue", v=mean(x1), h=mean(y))
confint(modelo, level=0.90)
## 5 % 95 %
## (Intercept) -93.355395 85.07116
## x1 7.156267 21.50390