<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
span.EstiloDeEmail17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:1460881194;
mso-list-type:hybrid;
mso-list-template-ids:1506474982 -1072553262 68550681 68550683 68550671 68550681 68550683 68550671 68550681 68550683;}
@list l0:level1
{mso-level-text:%1-;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level2
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level3
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level4
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level5
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level6
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level7
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level8
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level9
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l1
{mso-list-id:1665014695;
mso-list-type:hybrid;
mso-list-template-ids:1506474982 -1072553262 68550681 68550683 68550671 68550681 68550683 68550671 68550681 68550683;}
@list l1:level1
{mso-level-text:%1-;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l1:level2
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l1:level3
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l1:level4
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l1:level5
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l1:level6
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l1:level7
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l1:level8
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l1:level9
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=PT-BR link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-US>Olá a todos,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal>Tenho 2 problemas se alguém puder me ajudar (Um exemplo dos dados encontra-se em anexo):<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l1 level1 lfo1'><![if !supportLists]><span style='mso-list:Ignore'>1-<span style='font:7.0pt "Times New Roman"'> </span></span><![endif]>como faço para estimar os intervalos de confiança dos coeficientes de um modelo ZINB. Estou usando o package (pscl). Já tentei por bootstrap mais ele não estima os intervalos. Segue abaixo o script que usei<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>data(bum2)<o:p></o:p></p><p class=MsoNormal><span lang=EN-US>F1a<-formula(BUM ~ Year + Quarter + area + Strategy+offset(log(effort1)))<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal>options(contrasts=c("contr.<span lang=EN-US>treatment","contr.poly"))<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>ZINB<-zeroinfl(F1a,dist="negbin",link = "logit",data=bum2)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>boot.zinb <- function(data, indices){<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> require(pscl)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> data <- data[indices,] <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> try(mod <- zeroinfl(F1a,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> data = data, <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> link = "logit",<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> dist = "negbin",<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> trace = FALSE<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> EM = FALSE))<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> if (exists("mod")) {<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> coef(mod)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> } else {<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> NA<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> } }<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>system.time(zinb.boot.out <- boot(data = bum2, statistic = boot.zinb, R = 99,sim="permutation"))<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal>zinb.boot.out <o:p></o:p></p><p class=MsoNormal><span lang=EN-US>boot.ci(zinb.boot.out,type="bca")<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l1 level1 lfo1'><![if !supportLists]><span style='mso-list:Ignore'>2-<span style='font:7.0pt "Times New Roman"'> </span></span><![endif]>como faço para estimar os predicts e os intervalos de confiança apenas da variável YEAR de um modelo ZINB. Abaixo o código usado:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span lang=EN-US>x<-seq(1980,2008)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>newdata=cbind.data.frame(Year=as.factor(x),Quarter=as.factor(rep(1,length(x))),area=as.factor(rep(1,length(x))),Strategy=as.factor(rep(4,length(x))),effort1=rep(1000,length(x)))<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>newdata<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>fm_zip <- zeroinfl(F1a,dist="negbin",link = "logit",data=bum2)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>fit <- predict(fm_zip)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Pearson <- resid(fm_zip, type = "pearson")<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>VarComp <- resid(fm_zip, type = "response") / Pearson<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>year <- bum2$Year<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>bootstrap <- replicate(999, {<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> yStar <- pmax(round(fit + sample(Pearson) * VarComp, 0), 0)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> predict(zeroinfl(yStar ~ year | 1), newdata = newdata)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>})<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>newdata0 <- newdata<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>newdata0$fit <- predict(fm_zip, newdata = newdata, type = "response")<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>newdata0<- t(apply(bootstrap, 1, quantile, c(0.025, 0.975)))<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal>Desde Ja agradeço a vossa atenção <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Humberto<o:p></o:p></p></div></body></html>