<div dir="ltr"><div class="gmail_default" style="color:rgb(0,0,102);font-family:courier new,monospace">Elias,</div><div class="gmail_default" style="color:rgb(0,0,102);font-family:courier new,monospace"><br></div><div class="gmail_default" style="color:rgb(0,0,102);font-family:courier new,monospace">Na verdade o w entrou na função apenas porque eu estava tentando reproduzir o primeiro exemplo da função <a href="http://boot.ci" target="_blank">boot.ci</a>. Eu não tinha intenção de colocar qualquer peso na função. Mas sem o w a função boot retonrna sempre um erro. Assim coloquei o w sempre com peso 1, achando que assim daria certo mas sempre com pesos sem "função". O fato é que agora eu voltei a ter o problema inicial. A função funciona mas retorna intervalos com valores iguais a zero. Eu esperava que o intervalo contivesse o valor que retorna a função originalmente que é <pre style="margin:0px;border:currentColor;color:rgb(0,0,0);text-transform:none;line-height:9.72px;text-indent:0px;letter-spacing:normal;font-family:"Courier New";font-size:9pt!important;font-style:normal;font-variant:normal;font-weight:normal;word-spacing:0px;white-space:pre-wrap!important;background-color:rgb(255,255,255)">1.000319 </pre></div><div class="gmail_default" style="color:rgb(0,0,102);font-family:courier new,monospace">e que fosse alguma coisa proxima dos intervalos que retornam a função original SMR. Assim, os intervalos ainda não fazem sentido para mim. Eu ainda não consegui entender o que estou fazendo de errado. <br></div><div class="gmail_default" style="color:rgb(0,0,102);font-family:courier new,monospace"><br></div><div class="gmail_default" style="color:rgb(0,0,102);font-family:courier new,monospace"><table style="border:currentColor;width:706.51px;color:rgb(0,0,0);text-transform:none;line-height:inherit!important;text-indent:0px;letter-spacing:normal;padding-bottom:8px;padding-left:6px;font-family:"Courier New"!important;font-size:9pt!important;font-style:inherit!important;font-variant:inherit!important;font-weight:inherit!important;word-spacing:0px;white-space:pre-wrap!important;background-color:rgb(255,255,255)" cellspacing="0" cellpadding="0"><tbody><tr><td align="left" style="line-height:1.2;font-family:"Courier New";font-size:9pt!important;vertical-align:top"><pre style="margin:0px;border:currentColor;line-height:1.2;font-family:"Courier New";font-size:9pt!important;white-space:pre-wrap!important"><span style="color:blue;white-space:pre-wrap">> </span><span style="color:blue">SMR2 <- function(a,w=1){length(a$Hosp_Death[which(a$Hosp_Death==1)])*w/(length(a$SAPS3Pro2) * mean(a$SAPS3Pro2))*w}
</span><span style="color:blue;white-space:pre-wrap">> </span><span style="color:blue">SMR2(a)
</span>[1] 1.000319
<span style="color:blue;white-space:pre-wrap">> </span><span style="color:blue">plot(boo <- boot(a,SMR2,999,stype='w'))
</span><span style="color:blue;white-space:pre-wrap">> </span><span style="color:blue"><a href="http://boot.ci" target="_blank">boot.ci</a>(boo)
</span>BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
Based on 999 bootstrap replicates
CALL :
<a href="http://boot.ci" target="_blank">boot.ci</a>(boot.out = boo)
Intervals :
Level Normal Basic Studentized
95% ( 0, 0 ) ( 0, 0 ) ( 0, 0 )
Level Percentile BCa
95% ( 0, 0 ) ( 0, 0 )
Calculations and Intervals on Original Scale
<span style="color:blue;white-space:pre-wrap">> </span><span style="color:blue">quantile(boo$t, c(0.025,0.975))
</span> 2.5% 97.5%
0.000000e+00 3.777955e-09
</pre></td></tr><tr><td align="left" style="line-height:1.2;font-family:"Courier New";font-size:9pt!important;vertical-align:top"></td></tr><tr><td align="left" style="line-height:1.2;font-family:"Courier New";font-size:9pt!important;vertical-align:top"><table style="width:706.94px" cellspacing="0" cellpadding="0"><tbody><tr><td width="1" height="" align="left" style="line-height:1.2;font-family:"Courier New";font-size:9pt!important;vertical-align:top" rowspan="1"><div style="color:blue;white-space:pre-wrap">> </div></td></tr></tbody></table></td></tr></tbody></table></div><div class="gmail_default" style="color:rgb(0,0,102);font-family:courier new,monospace"><br></div><div class="gmail_default" style="color:rgb(0,0,102);font-family:courier new,monospace"><br></div><div class="gmail_default" style="color:rgb(0,0,102);font-family:courier new,monospace"><br></div><div class="gmail_extra"><br clear="all"><div><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><font color="#000066" face="'courier new', monospace" style="background-color:rgb(255,255,255)">Pedro Brasil</font></div></div></div></div></div></div>
<br><div class="gmail_quote">Em 23 de setembro de 2015 10:50, Elias Teixeira Krainski <span dir="ltr"><<a href="mailto:eliaskrainski@yahoo.com.br" target="_blank">eliaskrainski@yahoo.com.br</a>></span> escreveu:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">
<div text="#000000" bgcolor="#FFFFFF">
Considerando a funcao que calcula a estatistica, e' mais apropriado
usar stype='w' na funcao boot()<br>
<br>
O CI fica menos amplo que o obtido por GLM:<br>
<br>
<br>
plot(boo <- boot(a,SMR2,999,stype='w'))<br>
<a href="http://boot.ci" target="_blank">boot.ci</a>(boo)<br>
<br>
m <- glm(Hosp_Death ~ offset(log(SAPS3Pro2)), poisson, data=a)<br>
(coef.stats <- coef(summary(m)))<br>
<br>
hist(boo$t)<br>
abline(v=exp(coef.stats[1,1] +
qnorm(c(0.025,0.5,0.975))*coef.stats[1,2]), col=2)<br>
abline(v=quantile(boo$t, c(0.025,0.975)), col=4)<br>
<br>
Elias<div><div><br>
<br>
<div>On 23/09/15 15:40, Pedro Emmanuel
Alvarenga Americano do Brasil wrote:<br>
</div>
</div></div><blockquote type="cite"><div><div>
<div dir="ltr">
<div class="gmail_default" style="color:rgb(0,0,102);font-family:courier new,monospace">
Amigos de R,</div>
<div class="gmail_default" style="color:rgb(0,0,102);font-family:courier new,monospace"><br>
</div>
<div class="gmail_default" style="color:rgb(0,0,102);font-family:courier new,monospace">Desculpa
pela demora, so consegui voltar nessa análise hoje. Bom tentei
fazer o script recomendado pelo Elias. O pedaço do plot do
bootstrap funciona, mas o pedaço para gerar o intervalo de
confiança retorna um erro. </div>
<div class="gmail_default" style="color:rgb(0,0,102);font-family:courier new,monospace"><br>
</div>
<div class="gmail_default" style="color:rgb(0,0,102);font-family:courier new,monospace">
<pre style="margin:0px;border:currentColor;color:rgb(0,0,0);text-transform:none;line-height:9.72px;text-indent:0px;letter-spacing:normal;font-family:"Courier New";font-size:9pt!important;font-style:normal;font-variant:normal;font-weight:normal;word-spacing:0px;white-space:pre-wrap!important;background-color:rgb(255,255,255)"><span style="color:blue;white-space:pre-wrap">> </span><span style="color:blue">library(boot)
</span><span style="color:blue;white-space:pre-wrap">> </span><span style="color:blue">SMR2 <- function(a,w=1){length(a$Hosp_Death[which(a$Hosp_Death==1)])*w/(length(a$SAPS3Pro2) * mean(a$SAPS3Pro2))*w}
</span><span style="color:blue;white-space:pre-wrap">> </span><span style="color:blue">SMR2(a)
</span>[1] 1.000319
<span style="color:blue;white-space:pre-wrap">> </span><span style="color:blue">plot(boo <- boot(a,SMR2,999,stype='i'))
</span><span style="color:blue;white-space:pre-wrap">> </span><span style="color:blue"><a href="http://boot.ci" target="_blank">boot.ci</a>(boo)
</span><span style="color:rgb(197,6,11)">Error in <a href="http://bca.ci" target="_blank">bca.ci</a>(boot.out, conf, index[1L], L = L, t = t.o, t0 = t0.o, :
estimated adjustment 'w' is infinite</span></pre>
</div>
<div class="gmail_default" style="color:rgb(0,0,102);font-family:courier new,monospace"><br>
</div>
<div class="gmail_default" style="color:rgb(0,0,102);font-family:courier new,monospace">Achei
muito estranho a função plot do bot funcionar e o <a href="http://boot.ci" target="_blank">boot.ci</a> não
funcionar. Possivelmente ha necessidade de resolver alguma
configuração para esse pedação do script. <br>
</div>
</div>
<div class="gmail_extra"><br clear="all">
<div>
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div dir="ltr"><font color="#000066" face="'courier new', monospace" style="background-color:rgb(255,255,255)">Pedro
Brasil</font></div>
</div>
</div>
</div>
</div>
</div>
<br>
<div class="gmail_quote">2015-09-23 0:19 GMT-03:00 ASANTOS <span dir="ltr"><<a href="mailto:alexandresantosbr@yahoo.com.br" target="_blank">alexandresantosbr@yahoo.com.br</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">Mauro,
segue o script,
<div>
<div><br>
<br>
dput(a[sample(1:nrow(a),100),c("Hosp_Death","SAPS3Pro2")])<br>
structure(list(Hosp_Death = c(0L, 1L, 0L, 1L, 0L, 0L,
0L, 1L,<br>
0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L,<br>
1L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 1L,<br>
0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L,
0L, 0L,<br>
1L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L,
0L, 0L,<br>
1L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L,
0L, 0L,<br>
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L),
SAPS3Pro2 = c(0.1205,<br>
0.3768, 0.315, 0.3768, 0.0311, 0.0719, 0.1735, 0.75,
0.01, 0.1454,<br>
0.1093, 0.0511, 0.0891, 0.3353, 0.0073, 0.0401, 0.0044,
0.0239,<br>
0.5246, 0.1591, 0.0453, 0.0511, 0.8715, 0.1735, 0.6037,
0.4405,<br>
0.2047, 0.0208, 0.1591, 0.2047, 0.1205, 0.2759, 0.0273,
0.0044,<br>
0.2759, 0.0157, 0.0643, 0.2215, 0.2047, 0.1735, 0.1591,
0.0273,<br>
0.0062, 0.0311, 0.0157, 0.4192, 0.0643, 0.1735, 0.239,
0.4618,<br>
0.0401, 0.0802, 0.0273, 0.0239, 0.0025, 0.0157, 0.0311,
0.0157,<br>
0.0719, 0.239, 0.0574, 0.0157, 0.0085, 0.0085, 0.1093,
0.2215,<br>
0.1591, 0.0719, 0.0044, 0.8563, 0.0453, 0.2047, 0.1454,
0.0273,<br>
0.0891, 0.0802, 0.0239, 0.0135, 0.0802, 0.2571, 0.1735,
0.0157,<br>
0.3768, 0.2759, 0.0891, 0.2047, 0.1735, 0.1454, 0.0643,
0.0311,<br>
0.0453, 0.2759, 0.0239, 0.0181, 0.4405, 0.0085, 0.0311,
0.1205,<br>
0.6579, 0.1093)), .Names = c("Hosp_Death", "SAPS3Pro2"),
row.names = c(21875L,<br>
6572L, 48643L, 11869L, 35683L, 48246L, 23919L, 29666L,
3676L,<br>
45549L, 36453L, 14510L, 5082L, 1898L, 41549L, 25481L,
28590L,<br>
38198L, 12822L, 12834L, 33267L, 34088L, 47720L, 30063L,
18326L,<br>
11582L, 11454L, 34960L, 18785L, 11385L, 20605L, 28105L,
25496L,<br>
1607L, 48766L, 36534L, 41868L, 45312L, 37206L, 26927L,
38944L,<br>
21087L, 22343L, 1332L, 11496L, 29485L, 38316L, 4486L,
19757L,<br>
45768L, 33028L, 12205L, 13150L, 41270L, 2780L, 44400L,
19696L,<br>
26015L, 14651L, 39093L, 24905L, 17870L, 35016L, 42851L,
20464L,<br>
33155L, 24924L, 33220L, 15379L, 28989L, 33286L, 34782L,
48534L,<br>
9045L, 20403L, 40222L, 8821L, 31240L, 12465L, 11024L,
24407L,<br>
45729L, 7412L, 22344L, 17737L, 3514L, 2335L, 22491L,
22493L,<br>
14077L, 20346L, 12114L, 36868L, 16431L, 25112L, 31272L,
10877L,<br>
14391L, 8422L, 45130L), class = "data.frame")<br>
<br>
<br>
SMR <- function(obs.var,pred.var){<br>
</div>
</div>
if(length(obs.var) != length(pred.var)){<span><br>
stop("Length of pred.var and obs.var differ.")<br>
}<br>
</span>
if(any(min(pred.var) <0 | max(pred.var) > 1)){<span><br>
stop("The individual predicted death must range from
0 to 1.")<br>
}<br>
</span>
if(any(levels(as.factor(obs.var)) != c(0,1))){<span><br>
stop("Observed death variable must be coded as 0 and
1.")<br>
}<br>
</span><span>
O <- length(obs.var[which(obs.var==1)])<br>
</span><span>
E <- length(pred.var) * mean(pred.var)<br>
</span><span>
SMR <- O / E<br>
</span><span>
lowerCL <- O / E * (1 - 1 / (9 * O) - 1.96 / (3 *
sqrt(O)))^3 * 100<br>
</span><span>
upperCL <- (O + 1) / E * (1 - (1 / (9 * (O + 1))) +
1.96 / (3 * sqrt(O + 1)))^3 * 100<br>
</span>
output <- c(SMR=SMR,lower.Cl=lowerCL,upper.Cl=upperCL)<br>
output<span><br>
}<br>
<br>
<br>
SMR2 <-
function(a,w=1){length(a$Hosp_Death[which(a$Hosp_Death==1)])*w/(length(a$SAPS3Pro2)
* mean(a$SAPS3Pro2))*w}<br>
<br>
<br>
</span><span><a href="http://boot.ci" target="_blank" rel="noreferrer">boot.ci</a>(boot(a,
SMR2, R = 10, stype = "w",parallel = "multicore"))<br>
<br>
x <- <a href="http://boot.ci" target="_blank" rel="noreferrer">boot.ci</a>(boot(a,
SMR2, R = 10, stype = "w",parallel = "snow"))<br>
</span><span>
SMR2 <- function(a,w=1)<br>
sum(w*a$Hosp_Death)/sum(w*a$SAPS3Pro2)<br>
<br>
SMR2(a) ### SMR observada nos dados<br>
<br>
require(boot)<br>
<br>
plot(boo <- boot(a,SMR2,999,stype='i'))<br>
<a href="http://boot.ci" target="_blank" rel="noreferrer">boot.ci</a>(boo)<br>
<br>
</span>
<div>
<div>
Em 22/09/2015 23:14, Mauro Sznelwar escreveu:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">Alguém
poderia passar o código anterior, pois eu apaguei o
que chegou antes.<br>
<br>
<br>
<br>
vc pode fazer assim:<br>
<br>
SMR2 <- function(a,w=1)<br>
sum(w*a$Hosp_Death)/sum(w*a$SAPS3Pro2)<br>
<br>
SMR2(a) ### SMR observada nos dados<br>
<br>
require(boot)<br>
<br>
plot(boo <- boot(a,SMR2,999,stype='i'))<br>
<a href="http://boot.ci" target="_blank" rel="noreferrer">boot.ci</a>(boo)<br>
<br>
.<br>
<br>
<br>
---<br>
Este email foi escaneado pelo Avast antivírus.<br>
<a href="https://www.avast.com/antivirus" target="_blank" rel="noreferrer">https://www.avast.com/antivirus</a><br>
<br>
_______________________________________________<br>
R-br mailing list<br>
<a href="mailto:R-br@listas.c3sl.ufpr.br" target="_blank">R-br@listas.c3sl.ufpr.br</a><br>
<a href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br" target="_blank" rel="noreferrer">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a><br>
Leia o guia de postagem (<a href="http://www.leg.ufpr.br/r-br-guia" target="_blank" rel="noreferrer">http://www.leg.ufpr.br/r-br-guia</a>)
e fornea cdigo mnimo reproduzvel.<br>
</blockquote>
<br>
</div>
</div>
<span>
-- <br>
======================================================================<br>
Alexandre dos Santos<br>
Proteção Florestal<br>
IFMT - Instituto Federal de Educação, Ciência e Tecnologia
de Mato Grosso<br>
Campus Cáceres<br>
Caixa Postal 244<br>
Avenida dos Ramires, s/n<br>
Bairro: Distrito Industrial<br>
Cáceres - MT CEP: 78.200-000<br>
Fone: <a href="tel:%28%2B55%29%2065%208132-8112" target="_blank" value="+556581328112">(+55) 65 8132-8112</a> (TIM) <a href="tel:%28%2B55%29%2065%209686-6970" target="_blank" value="+556596866970">(+55) 65 9686-6970</a> (VIVO)<br>
<a href="mailto:e-mails%3Aalexandresantosbr@yahoo.com.br" target="_blank">e-mails:alexandresantosbr@yahoo.com.br</a><br>
<a href="mailto:alexandre.santos@cas.ifmt.edu.br" target="_blank">alexandre.santos@cas.ifmt.edu.br</a><br>
Lattes: <a href="http://lattes.cnpq.br/1360403201088680" target="_blank" rel="noreferrer">http://lattes.cnpq.br/1360403201088680</a><br>
======================================================================<br>
<br>
</span>
<div>
<div>
_______________________________________________<br>
R-br mailing list<br>
<a href="mailto:R-br@listas.c3sl.ufpr.br" target="_blank">R-br@listas.c3sl.ufpr.br</a><br>
<a href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br" target="_blank" rel="noreferrer">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a><br>
Leia o guia de postagem (<a href="http://www.leg.ufpr.br/r-br-guia" target="_blank" rel="noreferrer">http://www.leg.ufpr.br/r-br-guia</a>)
e fornea cdigo mnimo reproduzvel.</div>
</div>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset></fieldset>
<br>
</div></div><pre><div><div>_______________________________________________
R-br mailing list
<a href="mailto:R-br@listas.c3sl.ufpr.br" target="_blank">R-br@listas.c3sl.ufpr.br</a>
<a href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br" target="_blank">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a></div></div>
Leia o guia de postagem (<a href="http://www.leg.ufpr.br/r-br-guia" target="_blank">http://www.leg.ufpr.br/r-br-guia</a>) e forne�a c�digo m�nimo reproduz�vel.</pre>
</blockquote>
<br>
</div>
<br>_______________________________________________<br>
R-br mailing list<br>
<a href="mailto:R-br@listas.c3sl.ufpr.br" target="_blank">R-br@listas.c3sl.ufpr.br</a><br>
<a href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br" target="_blank" rel="noreferrer">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a><br>
Leia o guia de postagem (<a href="http://www.leg.ufpr.br/r-br-guia" target="_blank" rel="noreferrer">http://www.leg.ufpr.br/r-br-guia</a>) e forneça código mínimo reproduzível.<br></blockquote></div><br></div></div>