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 <alisson.lucrecio@ifgoiano.edu.br>:
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] <ml-node+s2285057n4663483h9@n4.nabble.com>:
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]> escreveu:
Victor,

Boa tarde.

Use o pacote rstan.

Att.


2014-11-08 12:53 GMT-02:00 Victor Eduardo [via R-br] <[hidden email]>:

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]
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



--
Alisson Lucrecio da Costa

_______________________________________________
R-br mailing list
[hidden email]
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]
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



--
Alisson Lucrecio da Costa



--
Alisson Lucrecio da Costa