Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Regresión lineal múltiple

> #TRABAJO FINAL BIOMASA


> Biomasa.data <- read.table(file = "D:/BIOMASA.txt", header = T)
> Biomasa.data
BIOMASA DAP ALTURA.TOTAL
1 243.06 26.42 18.50
2 151.99 19.89 15.50
3 319.81 29.19 21.25
4 323.08 26.83 22.25
5 389.35 25.62 21.25
6 356.67 25.46 20.50
7 326.61 28.65 18.50
8 116.51 23.87 19.50
9 200.91 21.33 14.00
10 205.57 18.78 15.25
11 136.86 18.14 15.75
12 185.23 21.04 14.00
13 257.26 24.19 18.25
14 305.48 28.81 21.00
15 177.20 18.84 16.00
16 99.93 16.71 15.00
17 245.43 23.62 20.00
18 297.12 24.92 22.00
19 247.06 23.55 20.75
20 153.94 20.69 15.50
21 352.70 28.65 21.75
22 206.96 28.33 15.75
23 172.93 20.69 19.50
24 267.11 26.58 20.75
25 184.96 23.24 16.50
26 625.18 36.76 21.50
27 593.40 34.06 24.50
28 276.51 25.46 17.50
29 171.75 23.71 14.00
30 478.29 17.83 23.75
31 294.90 23.87 21.00
32 214.07 23.40 19.75
33 355.11 25.46 22.50
34 307.99 23.71 19.75
35 150.38 20.85 17.50
36 157.06 20.37 17.50
37 220.94 23.08 17.25
38 378.58 28.97 20.50
39 140.77 22.85 18.75
40 144.70 17.51 20.00
> attach(Biomasa.data)#ejecuta una sola vez

> X1 <- DAP

> X2 <- ALTURA.TOTAL

> Y <- BIOMASA

> plot((Biomasa.data),main = "Diagrama de dispersión", col="green", lwd=1)


> regresión <- lm(Y ~ X1 + X2)

> regresión

Call:

lm(formula = Y ~ X1 + X2)

Coefficients:

(Intercept) X1 X2

-435.95 13.47 19.76

Biomasa (Kg) = 13.47DAP(cm)+19.76ALTURA.TOTAL(m)-435.95

>summary(regresión)

Call:

lm(formula = Y ~ X1 + X2)

Residuals:

Min 1Q Median 3Q Max

-154.397 -42.885 4.207 26.356 204.755

Coefficients:

Estimate Std. Error t value Pr(>|t|)

(Intercept) -435.951 76.852 -5.673 1.74e-06 ***

X1 13.470 2.895 4.653 4.10e-05 ***

X2 19.761 4.476 4.415 8.46e-05 ***

---

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 66.71 on 37 degrees of freedom

Multiple R-squared: 0.701, Adjusted R-squared: 0.6848

F-statistic: 43.37 on 2 and 37 DF, p-value: 1.995e-10

> anova(regresión)

Analysis of Variance Table

Response: Y

Df Sum Sq Mean Sq F value Pr(>F)


X1 1 299271 299271 67.255 7.605e-10 ***

X2 1 86720 86720 19.489 8.459e-05 ***

Residuals 37 164642 4450

---

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

#SUPESTOS

#NORMALIDAD

package ‘nortest’ successfully unpacked and MD5 sums checked

library(nortest)

lillie.test(residuals(regresión))

Lilliefors (Kolmogorov-Smirnov) normality test

data: residuals(regresión)

D = 0.1087, p-value = 0.2741

#Prueba de igualdad de varianzas

library(car)

library(lmtest)

ncvTest(regresión)

bptest(regresión)

Non-constant Variance Score Test

Variance formula: ~ fitted.values

Chisquare = 2.535095, Df = 1, p = 0.11134

#Independencia

dwtest(regresión)

#coeficiente de correlación

cor(Biomasa.data)

BIOMASA DAP ALTURA.TOTAL

BIOMASA 1.0000000 0.7372271 0.7252730

DAP 0.7372271 1.0000000 0.5259492

ALTURA.TOTAL 0.7252730 0.5259492 1.0000000

#COEFINTE DE DETERMINACION(r)

You might also like