Análisis exploratorio de los datos

library(ggplot2)
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
a=ggplot(latex,aes(x=`Distancia al río (m)`, y=`Cantidad de látex producido (ml/día)`,col=Podado))+
  geom_point()+theme_bw()
ggplotly(a)
b=ggplot(latex,aes(x=`Elevación (msnm)`, y=`Cantidad de látex producido (ml/día)`, col=Podado))+
  geom_point()+theme_bw()
ggplotly(b)
ggplot(latex,aes(x=Podado,y=`Cantidad de látex producido (ml/día)`,fill=Podado))+geom_boxplot()

Análisis de la regresión lineal

y=`Cantidad de látex producido (ml/día)`
x1=`Distancia al río (m)`
x2=`Elevación (msnm)`
x3=as.numeric(Podado=="SI")
data.frame(y,x1,x2,x3)
##    y  x1   x2 x3
## 1 24  87 1169  0
## 2 32  12 1168  0
## 3 28 100 1102  0
## 4 37   7 1098  0
## 5 30  15 1165  1
## 6 22  84 1164  1
## 7 25 104 1101  1
## 8 36   5 1097  1
xd=lm(y~x1+x2+x3)
summary(xd)
## 
## Call:
## lm(formula = y ~ x1 + x2 + x3)
## 
## Residuals:
##        1        2        3        4        5        6        7        8 
##  0.03767  0.10861  0.44492 -0.59120  0.33347 -0.51377 -0.07759  0.25788 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 119.515658   6.017345  19.862 3.79e-05 ***
## x1           -0.104735   0.004176 -25.079 1.50e-05 ***
## x2           -0.073945   0.005294 -13.969 0.000152 ***
## x3           -2.132494   0.355281  -6.002 0.003877 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.5021 on 4 degrees of freedom
## Multiple R-squared:  0.9953, Adjusted R-squared:  0.9917 
## F-statistic:   281 on 3 and 4 DF,  p-value: 4.176e-05
cor(y,x1)
## [1] -0.854005
cor(y,x2)
## [1] -0.4563459
cor(y,x3)
## [1] -0.1935736
predict(xd, list(x1=5,x2=1097, x3=1), interval = "confidence")
##        fit      lwr      upr
## 1 35.74212 34.71541 36.76883

La función que se ajusta a los datos es \(y=119.515658-0.104735x_1-0.073945x_2-2.132494x_3\)

ANOVA y Post-ANOVA

library(agricolae)
## Warning: package 'agricolae' was built under R version 4.0.5
##ANOVA
uwu=lm(y~x3)
anova(uwu)
## Analysis of Variance Table
## 
## Response: y
##           Df Sum Sq Mean Sq F value Pr(>F)
## x3         1    8.0    8.00  0.2336  0.646
## Residuals  6  205.5   34.25
##Post ANOVA

com=LSD.test(uwu,"x3")
com
## $statistics
##   MSerror Df  Mean       CV  t.value     LSD
##     34.25  6 29.25 20.00803 2.446912 10.1259
## 
## $parameters
##         test p.ajusted name.t ntr alpha
##   Fisher-LSD      none     x3   2  0.05
## 
## $means
##       y      std r      LCL      UCL Min Max   Q25  Q50   Q75
## 0 30.25 5.560276 4 23.08991 37.41009  24  37 27.00 30.0 33.25
## 1 28.25 6.130525 4 21.08991 35.41009  22  36 24.25 27.5 31.50
## 
## $comparison
## NULL
## 
## $groups
##       y groups
## 0 30.25      a
## 1 28.25      a
## 
## attr(,"class")
## [1] "group"