#UNIVERSIDAD NACIONAL DEL ALTIPLANO
#INGENIERIA ESTADISTICA E INFORMATICA
#REGRESION AVANZADA
#REGRESION INTRISICAMENTE NO LINEAL
library(readxl)
## Warning: package 'readxl' was built under R version 4.0.2
Datos <- read_excel("E:/VII SEMESTRE/REGRESION AVANZADA/Trabajo 3/Datos.xlsx")
Datos
## # A tibble: 7 x 3
## x y1 y2
## <dbl> <dbl> <dbl>
## 1 0.5 0.68 1.58
## 2 1 0.45 2.66
## 3 2 2.5 2.04
## 4 4 6.19 7.85
## 5 8 56.1 54.2
## 6 9 89.8 90.2
## 7 10 148. 146.
head(Datos)
## # A tibble: 6 x 3
## x y1 y2
## <dbl> <dbl> <dbl>
## 1 0.5 0.68 1.58
## 2 1 0.45 2.66
## 3 2 2.5 2.04
## 4 4 6.19 7.85
## 5 8 56.1 54.2
## 6 9 89.8 90.2
View(Datos)
#Representacion de Datos
plot(y1 ~ x, xlab="Log de Densidad", ylab="Residuales", data = Datos)

plot(y2 ~ x, xlab="Log de Densidad", ylab="Residuales", data = Datos)

foo = function(x,b1,b2,b3){(b2+b3*x+(log(b1)))}
x<- 2
#Plots of Regression No lineal
plot(y1 ~ x,xlab="Log de Densidad",
ylab="Mobilidad de los electrones",main="Prueba 1", data = Datos)
lines(lowess(Datos$y1 ~ Datos$x),col = "red")

plot(y2 ~ x,xlab="Log de Densidad",
ylab="Mobilidad de los electrones",main="Prueba 2", data = Datos)
lines(lowess(Datos$y2 ~ Datos$x),col = "blue")

#Valors
m1start=list(b1=0,b2=0.3,b3=5.1)
B1=0
B2=0.3
B3=5.1
x=2
#Anova
m.lm <- lm(y1 ~ x,data = Datos)
summary(m.lm)
##
## Call:
## lm(formula = y1 ~ x, data = Datos)
##
## Residuals:
## 1 2 3 4 5 6 7
## 15.750 8.924 -2.216 -24.907 -27.760 -7.250 37.459
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -21.665 15.855 -1.366 0.23003
## x 13.191 2.571 5.131 0.00367 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 25.22 on 5 degrees of freedom
## Multiple R-squared: 0.8404, Adjusted R-squared: 0.8085
## F-statistic: 26.33 on 1 and 5 DF, p-value: 0.003673
anova(m.lm)
## Analysis of Variance Table
##
## Response: y1
## Df Sum Sq Mean Sq F value Pr(>F)
## x 1 16740.5 16740.5 26.327 0.003673 **
## Residuals 5 3179.3 635.9
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1