<div dir="ltr">Oi Alexandre,<div><br></div><div>É que me foi proposto trabalhar com o dbern.</div><div><br></div><div>Então, estou com problema no modelo... alguém poderia verificar onde está o erro? Por gentileza...</div>
<div>Segue:</div><div><br></div><div><div># Gerando dados</div><div>tabela<-read.csv("morfo.csv",sep=";",head=T)</div><div>tabela$SX<-as.factor(tabela$SX)</div><div><br></div><div>#criar a lista de dados para o jags</div>
<div>lddados <- list(y=tabela$SX,</div><div><span class="" style="white-space:pre">              </span>    N=length(tabela$SX),</div><div><span class="" style="white-space:pre">           </span>    CT=tabela$CT,</div><div><span class="" style="white-space:pre">          </span>    CF=tabela$CF,</div>
<div><span class="" style="white-space:pre">            </span>    CP=tabela$CP,</div><div><span class="" style="white-space:pre">          </span>    CC=tabela$CC,</div><div><span class="" style="white-space:pre">          </span>    FO=tabela$FO,</div>
<div><span class="" style="white-space:pre">            </span>    AC=tabela$AC,</div><div><span class="" style="white-space:pre">          </span>    PD=tabela$PD,</div><div><span class="" style="white-space:pre">          </span>    CD=tabela$CD,</div>
<div><span class="" style="white-space:pre">            </span>    BD=tabela$BD,</div><div><span class="" style="white-space:pre">          </span>    PP=tabela$PP,</div><div><span class="" style="white-space:pre">          </span>    CPT=tabela$CPT,</div>
<div><span class="" style="white-space:pre">            </span>    BP=tabela$BP,</div><div><span class="" style="white-space:pre">          </span>    PV=tabela$PV,</div><div><span class="" style="white-space:pre">          </span>    BV=tabela$BV,</div>
<div><span class="" style="white-space:pre">            </span>    LC=tabela$LC,</div><div><span class="" style="white-space:pre">          </span>    CV=tabela$CV,</div><div><span class="" style="white-space:pre">          </span>    PA=tabela$PA,</div>
<div><span class="" style="white-space:pre">            </span>    BA=tabela$BA,</div><div><span class="" style="white-space:pre">          </span>    CA=tabela$CA,</div><div><span class="" style="white-space:pre">          </span>    AP=tabela$AP,</div>
<div><span class="" style="white-space:pre">            </span>    LP=tabela$LP,</div><div><span class="" style="white-space:pre">          </span>    CM=tabela$CM,</div><div><span class="" style="white-space:pre">          </span>    DOH=tabela$DOH,</div>
<div><span class="" style="white-space:pre">            </span>    DOV=tabela$DOV)</div><div><br></div><div>#criar modelo</div><div>sink('morfo.txt')</div><div>cat('</div><div><span class="" style="white-space:pre">   </span>model{</div>
<div><span class="" style="white-space:pre">            </span>for(i in 1:N){                   # loop sobre as observações</div><div><span class="" style="white-space:pre">                       </span>y[i] ~ dbern(p[i])         # saída binária</div>
<div><span class="" style="white-space:pre">                    </span>logit(p[i]) <- beta0       # regressão multivariada</div><div><span class="" style="white-space:pre">                                     </span> + beta1*CT[i]</div><div><span class="" style="white-space:pre">                                     </span> + beta2*CF[i]</div>
<div><span class="" style="white-space:pre">                                    </span> + beta3*CP[i]</div><div><span class="" style="white-space:pre">                                     </span> + beta4*CC[i]</div><div><span class="" style="white-space:pre">                                     </span> + beta5*FO[i]</div>
<div><span class="" style="white-space:pre">                                    </span> + beta6*AC[i]</div><div><span class="" style="white-space:pre">                                     </span> + beta7*PD[i]</div><div><span class="" style="white-space:pre">                                     </span> + beta8*CD[i]</div>
<div><span class="" style="white-space:pre">                                    </span> + beta9*BD[i]</div><div><span class="" style="white-space:pre">                                     </span> + beta10*PP[i]</div><div><span class="" style="white-space:pre">                                    </span> + beta11*CPT[i]</div>
<div><span class="" style="white-space:pre">                                    </span> + beta12*BP[i]</div><div><span class="" style="white-space:pre">                                    </span> + beta13*PV[i]</div><div><span class="" style="white-space:pre">                                    </span> + beta14*BV[i]</div>
<div><span class="" style="white-space:pre">                                    </span> + beta15*LC[i]</div><div><span class="" style="white-space:pre">                                    </span> + beta16*CV[i]</div><div><span class="" style="white-space:pre">                                    </span> + beta17*PA[i]</div>
<div><span class="" style="white-space:pre">                                    </span> + beta18*BA[i]</div><div><span class="" style="white-space:pre">                                    </span> + beta19*CA[i]</div><div><span class="" style="white-space:pre">                                    </span> + beta20*AP[i]</div>
<div><span class="" style="white-space:pre">                                    </span> + beta21*LP[i]</div><div><span class="" style="white-space:pre">                                    </span> + beta22*CM[i]</div><div><span class="" style="white-space:pre">                                    </span> + beta23*DOH[i]</div>
<div><span class="" style="white-space:pre">                                    </span> + beta24*DOV[i]</div><div><span class="" style="white-space:pre">           </span>}</div><div><span class="" style="white-space:pre">          </span># Prioris</div><div><span class="" style="white-space:pre">          </span>beta0 ~ dnorm(0,1.0E-6)</div>
<div><span class="" style="white-space:pre">            </span>beta1 ~ dnorm(0,1.0E-6)</div><div><span class="" style="white-space:pre">            </span>beta2 ~ dnorm(0,1.0E-6)</div><div><span class="" style="white-space:pre">            </span>beta3 ~ dnorm(0,1.0E-6)</div>
<div><span class="" style="white-space:pre">            </span>beta4 ~ dnorm(0,1.0E-6)</div><div><span class="" style="white-space:pre">            </span>beta5 ~ dnorm(0,1.0E-6)</div><div><span class="" style="white-space:pre">            </span>beta6 ~ dnorm(0,1.0E-6)</div>
<div><span class="" style="white-space:pre">            </span>beta7 ~ dnorm(0,1.0E-6)</div><div><span class="" style="white-space:pre">            </span>beta8 ~ dnorm(0,1.0E-6)</div><div><span class="" style="white-space:pre">            </span>beta9 ~ dnorm(0,1.0E-6)</div>
<div><span class="" style="white-space:pre">            </span>beta10 ~ dnorm(0,1.0E-6)</div><div><span class="" style="white-space:pre">           </span>beta11 ~ dnorm(0,1.0E-6)</div><div><span class="" style="white-space:pre">           </span>beta12 ~ dnorm(0,1.0E-6)</div>
<div><span class="" style="white-space:pre">            </span>beta13 ~ dnorm(0,1.0E-6)</div><div><span class="" style="white-space:pre">           </span>beta14 ~ dnorm(0,1.0E-6)</div><div><span class="" style="white-space:pre">           </span>beta15 ~ dnorm(0,1.0E-6)</div>
<div><span class="" style="white-space:pre">            </span>beta16 ~ dnorm(0,1.0E-6)</div><div><span class="" style="white-space:pre">           </span>beta17 ~ dnorm(0,1.0E-6)</div><div><span class="" style="white-space:pre">           </span>beta18 ~ dnorm(0,1.0E-6)</div>
<div><span class="" style="white-space:pre">            </span>beta19 ~ dnorm(0,1.0E-6)</div><div><span class="" style="white-space:pre">           </span>beta20 ~ dnorm(0,1.0E-6)</div><div><span class="" style="white-space:pre">           </span>beta21 ~ dnorm(0,1.0E-6)</div>
<div><span class="" style="white-space:pre">            </span>beta22 ~ dnorm(0,1.0E-6)</div><div><span class="" style="white-space:pre">           </span>beta23 ~ dnorm(0,1.0E-6)</div><div><span class="" style="white-space:pre">           </span>beta24 ~ dnorm(0,1.0E-6)</div>
<div><span class="" style="white-space:pre">    </span>}</div><div>')</div><div><br></div><div>sink()</div><div><br></div><div>#carregar a biblioteca jags</div><div>library(rjags)</div><div><br></div><div>#definir os parâmetros para as posteriores</div>
<div><br></div><div>params <- c("beta0",</div><div>            "beta1",</div><div><span class="" style="white-space:pre">      </span> <span class="" style="white-space:pre"> </span>"beta2",</div>
<div>            "beta3",</div><div><span class="" style="white-space:pre">               </span>"beta4",</div><div>            "beta5",</div><div>            "beta6",</div><div><span class="" style="white-space:pre">       </span> <span class="" style="white-space:pre"> </span>"beta7",</div>
<div>            "beta8",</div><div><span class="" style="white-space:pre">               </span>"beta9",</div><div>            "beta10",</div><div>            "beta11",</div><div><span class="" style="white-space:pre">     </span> <span class="" style="white-space:pre"> </span>"beta12",</div>
<div>            "beta13",</div><div><span class="" style="white-space:pre">              </span>"beta14",</div><div>            "beta15",</div><div>            "beta16",</div><div><span class="" style="white-space:pre">    </span> <span class="" style="white-space:pre"> </span>"beta17",</div>
<div>            "beta18",</div><div><span class="" style="white-space:pre">              </span>"beta19",</div><div>            "beta20",</div><div>            "beta21",</div><div><span class="" style="white-space:pre">    </span> <span class="" style="white-space:pre"> </span>"beta22",</div>
<div>            "beta23",</div><div><span class="" style="white-space:pre">              </span>"beta24")</div><div><br></div><div>#inicializar cadeia</div><div>inicio <- list(beta0=0,</div><div><span class="" style="white-space:pre">            </span>   beta1=0,</div>
<div><span class="" style="white-space:pre">            </span>   beta2=0,</div><div><span class="" style="white-space:pre">                </span>   beta3=0,</div><div><span class="" style="white-space:pre">                </span>   beta4=0,</div><div><span class="" style="white-space:pre">                </span>   beta5=0,</div>
<div><span class="" style="white-space:pre">            </span>   beta6=0,</div><div><span class="" style="white-space:pre">                </span>   beta7=0,</div><div><span class="" style="white-space:pre">                </span>   beta8=0,</div><div><span class="" style="white-space:pre">                </span>   beta9=0,</div>
<div><span class="" style="white-space:pre">            </span>   beta10=0,</div><div><span class="" style="white-space:pre">               </span>   beta11=0,</div><div><span class="" style="white-space:pre">               </span>   beta12=0,</div><div><span class="" style="white-space:pre">               </span>   beta13=0,</div>
<div><span class="" style="white-space:pre">            </span>   beta14=0,</div><div><span class="" style="white-space:pre">               </span>   beta15=0,</div><div><span class="" style="white-space:pre">               </span>   beta16=0,</div><div><span class="" style="white-space:pre">               </span>   beta17=0,</div>
<div><span class="" style="white-space:pre">            </span>   beta18=0,</div><div><span class="" style="white-space:pre">               </span>   beta19=0,</div><div><span class="" style="white-space:pre">               </span>   beta20=0,</div><div><span class="" style="white-space:pre">               </span>   beta21=0,</div>
<div><span class="" style="white-space:pre">            </span>   beta22=0,</div><div><span class="" style="white-space:pre">               </span>   beta23=0,</div><div><span class="" style="white-space:pre">               </span>   beta24=0)</div><div><br>
</div><div>#chamar o modelo no jags</div><div>morfo.m <- jags.model("morfo.txt",data=lddados,inicio,n.chains=1,n.adapt=1000)</div><div><br></div></div><div>Abraço,</div><div>Gisele</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">Em 12 de outubro de 2013 15:39, ASANTOS <span dir="ltr"><<a href="mailto:alexandresantosbr@yahoo.com.br" target="_blank">alexandresantosbr@yahoo.com.br</a>></span> escreveu:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    Gisele,<br>
        Por que não utilizar a função qbinom(), que também se aplica a
    Bernoulli?<br>
    <br>
    Abraço,<br>
    <br>
    <pre cols="72">-- 
