search for: posterior

Displaying 20 results from an estimated 373 matches for "posterior".

2010 Jul 18
2
loop troubles
...ecision (I add precision manually because I want it to be zero but if I include zero as prior variance I get an error cant divide by zero. Now my question is instead of having the three iterations below, is there anyway to create a loop, the only problem is I want to have elements from the previous posterior to be the new prior and now I cant figure out how to do the code below in a loop. The data below is dummy data, I used a starting mu of 1, and starting precision of 0. bayes.analysis.treat<-function(mu0,p0){ n1 = 5 n2 = 10 n3 = 15 ybar1 = 12 ybar2 = 13 ybar3 = 14 sd1 = 2 sd2 = 3 sd3...
2012 Aug 05
1
Possible bug with MCMCpack metropolis sampler
Hi, I'm having issues with what I believe is a bug in the MCMCpack's MCMCmetrop1R function. I have code that basically looks like this: posterior.sampler <- function(data, prior.mu){ log.posterior <- function(theta) log.likelihood(data, theta) + log.prior(prior.mu, theta) post.samples <- MCMCmetrop1R(log.posterior, theta.init=prior.mu, burnin=100, mcmc=1000, thin=40, tune=1, verbose=0, logfun=T, optim.method="BFGS")...
2004 Jan 23
1
predict.lda problem with posterior probabilities
With predict.lda the posterior probabilities only relate to the existing Class definitions. This is fine for Class definitions like gender but it is a problem when new data does not necessarily belong to an existing Class. Is there a classification method that gives posterior probabilities for Class membership and does not assu...
2006 Dec 05
3
Comparing posterior and likelihood estimates for proportions (off topic)
This question is slightly off topic, but I'll use R to try and make it as relevant as possible. I'm working on a problem where I want to compare estimates from a posterior distribution with a uniform prior with those obtained from a frequentist approach. Under these conditions the estimates should agree. Specifically, I am asking the question, "What is the probability that the true proportion of students passing a test is 50% when the observed proportion for th...
2008 Dec 31
3
WinBUGS posterior samples (via R2WinBUGS)?
Hi all, I did some analysis using package R2WinBUGS to call WinBUGS. I set the iterations to 50000 (fairly a large number, I think), but after the program was done, the effective posterior samples contained only 7 draws. I don't know why. By the way, I checked posterior sample size by using bugsobj$n.sims. And, for my previous practice with WinBUGS/R2WinBUGS, no such strange thing happend. Does anybody have some idea on what might be wrong with my model or whatever part in this...
2008 Sep 27
0
compute posterior mean by numerical integration
Dear R useRs, i try to compute the posterior mean for the parameters omega and beta for the following posterior density. I have simulated data where i know that the true values of omega=12 and beta=0.01. With the function postMeanOmega and postMeanBeta i wanted to compute the mean values of omega and beta by numerical integration, but inst...
2004 Feb 16
0
How do we obtain Posterior Predictive (Bayesian) P-values in R (a sking a second time)
...lue) in R from the chain I obtained from the Gibbs sampler? I have a matrix 'samp' [10,000x86] where I stored the result of each of the 10,000 iterations of the 86 variables of interest. Something I want to add is that Gelman also states that "...in practice, we usually compute the posterior predictive distribution using simulation. If we already have L simulations from the posterior density of theta, we just draw one y_rep from the predictive distribution for each simulated theta; we now have L draws from the joint posterior distribution, p(y_rep,theta|y). The posterior predictive che...
2007 Apr 03
1
Calculating DIC from MCMC output
...ts, and I'm trying to calculate the Deviance Information Criterion "by hand" from some MCMC output. However, having consulted several sources, I am left confused as to the exact terms to use. The most common formula can be written as DIC = 2*Mean(Deviance over the whole sampled posterior distribution) - Deviance(Mean posterior parameter values) However, I have also seen this as DIC = 2*Mean(Deviance over the whole sampled posterior distribution) - Min(Deviance over the whole sampled posterior) Now, my understanding is that for some distributions, the deviance at the parame...
2013 Feb 18
1
compare posterior samples from R2OpenBugs and R function bugs{R2WinBUGS}
Hi all, I used both OpenBugs and R function bugs{R2WinBUGS} to run a linear mixed effects model based on the same data set and initial values. I got the same summary statistics but different posterior samples. However, if I order these two sets of samples, one is generated from OpenBugs and the other is generated from R, they turn to be the same. And the samples from R do not have any autocorrelation. I do not know why and how this R function destroy the orders of posterior samples. Have anyone...
2007 Jan 26
1
Bayesian inference: Poisson distribution with normal (!) prior
...rted with the subsequent two functions to obtain random numbers for Lambda after the first observed period. My question is now, how to get the randoms for the n following periods? Thanks a lot for your hints! Maybe there is an easier way to do the necessary calculations...? Carsten # Function 1: Posterior for the first observation test.posterior=function(x,observation,p1,p2) { f1=function(x,observation,p1,p2) dpois(observation,qnorm(pnorm(x,p1,p2),p1,p2))*dnorm(x,p1,p2) integral=integrate(f1,0,Inf,p1=p1,p2=p2,observation=observation)$value ausgabe=f1(x,observation,p1=p1,p2=p2)/integral return(ausgab...
2013 May 08
1
How to calculate Hightest Posterior Density (HPD) of coeficients in a simple regression (lm) in R?
Hi! I am trying to calculate HPD for the coeficients of regression models fitted with lm or lmrob in R, pretty much in the same way that can be accomplished by the association of mcmcsamp and HPDinterval functions for multilevel models fitted with lmer. Can anyone point me in the right direction on which packages/how to implement this? Thanks for your time! R. [[alternative HTML version
2010 Sep 30
1
Accessing Vector of A Data Frame
I have a variable that looks like this: > print(pred$posterior) o x 1 2.356964e-03 9.976430e-01 2 8.988153e-01 1.011847e-01 3 9.466137e-01 5.338627e-02 4 2.731429e-11 1.000000e+00 Now what I want to do is to access "o" and "x" How come this approach fail? > print(pred$posterior$o) or >...
2012 Dec 18
1
multi dimensional optim problem
I am attempting to use optim to solve a neural network problem. I would like to optimize coefficients that are currently stored in a matrix Y=270 x 1 X= 27- x 14 b1= 10x14 b2= 11x1 V= 10 x 14 set of prior variances. I have the following function: posterior.mode1=function(y,X,b_0,b2,V) { log.like=function(b1) { a_g=compute(b1) z_g=tanh(a_g); z_g=cbind(1,z_g) p=softmax(z_g%*%b2); a=sum(y*log(p)+(1-y)*log(1-p)); return(a); } compute=function(b1) { a_g=NULL; for(i in 1:nrow(b1)){ a_g=cbind(a_g,X%*%b1[i,])...
2008 Dec 05
0
making sense of posterior statistics in the deal package
Hello, I'm doing bayesian network analyses with the deal package. I am at a loss for how to interpret output from the analysis (i.e. what is a good score, what is a bad score, which stats tell me what about the network edges/nodes). Here is an example node with its posterior scores for all parent nodes. ------------------------------------------------------------ Conditional Posterior: Yp1| 3 4 5 6 9 11 12 15 18 [[1]] [[1]]$tau [,1] [,2] [,3] [,4] [,5] [,6] [1,] 138.0000000 -201.944190 -61.827901 -29.5419149...
2006 Apr 12
3
[Q] Bayeisan Network with the "deal" package
Dear R-users I am looking for a help in using the "deal" package. I followed the manual and paper from the author's web site to learn it, as shown below, but I could not figure out how to access the local and posterior probability of the nodes in the constructed network. library(deal) data(ksl) ksl.nw <- network(ksl) ksl.prior <- jointprior(ksl.nw) banlist <- matrix(c(5,5,6,6,7,7,9, 8,9,8,9,8,9,8), ncol = 2) ksl.nw$banlist <- banlist ksl.nw <- learn(ksl.nw, ksl, ksl.prio...
2011 Dec 03
2
density function always evaluating to zero
Dear R users, I'm trying to carry out monte carlo integration of a posterior density function which is the product of a normal and a gamma distribution. The problem I have is that the density function always returns 0. How can I solve this problem? Here is my code #generate data x1 <- runif(100, min = -10, max = 10) y <- 2 * x1^2 + rnorm(100) # # # # # # # # Model...
2004 Jul 13
1
lda() - again.
Hi. I asked a question about lda() and got some answers. However, one question remains (which is not independent of the earlier ones): What output does lda() produce which I can use to compute the posteriors? I know predict(lda())$posterior will give me precisely the posteriors, but suppose I'd like to compute them myself, outside of R. So far, I have not been able to use "coefficients of linear discrimiants" to do this, for they don't seem to be the alpha and beta in log(post...
2006 Nov 19
0
posterior probability formula in predict.lda
...all, have a dataset with rows as plots and environmental data as columns. I have predicted the values using the following ed.pred<-predict(lda.ed,ed) #lda.ed the model, ed the env. variables used for the prediction plots I am wanting to know the formula used by predict.lda for calculating the posterior probabilities. Can anyone point me in the right direction? Thanks
2008 Jan 24
0
posterior probability in finite mixture
Dear All, This is a question somewhat off-topic. Say, if I have known the number of components in the mixture, all the estimated parameters, prior probabilities, and so on for a finite mixture model, how might I compute the posterior probabilities of each case for a new dataset without observed response (Y)? I want to know the parametric form of such calculation such that I can calculate it manually in excel or sql. Thank you so much! -- =============================== WenSui Liu Statistical Project Manager ChoicePoint Preci...
2010 Aug 09
1
creating pdf of wireframe
...ey for better visibility trellis.device(pdf,file="PostAll.pdf", width = 5, height = 5) trellis.par.set("plot.line", list(lwd=0.15)); top.left <- wireframe(post1, xlab=list("p(adj-N)", cex=.7, rot=30),ylab=list("p(num-N)", cex=.7, rot=-45),zlab=list("posterior", cex=.7, rot=90),col.regions=newcols(100), drape=TRUE,colorkey=TRUE, lwd=0.15, zoom=1, scales = list(z = list(distance = 0.5), x = list(distance = 0.5), y = list(distance = 0.5))); top.right <- wireframe(post2, xlab=list("p(adj-N)", cex=.7, rot=30),ylab=list("p(num-N)"...