library(pracma)
coef = taylor(f = exp, x0 = 0, n = 3)
curve(exp(x), from = 0, to = 4)
curve(coef[1]*x^3 + coef[2]*x^2+coef[3]*x+coef[4], from = 0, to = 4, add = T, col = 'red')

set.seed(1964)
t=rep(c(0,7,14,21,28,35,42,49,56,53,70,77,84),each=4);t
##  [1]  0  0  0  0  7  7  7  7 14 14 14 14 21 21 21 21 28 28 28 28 35 35 35 35 42
## [26] 42 42 42 49 49 49 49 56 56 56 56 53 53 53 53 70 70 70 70 77 77 77 77 84 84
## [51] 84 84
W<-((runif(4,15,20)*t)/(runif(4,1,6)+t))+rnorm(52,0.2,0.6);length(W)
## [1] 52
mediasW=tapply(W,as.factor(t),mean);mediasW
##          0          7         14         21         28         35         42 
##  0.4762855 11.3963341 13.4876605 15.4083178 15.0822729 16.1526516 16.1115322 
##         49         53         56         70         77         84 
## 16.3191103 16.5936494 16.7209217 16.7006052 16.7132313 17.1051012
mediast=tapply(as.numeric(t),as.factor(t),mean);mediast
##  0  7 14 21 28 35 42 49 53 56 70 77 84 
##  0  7 14 21 28 35 42 49 53 56 70 77 84
W<-((runif(4,15,20)*t)/(runif(4,1,6)+t))+rnorm(52,0.2,0.6);length(W)
## [1] 52
AF=((runif(4,6,37)*t)/(runif(4,1,5))+t^2)+rnorm(52,0.2,0.8)
plot(t,W,pch=19,cex=0.6,tlab="Peso Seco (g)",xlab="tiempo (dias)")
## Warning in plot.window(...): "tlab" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "tlab" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "tlab" is not a
## graphical parameter

## Warning in axis(side = side, at = at, labels = labels, ...): "tlab" is not a
## graphical parameter
## Warning in box(...): "tlab" is not a graphical parameter
## Warning in title(...): "tlab" is not a graphical parameter
points(mediast,mediasW,col="darkblue",pch=19)
points(7,mediasW[2], col="darkgreen",cex=1.2,pch=19)
points(14,mediasW[2], col="darkgreen",cex=1.2,pch=19)
points(14,mediasW[3], col="darkred",cex=1.2,pch=19)

xx = c(7, 14, 14)
yy = c(mediasW[2], mediasW[2], mediasW[3])
polygon(xx, yy, col = "lightblue")
text(12, (mediasW[2] + mediasW[3])/2, 'A', cex = 0.9)
text(3, mediasW[2], bquote(paste('(t'['2']*',','W'['2'],')')), cex = 0.75)
text(19, mediasW[2],bquote(paste('(t'['3']*',','W'['2'],')')), cex = 0.75)
text(10, mediasW[3], bquote(paste('(t'['3']*',','W'['3'],')')), cex = 0.75)
lines(mediast, mediasW, lty = 1, col = "darkred", lwd = 1); grid(10, 10)

\[Tcc(5:10)\frac{\Delta_w}{\Delta_D}=\frac{W_3-W_2}{t_3-t_2}\]

delta.mediasW = diff(mediasW)
delta.mediast = diff(mediast)
vector.TAC = round(delta.mediasW/delta.mediast, 4);vector.TAC
##       7      14      21      28      35      42      49      53      56      70 
##  1.5600  0.2988  0.2744 -0.0466  0.1529 -0.0059  0.0297  0.0686  0.0424 -0.0015 
##      77      84 
##  0.0018  0.0560
#tasa media en intervalo 5:10
vector.TAC[2]
##     14 
## 0.2988

Modelo de creciemiento no lineal

m <- nls(W~a+((b-a)/(1+exp(-t))), start = list(a = 1, b = 1))
summary(m)
## 
## Formula: W ~ a + ((b - a)/(1 + exp(-t)))
## 
## Parameters:
##   Estimate Std. Error t value Pr(>|t|)    
## a  -15.971      2.086  -7.657 5.67e-10 ***
## b   16.417      0.298  55.088  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.064 on 50 degrees of freedom
## 
## Number of iterations to convergence: 1 
## Achieved convergence tolerance: 1.418e-08

\[W=-16.97+\frac{0.33+16.97}{1+exp(-t)} \]