{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE)
datos=c(6,3,7,4,5,3)
A=matrix(data=datos,nrow=3,ncol=2,byrow=FALSE)
print(A*3)
## [,1] [,2]
## [1,] 18 12
## [2,] 9 15
## [3,] 21 9
matA<-matrix(data=c("a","b","c","d","e","f"),nrow=3,ncol=2,byrow=TRUE)
rownames(matA)<-c("Fila1","Fila2","Fila3")
colnames(matA)<-c("Col1","Col2")
print(matA)
## Col1 Col2
## Fila1 "a" "b"
## Fila2 "c" "d"
## Fila3 "e" "f"
class(matA)
## [1] "matrix" "array"
print(is.matrix(matA))
## [1] TRUE
## Fórmulas estaadísticas
x<-c(4,2,7,8,4,6,5,8,3)
media<-mean(x)
desvSTD<-sd(x)
varianza<-var(x)
print(media)
## [1] 5.222222
print(desvSTD)
## [1] 2.166667
print(varianza)
## [1] 4.694444
x<-c(0,1,2,3,4,5)
y<-c(0.5,1.4,1.98,3.1,3.8,5.4)
formula1<-formula(y~x)
modelo<-lm(formula1)
summary(modelo)
##
## Call:
## lm(formula = formula1)
##
## Residuals:
## 1 2 3 4 5 6
## 0.14762 0.10990 -0.24781 -0.06552 -0.30324 0.35905
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.35238 0.20485 1.72 0.160511
## x 0.93771 0.06766 13.86 0.000157 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.283 on 4 degrees of freedom
## Multiple R-squared: 0.9796, Adjusted R-squared: 0.9745
## F-statistic: 192.1 on 1 and 4 DF, p-value: 0.0001571
`
plot(x,y)
abline(0.35238,0.93771,col="yellow")
altura<-c(2.25,2.00,1.80,1.70,1.60,1.50,1.25)
tiempo<-c(0.729,0.690,0.623,0.607,0.586,0.553,0.503)
h<-seq(1.0,2.50,0.1)
t<-sqrt(h*2/9.8)
t2=tiempo*tiempo
plot(t2,altura,xlim=c(0.4,0.90),ylim=c(0,3.0),main="Altura(cm) vs Tiempo(s)",xlab = "t(seg)",ylab="altura(cm)")
lines(t,h,col="black")
abline(-0.8785,4.2723,col="red" )
abline(v=0.7,col="yellow")
abline(h=2.0,col="blue")
abline(v=0.5,col="blue")
modelo<-lm(altura~tiempo)
summary(modelo)
##
## Call:
## lm(formula = altura ~ tiempo)
##
## Residuals:
## 1 2 3 4 5 6 7
## 0.030647 -0.054349 0.029120 -0.003186 -0.014338 0.025281 -0.013175
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.8650 0.1106 -7.823 0.000547 ***
## tiempo 4.2309 0.1792 23.616 2.54e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03397 on 5 degrees of freedom
## Multiple R-squared: 0.9911, Adjusted R-squared: 0.9893
## F-statistic: 557.7 on 1 and 5 DF, p-value: 2.535e-06
altura<-c(2.25,2.00,1.80,1.70,1.60,1.50,1.25)
tiempo<-c(0.729,0.690,0.623,0.607,0.586,0.553,0.503)
h<-seq(1.0,2.50,0.1)
t<-sqrt(h*2/9.8)
t2=tiempo*tiempo
plot(t2,altura,main="Altura(cm) vs Tiempo(s)")
abline(0.4698,3.3319)
modelo<-lm(altura~t2)
summary(modelo)
##
## Call:
## lm(formula = altura ~ t2)
##
## Residuals:
## 1 2 3 4 5 6 7
## 0.0088906 -0.0526873 0.0468317 0.0138371 -0.0008638 0.0271105 -0.0431189
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.43169 0.06582 6.559 0.00124 **
## t2 3.40475 0.16828 20.233 5.45e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03958 on 5 degrees of freedom
## Multiple R-squared: 0.9879, Adjusted R-squared: 0.9855
## F-statistic: 409.4 on 1 and 5 DF, p-value: 5.454e-06