[R-br] Erro ao rodar Wibugs/Openbugs

Victor Eduardo victorduca08 em gmail.com
Sábado Novembro 8 16:44:24 BRST 2014


Acredito que o JAGS também seja tão eficiente quanto o stan, até porque ele
é atual também. Ele rodou super rápido. Agora a luta aqui é a convergência
dos parâmetros. rs

Em 8 de novembro de 2014 16:32, Alisson Lucrécio <
alisson.lucrecio em ifgoiano.edu.br> escreveu:

> Lie a respeito deles há alguns meses, WinBugs, JAGS e Stan, não me lembro
> muito bem mais todos funcionam com MCMC. Tinha lido que o Rtan era mais
> eficiente que o WinBurgs pos tinha tido uma evolunção no amostradores de
> Gibbs. Entretanto, não sei se o Jags também teve essa evolução, mas todos
> fazem a mesma coisa, vc só tera uns 30 a 40 segundos a menos quando rodar o
> código.
>
> 2014-11-08 16:31 GMT-02:00 Alisson Lucrécio <
> alisson.lucrecio em ifgoiano.edu.br>:
>
>> Lie a respeito deles há alguns meses, WinBugs, JAGS e Stan, não me lembro
>> muito bem mais todos funcionam com MCMC. Tinha lido que o Rtan era mais
>> eficiente que o WinBurgs pos tinha tido uma evolunção no amostradores de
>> Gibbs. Entretanto, não sei se o Jags também teve essa evolução, mas todos
>> fazem a mesma coisa, vc só tera uns 30 a 40 segundos a menos quando rodar o
>> código.
>>
>> 2014-11-08 16:12 GMT-02:00 Victor Eduardo [via R-br] <
>> ml-node+s2285057n4663488h64 em n4.nabble.com>:
>>
>> Oi Alisson, fui experimentar o JAGS, conhece? Com os mesmos códigos de
>>> antes rodou normalmente o programa. Não sabia que o rbug era problemático,
>>> fiquei horas quebrando a cabeça para solucionar e nada.
>>>
>>> Aparentemente está tudo ok!
>>>
>>>
>>> O rstan não rodou de jeito nenhum aqui. Chegou a carregar o pacote pelo
>>> comando que me passou, mas na hora de rodar aquele exemplo começou a
>>> apresentar erro de funções não encontradas. Não sei se o problema foi no
>>> meu pc.
>>>
>>>
>>>
>>>
>>>
>>> Valeu pela ajuda
>>>
>>> Em 8 de novembro de 2014 15:54, Alisson Lucrécio <[hidden email]
>>> <http://user/SendEmail.jtp?type=node&node=4663488&i=0>> escreveu:
>>>
>>>> Victor,
>>>>
>>>> Minha sugestão é que vc sustituia o código rbug por rstan, o rbug é
>>>> muito problemático e ineficente, mande um CMR. Vc conseguiu rodar o rstar?
>>>>
>>>> Att.
>>>>
>>>> 2014-11-08 15:52 GMT-02:00 Alisson Lucrécio <[hidden email]
>>>> <http://user/SendEmail.jtp?type=node&node=4663488&i=1>>:
>>>>
>>>>> Victor,
>>>>>
>>>>> Minha sugestão é que vc sustituia o código rbug por rstan, o rbug é
>>>>> muito problemático e ineficente, mande um CRM. Vc conseguiu rodar o rstar?
>>>>> Att.
>>>>>
>>>>> 2014-11-08 15:38 GMT-02:00 Victor Eduardo [via R-br] <[hidden email]
>>>>> <http://user/SendEmail.jtp?type=node&node=4663488&i=2>>:
>>>>>
>>>>> Não rodou aqui. =/
>>>>>>
>>>>>> O erro que tinha incialmente eu consegui arrumar, só que agora surgiu
>>>>>> outro
>>>>>>
>>>>>> Error in handleRes(res) : NA
>>>>>>
>>>>>>
>>>>>> Só que não tem NA na minha base de dados
>>>>>>
>>>>>> 2014-11-08 14:10 GMT-02:00 Alisson Lucrécio <[hidden email]
>>>>>> <http://user/SendEmail.jtp?type=node&node=4663486&i=0>>:
>>>>>>
>>>>>>> Caro Victor,
>>>>>>>
>>>>>>> Se der certo teste esse exemplo.
>>>>>>>
>>>>>>> library(rstan)
>>>>>>>
>>>>>>> treatment_level <- c("0", "5", "10", "15")
>>>>>>> repetition_number <- 20
>>>>>>> response_mean <- c(100, 94, 88, 82)
>>>>>>>
>>>>>>> treatment <- gl(n = length(treatment_level), k = repetition_number,
>>>>>>> labels = treatment_level)
>>>>>>> str_error <- 2
>>>>>>>
>>>>>>> response_temp <- sapply(response_mean, function(x){
>>>>>>>   response <- rnorm(n = repetition_number, mean = x, sd = str_error)
>>>>>>> })
>>>>>>>
>>>>>>> response <- c(response_temp)
>>>>>>>
>>>>>>> plot(response ~ treatment)
>>>>>>>
>>>>>>> summary(lm(response ~ treatment -1))
>>>>>>>
>>>>>>> mean(response)
>>>>>>> sd(response)
>>>>>>>
>>>>>>> stan_data <- list(N = length(response), I = length(treatment_level),
>>>>>>> Treatment=as.numeric(treatment), Response = response)
>>>>>>>
>>>>>>> # Bayesian method for estimate mean and standard error by treatment
>>>>>>>
>>>>>>> stan_modelcode <- "
>>>>>>> data {                                    // data setup
>>>>>>>   int<lower=0> N;                         // sample size
>>>>>>>   int<lower=1> I;                         // number of treatments
>>>>>>>   real Response[N];                       // Response
>>>>>>>   int<lower=1, upper=I> Treatment[N];     // Treatment
>>>>>>> }
>>>>>>>
>>>>>>> parameters {
>>>>>>>   real mu[I];
>>>>>>>   real<lower=0, upper=100> sigma[I];
>>>>>>> }
>>>>>>>
>>>>>>> model {
>>>>>>>   //Priors
>>>>>>>   mu ~ normal(0, 100);
>>>>>>>   sigma ~ uniform(0, 100);
>>>>>>>   //Likelihood
>>>>>>>   for(i in 1:N) {
>>>>>>>     Response[i] ~ normal(mu[Treatment[i]], sigma[Treatment[i]]);
>>>>>>>   }
>>>>>>> }
>>>>>>> "
>>>>>>>
>>>>>>> fit <- stan(model_code = stan_modelcode, data = stan_data, iter =
>>>>>>> 1000, chains = 3,
>>>>>>>             verbose = TRUE)
>>>>>>>
>>>>>>> plot(fit)
>>>>>>>
>>>>>>> 2014-11-08 14:09 GMT-02:00 Alisson Lucrécio <[hidden email]
>>>>>>> <http://user/SendEmail.jtp?type=node&node=4663486&i=1>>:
>>>>>>>
>>>>>>> Use esse código.
>>>>>>>>
>>>>>>>> Sys.setenv(MAKEFLAGS = "-j4")
>>>>>>>> source('http://mc-stan.org/rstan/install.R', echo = TRUE,
>>>>>>>> max.deparse.length = 2000)
>>>>>>>> install_rstan()
>>>>>>>>
>>>>>>>> 2014-11-08 13:41 GMT-02:00 Victor Eduardo [via R-br] <[hidden
>>>>>>>> email] <http://user/SendEmail.jtp?type=node&node=4663486&i=2>>:
>>>>>>>>
>>>>>>>> Oi Alisson, o pacote deu erro para instalar. Tanto pelo arquivo
>>>>>>>>> quando pelo código install.packages
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Esse erro que está acontecendo comigo é no modelo? Porque
>>>>>>>>> aparentemente está tudo ok com ele.
>>>>>>>>>
>>>>>>>>> Em 8 de novembro de 2014 13:01, Alisson Lucrécio <[hidden email]
>>>>>>>>> <http://user/SendEmail.jtp?type=node&node=4663483&i=0>> escreveu:
>>>>>>>>>
>>>>>>>>>> Victor,
>>>>>>>>>>
>>>>>>>>>> Boa tarde.
>>>>>>>>>>
>>>>>>>>>> Use o pacote rstan.
>>>>>>>>>>
>>>>>>>>>> Att.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> 2014-11-08 12:53 GMT-02:00 Victor Eduardo [via R-br] <[hidden
>>>>>>>>>> email] <http://user/SendEmail.jtp?type=node&node=4663483&i=1>>:
>>>>>>>>>>
>>>>>>>>>> Pessoal, estou rodando um modelo de regressão pelo Openbugs. Na
>>>>>>>>>>> hora de rodar ele da o seguinte erro durante o processo
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Error in BRugs::samplesSet(parametersToSave) :
>>>>>>>>>>>   model must be initialized before monitors used
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> O que seria exatamente isso?  Já mexi em tudo quanto é
>>>>>>>>>>> configuração e código do meu modelo e nada até agora
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Atenciosamente,
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Victor Eduardo
>>>>>>>>>>>
>>>>>>>>>>> _______________________________________________
>>>>>>>>>>> R-br mailing list
>>>>>>>>>>> [hidden email]
>>>>>>>>>>> <http://user/SendEmail.jtp?type=node&node=4663480&i=0>
>>>>>>>>>>> https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br
>>>>>>>>>>> Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e
>>>>>>>>>>> forneça código mínimo reproduzível.
>>>>>>>>>>>
>>>>>>>>>>> ------------------------------
>>>>>>>>>>>  If you reply to this email, your message will be added to the
>>>>>>>>>>> discussion below:
>>>>>>>>>>>
>>>>>>>>>>> http://r-br.2285057.n4.nabble.com/R-br-Erro-ao-rodar-Wibugs-Openbugs-tp4663480.html
>>>>>>>>>>>  To unsubscribe from R-br, click here.
>>>>>>>>>>> NAML
>>>>>>>>>>> <http://r-br.2285057.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Alisson Lucrecio da Costa
>>>>>>>>>>
>>>>>>>>>> _______________________________________________
>>>>>>>>>> R-br mailing list
>>>>>>>>>> [hidden email]
>>>>>>>>>> <http://user/SendEmail.jtp?type=node&node=4663483&i=2>
>>>>>>>>>> https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br
>>>>>>>>>> Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e
>>>>>>>>>> forneça código mínimo reproduzível.
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> R-br mailing list
>>>>>>>>> [hidden email]
>>>>>>>>> <http://user/SendEmail.jtp?type=node&node=4663483&i=3>
>>>>>>>>> https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br
>>>>>>>>> Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e
>>>>>>>>> forneça código mínimo reproduzível.
>>>>>>>>>
>>>>>>>>> ------------------------------
>>>>>>>>>  If you reply to this email, your message will be added to the
>>>>>>>>> discussion below:
>>>>>>>>>
>>>>>>>>> http://r-br.2285057.n4.nabble.com/R-br-Erro-ao-rodar-Wibugs-Openbugs-tp4663480p4663483.html
>>>>>>>>>  To unsubscribe from R-br, click here.
>>>>>>>>> NAML
>>>>>>>>> <http://r-br.2285057.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Alisson Lucrecio da Costa
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Alisson Lucrecio da Costa
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> R-br mailing list
>>>>>>> [hidden email]
>>>>>>> <http://user/SendEmail.jtp?type=node&node=4663486&i=3>
>>>>>>> https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br
>>>>>>> Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e
>>>>>>> forneça código mínimo reproduzível.
>>>>>>>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> R-br mailing list
>>>>>> [hidden email] <http://user/SendEmail.jtp?type=node&node=4663486&i=4>
>>>>>> https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br
>>>>>> Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e forneça
>>>>>> código mínimo reproduzível.
>>>>>>
>>>>>> ------------------------------
>>>>>>  If you reply to this email, your message will be added to the
>>>>>> discussion below:
>>>>>>
>>>>>> http://r-br.2285057.n4.nabble.com/R-br-Erro-ao-rodar-Wibugs-Openbugs-tp4663480p4663486.html
>>>>>>  To unsubscribe from R-br, click here.
>>>>>> NAML
>>>>>> <http://r-br.2285057.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Alisson Lucrecio da Costa
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Alisson Lucrecio da Costa
>>>>
>>>> _______________________________________________
>>>> R-br mailing list
>>>> [hidden email] <http://user/SendEmail.jtp?type=node&node=4663488&i=3>
>>>> https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br
>>>> Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e forneça
>>>> código mínimo reproduzível.
>>>>
>>>
>>>
>>> _______________________________________________
>>> R-br mailing list
>>> [hidden email] <http://user/SendEmail.jtp?type=node&node=4663488&i=4>
>>> https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br
>>> Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e forneça
>>> código mínimo reproduzível.
>>>
>>> ------------------------------
>>>  If you reply to this email, your message will be added to the
>>> discussion below:
>>>
>>> http://r-br.2285057.n4.nabble.com/R-br-Erro-ao-rodar-Wibugs-Openbugs-tp4663480p4663488.html
>>>  To unsubscribe from R-br, click here
>>> <http://r-br.2285057.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3357982&code=YWxpc3Nvbi5sdWNyZWNpb0BpZmdvaWFuby5lZHUuYnJ8MzM1Nzk4MnwtNTI1NDI5NDE3>
>>> .
>>> NAML
>>> <http://r-br.2285057.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>>
>>
>>
>>
>> --
>> Alisson Lucrecio da Costa
>>
>
>
>
> --
> Alisson Lucrecio da Costa
>
> _______________________________________________
> R-br mailing list
> R-br em listas.c3sl.ufpr.br
> https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br
> Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e forneça
> código mínimo reproduzível.
>
-------------- Próxima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://listas.inf.ufpr.br/pipermail/r-br/attachments/20141108/0840b693/attachment.html>


Mais detalhes sobre a lista de discussão R-br