<div dir="ltr">Alisson, bom dia!<div><br></div><div>Com base na dica dada por Jobenil Júnior, pensei em comparar o procedimento utilizando uma função para cálculo aproximado da área abaixo da curva já postada aqui no fórum.<br>
<div><br></div><div><br><div><div><font face="courier new, monospace">### <code r></font></div><div><font face="courier new, monospace"># dvg <- function(x, ts, tr, a, n) {tr+(ts-tr)/((1+(a*x)^n)^(1-1/n))}</font></div>
<div><font face="courier new, monospace">dvg <- function(x){0.23+(0.64-0.23)/((1+(1.22*x)^1.34)^(1-1/1.34))}</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">dvg(10) - dvg(1500) # [1] 0.1417496</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">integrate(dvg, lower = 10, upper = 1500)</font></div><div><font face="courier new, monospace"># 412.4841 with absolute error < 0.0011</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"># emprestando a função para cálculo da área abaixo da curva já postada por Walmes Zeviani</font></div><div><font face="courier new, monospace">browseURL("<a href="http://r-br.2285057.n4.nabble.com/R-br-funcao-para-calculo-da-area-abaixo-da-curva-de-progresso-da-doenca-td4661943.html">http://r-br.2285057.n4.nabble.com/R-br-funcao-para-calculo-da-area-abaixo-da-curva-de-progresso-da-doenca-td4661943.html</a>")</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">aac <- function(x, y){</font></div><div><font face="courier new, monospace"> ox <- order(x)</font></div><div><font face="courier new, monospace"> x <- x[ox]</font></div>
<div><font face="courier new, monospace"> y <- y[ox]</font></div><div><font face="courier new, monospace"> alt <- diff(x)</font></div><div><font face="courier new, monospace"> bas <- y[-length(y)]+diff(y)/2</font></div>
<div><font face="courier new, monospace"> a <- sum(alt*bas)</font></div><div><font face="courier new, monospace"> return(a)</font></div><div><font face="courier new, monospace">}</font></div><div><font face="courier new, monospace"><br>
</font></div><div><font face="courier new, monospace">x=seq(10,1500, by=10); y=dvg(x); aac(x, y) #[1] 412.5297</font></div><div><font face="courier new, monospace">x=seq(10,1500, by=1); y=dvg(x); aac(x, y) #[1] 412.4846</font></div>
<div><font face="courier new, monospace">x=seq(10,1500, by=.1); y=dvg(x); aac(x, y) #[1] 412.4841</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">integrate(dvg, lower = 10, upper = 1500)</font></div>
<div><font face="courier new, monospace"># 412.4841 with absolute error < 0.0011</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">### visualização</font></div>
<div><font face="courier new, monospace">plot(x, y, ylim=c(0,.5), type='n')</font></div><div><font face="courier new, monospace">polygon(c(x[1],x,x[length(x)]),c(0,y,0), col=5)</font></div><div><font face="courier new, monospace">points(c(10,1500), c(dvg(10), dvg(1500)), col=2, pch=20)</font></div>
<div><font face="courier new, monospace">text(c(10,1500), c(dvg(10), dvg(1500)), round(c(dvg(10), dvg(1500)),4), cex=.5, pos=3)</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">### </code></font></div>
</div></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr">Éder Comunello <<a href="mailto:comunello.eder@gmail.com" target="_blank">c</a><a href="mailto:omunello.eder@gmail.com" target="_blank">omunello.eder@gmail.com</a>> <br>
Dourados, MS - [22 16.5'S, 54 49'W]<br></div></div>
<br><br><div class="gmail_quote"><br></div></div></div></div>