======================================================================
Alexandre dos Santos
Proteção Florestal 
IFMT - Instituto Federal de Educação, Ciência e Tecnologia de Mato Grosso
Campus Cáceres
Caixa Postal 244
Avenida dos Ramires, s/n
Bairro: Distrito Industrial 
Cáceres - MT                      CEP: 78.200-000
Fone: <a href="tel:%28%2B55%29%2065%208132-8112" value="+556581328112" target="_blank">(+55) 65 8132-8112</a> (TIM)   <a href="tel:%28%2B55%29%2065%209686-6970" value="+556596866970" target="_blank">(+55) 65 9686-6970</a> (VIVO)
<a href="mailto:e-mails:alexandresantosbr@yahoo.com.br" target="_blank">e-mails:alexandresantosbr@yahoo.com.br</a> 
        <a href="mailto:alexandre.santos@cas.ifmt.edu.br" target="_blank">alexandre.santos@cas.ifmt.edu.br</a> 
Lattes: <a href="http://lattes.cnpq.br/1360403201088680" target="_blank">http://lattes.cnpq.br/1360403201088680</a>                   
======================================================================</pre>
    <br>
    <div>Em 12/10/2013 15:03, Gisele Correia
      escreveu:<br>
    </div>
    <blockquote type="cite"><div><div class="h5">
      <div dir="ltr">Olá!!
        <div><br>
        </div>
        <div>Alguém teria um exemplo de distribuição de Bernoulli no R?</div>
        <div>Até agora não encontrei nenhum trabalho/problema utilizando
          a função dbern(p).<br>
          Pretendo resolver o problema utilizando cadeias de Markov.</div>
        <div><br>
        </div>
        <div>Desde já agradeço,</div>
        <div>Gisele</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      </div></div><pre>_______________________________________________
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>
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>
    <pre cols="72"></pre>
  </div>

<br>_______________________________________________<br>
R-br mailing list<br>
<a href="mailto:R-br@listas.c3sl.ufpr.br">R-br@listas.c3sl.ufpr.br</a><br>
<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><br>
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.<br></blockquote></div><br></div>