diff --git a/scripts/ce089-06.R b/scripts/ce089-06.R index 003ffea4c5c9fe9fcfc08cceecfd90d7c6b2705b..39742e4be868011f49fa83f5c74272c1b297eabe 100644 --- a/scripts/ce089-06.R +++ b/scripts/ce089-06.R @@ -150,3 +150,30 @@ with(as.list(coef(n1)), { }) #----------------------------------------------------------------------- +# Usando o pacote boot. + +library(boot) + +help(boot, help_type = "html") + +str(turk0) + +# Criar uma função com dois argumentos: o data.frame original e um vetor +# que vai representar o índice das linhas usado para reamostrar dos +# dados. +fitmodel <- function(dataset, index) { + n0 <- nls(Gain ~ Int + Ass * (1 - 2^(-A/Mei)), + data = dataset[index, ], + start = list(Int = 625, Ass = 180, Mei = 0.1)) + c(coef(n0), s2 = deviance(n0)/df.residual(n0)) +} + +b0 <- boot(turk0, + statistic = fitmodel, + R = 999) + +pairs(b0) + +# TODO: +# usar o pacote boot. +# reproduzir os resultados do boot() e boot.ci().