search for: dunif

Displaying 20 results from an estimated 64 matches for "dunif".

Did you mean: runif
2011 Nov 07
2
Dunif and Punif
Hi, I am trying to use dunif and runif however, I have two problems: if I do dunif(1:10, min=1, max=10) I get 10 values, which summed give me 1.1111 I understand that the probability is computed as f(x) = 1 / (max-min) but in this case it looks wrong: I have 10 values, each one equiprobable, and the probability for each one...
2008 Dec 15
3
R2winbugs : vectorization
...censored regressions, the first is essentially a copy of code in Gelman+Hill): ===================== model 1 : 4 separate a's model{ for (i in 1:n){ z.lo[i]<- C * equals(y[i],C) z[i]~dnorm(z.hat[i],tau.y)I(z.lo[i],) z.hat[i]<-a1*x[i,1]+a2*x[i,2]+a3*x[i,3]+a4*x[i,4] } a1~dunif(0,100) a2~dunif(0,100) a3~dunif(0,100) a4~dunif(0,100) tau.y<-pow(sigma.y,-2) sigma.y~dunif(0,100) } ============== model 2 : vector of a's model{ for (i in 1:n){ z.lo[i]<- C * equals(y[i],C) z[i]~dnorm(z.hat[i],tau.y)I(z.lo[i],) z.hat[i]<-inprod(a[],x[i,]) } for (j...
2008 Jul 23
1
R2WinBUGS problem
...t wishes Troels cat(" model { for (i in 1:126) { dep[i] ~ dnorm(mu.dep[i],tau.dep) mu.dep[i] <- alpha[ID[i]]*NAK.cor[i]+beta[ID[i]]*TBW.cor[i] fit[i] <- mu.dep[i]+CONST[i] } tau.dep <- pow(sigma_dep,-2) sigma_dep ~ dunif(0,100) for (j in 1:16) { alpha[lev[j]] <- AB[lev[j],1] beta[lev[j]] <- AB[lev[j],2] AB[lev[j],1:2] ~ dmnorm(AB.hat[lev[j],],tau.AB[,])I(lower[], upper[]) AB.hat[lev[j],1] <- mu.alpha AB.hat[lev[j],2] <- mu.beta }...
2010 Oct 15
1
Problem using BRugs
...])<- rho_o * woy[i] + rho_d * wdy[i] + rho_w * wwy[i] + beta[1] + beta[2] * cap2[i] + beta[3] * pol2[i] + beta[4] * cap1[i] + beta[5] * pol1[i] + beta[6] * g[i]+ e[i] } # Priors for (j in 1:6) { beta[1:6] ~ dmnorm(mu[1:6], tau[1:6, 1:6]) } rho_o ~ dunif(-1,1) rho_d ~ dunif(-1,1) rho_w ~ dunif(-1,1) for (i in 1:676) { e[i] ~ dnorm(0, 1) } } [[alternative HTML version deleted]]
2010 May 06
1
BRugs dwwinn.exe error
...end. If I use a simple model with data and initial values bugs() works fine. So, I have to assume that there is something in my model which is not compatible with bugs(). The model is: ------------------------------------- model generateStartingValues { for (s in 1:Datasets) { lambda[s]~dunif(0.1,0.9) for (i in 1:K){ eltheta[s,i]~dunif(0.1,0.3) q[s,i]~dunif(0.1,0.4) } } } ------------------------------------- DATA list(K=19,Datasets=500) As I said this works fine with openBUGS and WinBUGS. I start BUGS from R-Console with ----...
2010 Aug 10
0
Error in R2Bugs
...s.plt[s] ~ dnorm(0.0, tau.plt)} for(k in 1:n.sp){eps.sp[k] ~ dnorm(0.0, tau.sp)} b.lev~dnorm(0, 0.01) b.light~dnorm(0, 0.01) b.con~dnorm(0,0.01) b.s1~dnorm(0, 0.01) b.s2~dnorm(0, 0.01) b.s3~dnorm(0, 0.01) b.dcon~dnorm(0, 0.01) tau.ind~dunif(0,100) sigma.ind<-1/sqrt(tau.ind) tau.plt ~ dunif(0,100) sigma.plt<-1/sqrt(tau.plt) tau.sp ~ dunif(0,100) sigma.sp<-1/sqrt(tau.sp) tau ~ dunif(0,100) sigma.sppl<-1/sqrt(tau) #sd of species x plot random effect } ----------------------------------------- Jo...
2009 Jul 16
1
Error with r2winbugs
.../sus.bug" model { for (i in 1:n){ y[i] ~ dpois(lamdba[i]) log(lambda[i]) <- mu+bmale[male[i]]+bschn[schn[i]]+epsilon[i] # epsilon[i] ~ dnorm(0,tau.epsilon) } mu ~ dnorm(0,.0001) bmale ~ dnorm(0,.0001) tau.epsilon <- pow(sigma.epsilon, -2) sigma.epsilon ~ dunif(0,100) for (j in 1:n.schn){ bschn[j] ~ dnorm(0,tau.schn) } tau.schn <- pow(sigma.schn, -2) sigma.schn ~ dunif(0,100) } I am running the following syntax: enroll.wide.m <- na.omit(enroll.wide) n <- nrow(enroll.wide.m) y <- enroll.wide.m$sus.5 sch <- as.vector(enroll...
2009 Mar 14
0
[multi-level model] set up categorical variable/indicator?
...bugs as: model{ for (i in 1:n){ y[i] ~ dnorm(y.hat[i], tau.y) y.hat[i] <- alpha[region[i]] + beta[county[i]]*bsmt[i] } for (j in 1:J){ alpha[j] ~ dnorm(mu.alpha[j], tau.alpha) } for (k in 1:K){ beta[k] ~ dnorm(mu.beta[k], tau.beta) } mu.y ~ dnorm(0, .0001) tau.y <- pow(sigma.y, -2) sigma.y ~ dunif(0, 100) mu.alpha ~ dnorm(0, .0001) mu.beta ~ dnorm(0, .0001) tau.alpha <- pow(sigma.alpha, -2) sigma.alpha ~ dunif (0, 100) tau.beta <- pow(sigma.beta, -2) sigma.beta ~ dunif(0, 100) } but my Bugs crashed because it couldn't read "region" data, and as I checked out my "reg...
2009 Aug 15
1
Filling in a uniform dist plot
Hi all, Apologies in advance if this is really too simple, but I have given a good shot at this. I'm generating a standard uniform distibution y <- dunif(x) plot(x,y,type="l") This will draw a horizontal line at y = 1. I want to fill the area from x=(0,1) with a color. I've tried the polygon command to create a polygon of the same shape, but can't seem to set the parameters to fill the figure from x=(0,1). I'm sure there...
2017 Jun 04
0
Hlep in analysis in RWinBugs
...*S1*m1 a21[i]<-sm[i]*S1*(1-m1)*S2*m2 a31[i]<-sm[i]*S1*(1-m1)*S2*(1-m2)*S3 sum[i]<-a11[i]+a21[i]+a31[i] } #priors #priors are dbeta(0.5,0.5), uniform is dbeta(1,1) S1~dbeta(1,1)#I(0,0.2) # S2~dbeta(1,1)#I(0.15,0.5) # S3~dbeta(1,1)#I(0.3,1) m1~dbeta(1,1)#I(0.01,1) m2~dbeta(1,1)#I(0,1) sd ~ dunif(0,100) sd1 ~ dunif(0,100) sd2 ~ dunif(0,100) tau <- 1/(sd*sd) tau1 <- 1/(sd1*sd1) tau2 <- 1/(sd2*sd2) } model.file <- Model file.show(model.file) #The Data list(N = 4, sm=c(9309,3253,5292,1361), a1=c(16,3,4,2), a2=c(96,31,42,3), a3=c(47,5,18,1)) inits <- function(){ list(sd = 1000,...
2017 Jun 04
0
Help in analysis in RWinBugs
...*S1*m1 a21[i]<-sm[i]*S1*(1-m1)*S2*m2 a31[i]<-sm[i]*S1*(1-m1)*S2*(1-m2)*S3 sum[i]<-a11[i]+a21[i]+a31[i] } #priors #priors are dbeta(0.5,0.5), uniform is dbeta(1,1) S1~dbeta(1,1)#I(0,0.2) # S2~dbeta(1,1)#I(0.15,0.5) # S3~dbeta(1,1)#I(0.3,1) m1~dbeta(1,1)#I(0.01,1) m2~dbeta(1,1)#I(0,1) sd ~ dunif(0,100) sd1 ~ dunif(0,100) sd2 ~ dunif(0,100) tau <- 1/(sd*sd) tau1 <- 1/(sd1*sd1) tau2 <- 1/(sd2*sd2) } model.file <- Model file.show(model.file) #The Data list(N = 4, sm=c(9309,3253,5292,1361), a1=c(16,3,4,2), a2=c(96,31,42,3), a3=c(47,5,18,1)) inits <- function(){ list(sd = 1000,...
2012 Oct 26
1
Openbugs- Array Index
...ects for each functional group for(i in 1:g){ # number of functional group for(j in 1:2){ # number of habitat type mu.h[i,j] ~ dnorm(0,0.0001) I(-2,2) # filling mu.h with values based on a random distribution sigma.h[i,j] ~ dunif(0,6) tau.h[i,j] <- 1/(sigma.h[i,j]*sigma.h[i,j]) } } # detectability mu.r ~ dnorm(0,0.0001) I(-3,3) sigma.r ~ dunif(0,6) tau.r <- 1/(sigma.r*sigma.r) psi ~ dunif(0,1)# inclusion rate that generates wi # proportion of number of species among groups for(i in 1:g){ prop[i] ~ dgamma(1,1) prob[...
2010 Aug 02
2
Including a text file (JAGS model) in an R package
Hello, I can`t figure out how to include a text file for use in an example in the .Rd help files of an R package I am writing. I want the examples section of one help file to look like this: \examples{ # Load the JAGS model mod <- jags.model("model.txt") } The function jags.model tries to read in the file model.txt. So far every time I run R CMD check, I get an error message:
2008 Aug 21
1
pnmath compilation failure; dylib issue?
...fined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/ lib -o pnmath.so bd0.o beta.o chebyshev.o choose.o d1mach.o dbeta.o dbinom.o dcauchy.o dchisq.o dexp.o df.o dgamma.o dgeom.o dhyper.o dlnorm.o dlogis.o dnbeta.o dnbinom.o dnchisq.o dnf.o dnorm.o dnt.o dpois.o dt.o dunif.o dweibull.o fmax2.o fmin2.o ftrunc.o gamma.o gamma_cody.o i1mach.o imax2.o imin2.o lbeta.o lgamma.o lgammacor.o mlutils.o pbeta.o pbinom.o pcauchy.o pchisq.o pexp.o pf.o pgamma.o pgeom.o phyper.o plnorm.o plogis.o pnbeta.o pnbinom.o pnchisq.o pnf.o pnmath.o pnorm.o pnt.o polygamma.o ppois....
2013 Mar 28
3
problem with plots with short example.
...# ### code chunk number 5: exchange ################################################### hier.mod <- "model{ for(i in 1:N){ y[i] ~ dnorm(mu[numstate[i]], tau[numstate[i]]) } for(j in 1:J){ mu[j] ~ dnorm(theta,nu) tau[j] ~ dgamma(a,b) } theta ~ dnorm(0,.01) nu ~ dgamma(.1,.1) a ~ dunif(0,1000) b ~ dunif(0,1000) }" hier.out <- run.jags(hier.mod, data=dat, burnin=10000, sample=100000, thin=10, monitor=c("mu", "tau", "theta", "nu", "a", "b"), monitor.deviance=T, monitor.pd=T, silent.jags=T) ##############...
2012 May 23
1
how a latent state matrix is updated using package R2WinBUGS
...0 0 0 0 1 [9,] 0 0 0 0 0 [10,] 0 0 0 0 0 model { # Priors and constraints for (i in 1:nind){ for (t in f[i]:(n.occasions-1)){ phi[i,t] <- mean.phi p[i,t] <- mean.p } #t } #i mean.phi ~ dunif(0, 1) # Prior for mean survival mean.p ~ dunif(0, 1) # Prior for mean recapture # Likelihood for (i in 1:nind){ # Define latent state at first capture z[i,f[i]] <- 1 for (t in (f[i]+1):n.occasions){ # State process z[i,t] ~ dbern(mu1[i...
2009 Dec 03
2
Help R2WinBUGS
...beta.x*x[i] + beta.eco[2]*D.eco2[i] + beta.eco[3]*D.eco3[i] } # beta.eco[1] <- 0 # priors beta.0 ~ dnorm (0, 0.0001) beta.x ~ dnorm (0, 0.0001) for (j in 2:J){ beta.eco[j] ~ dnorm (0, 0.0001) } tau.y <- pow(sigma.y, -2) sigma.y ~ dunif (0, 100) } DATA list(N=18, J=3, x = c(0.2, 1.1, 1, 2.2, 2.5, 2.9, 2.9, 3.6, 3.8, 0.6, 1, 2, 2.4, 2.6, 2.8, 3.2, 3.9, 3.5), y = c(0.5, 1.3, 0.1, 0.7, -0.4, 0.5, -0.9, -0.3, -0.3, 0.6, 0.4, 0.9, -0.1, -0.4, -0.5, -0.2, 0.3, -1.5), eco = c(1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 1, 3, 2, 3, 2, 2,...
2012 Jul 13
3
Help with R2 OpenBUGs
...ork/PTY Project/Waterhole Correction/ungulate.txt") cat(" model{ # hyperparameters # habitat effects for each functional group g <- length(table(G)) for(i in 1:g){ # number of functional group for(j in 1:3){ # number of habitat type mu.h[i,j] ~ dnorm(0,0.0001) I(-5,5) sigma.h[i,j] ~ dunif(0,5) tau.h[i,j] <- 1/(sigma.h[i,j]*sigma.h[i,j]) } } # detectability mu.r ~ dnorm(0,0.0001) I(-5,5) sigma.r ~ dunif(0,5) tau.r <- 1/(sigma.r*sigma.r) psi ~ dunif(0,1) # inclusion rate that generates wi # proportion of number of species among groups for(i in 1:g){ prop[i] ~ dgamma(1,1)...
2008 Oct 19
0
Kullback Leibler Divergence
Hi there, I'm trying to find the KL divergence measure between a prior and it's posterior distributions, and I'm using the KLdiv method in the flexmix package. plese see the example below: require(flexmix) x=seq(-4,4,length=100) d1=dnorm(x,0,1) d2=dunif(x,-3,3) y=cbind(d1,d2) kl=KLdiv(y) but let say, x1=seq(-5,5,length=100) d3=dunif(x1,-3,3) y1=cbind(d1,d3) kl1=KLdiv(y1) Notice that kl1 and kl are not the same. the documentation for the package doesn't mention to evaluate the densities at the same points. which one is correct? do I need to...
2007 May 14
1
Hierarchical models in R
Is there a way to do hierarchical (bayesian) logistic regression in R, the way we do it in BUGS? For example in BUGS we can have this model: model {for(i in 1:N) { y[i] ~ dbin(p[i],n[i]) logit(p[i]) <- beta0+beta1*x1[i]+beta2*x2[i]+beta3*x3[i] } sd ~ dunif(0,10) tau <- pow(sd, -2) beta0 ~ dnorm(0,0.1) beta1 ~ dnorm(0,tau) beta2 ~ dnorm(0,tau) beta3 ~ dnorm(0,tau) } where we put a prior on the parameters betas, but the sd of the priors is determined along with the parameters in a full bayesian model. I know that there are...