similar to: Metropolis-Hastings within Gibbs coding error

Displaying 20 results from an estimated 1000 matches similar to: "Metropolis-Hastings within Gibbs coding error"

2007 Jun 06
1
Metropolis-Hastings Markov Chain Monte Carlo in Spatstat
I'm testing some different formulations of pairwise interaction point processes in Spatstat (version 1.11-6) using R 2.5.0 on a Windows platform and I wish to simulate them using the Metropolis-Hastings algorithm implemented with Spatstat. Spatstat utilizes Fortran77 code with the preprocessor RatFor to do the Metropolis-Hastings MCMC, but the Makefile is more complicated than any I have
2012 Mar 14
1
Metropolis-Hastings in R
Hi all, I'm trying to write a MH algorithm in R for a standard normal distribution, I've been trying for a good week or so now with multiple attempts and have finally given up trying to do it on my own as I'm beginning to run out of time for this, would somebody please tell me what is wrong with my latest attempt: n=100 mu=0 sigma=1 lik<-function(theta) exp(((theta-mu)^2)/2*sigma)
2004 Sep 01
3
coercing a string naming to a variable name and return value
Hi all, I haven't been able to find how to assess a variable who's name is constructed with paste. The problem is following: In a data frame, there are 12 columns whose title vary only by a digit, all other part being equal. I would like to compute a operation on a subset these variables and parse them in turn. the data frame "basin.param" contains columns called ratio1,
2013 Feb 01
2
How does this function print, why is n1 which equals 1 printed as 2?
Windows 7, R 2.12.1 Colleagues, I am trying to understand the n.for.2means function. The code below is a copy of the function (renamed to n.for.2means.js). I have inserted a single line of code towards the bottom of the function which uses the cat function to print the value of n1. You will note the value (preceded by stars) is printed as 1. The function (1) prints a lot of output without any
2008 Mar 26
0
Naive Gibbs Sampling with Metropolis Steps (pkg: gibbs.met)
Hi R Users: This package provides two generic functions for performing Markov chain sampling in a naive way for a user-defined target distribution, which involves only continuous variables. The function "gibbs_met" performs Gibbs sampling with each 1-dimensional distribution sampled with Metropolis update using Gaussian proposal distribution centered at the previous state. The function
2005 Dec 01
2
Minimizing a Function with three Parameters
Hi, I'm trying to get maximum likelihood estimates of \alpha, \beta_0 and \beta_1, this can be achieved by solving the following three equations: n / \alpha + \sum\limits_{i=1}^{n} ln(\psihat(i)) - \sum\limits_{i=1}^{n} ( ln(x_i + \psihat(i)) ) = 0 \alpha \sum\limits_{i=1}^{n} 1/(psihat(i)) - (\alpha+1) \sum\limits_{i=1}^{n} ( 1 / (x_i + \psihat(i)) ) = 0 \alpha \sum\limits_{i=1}^{n} (
2012 Nov 30
1
Example metropolis hasting
Hello all, could you tell where is an example of metropolis hasting? Thank you! Tania Sent from my iPod
2010 Oct 13
1
(no subject)
Dear all, I have just sent an email with my problem, but I think no one can see the red part, beacuse it is black. So, i am writing again the codes: rm(list=ls()) #remove almost everything in the memory set.seed(180185) nsim <- 10 mresultx <- matrix(-99, nrow=1000, ncol=nsim) mresultb <- matrix(-99, nrow=1000, ncol=nsim) N <- 200 I <- 5 taus <- c(0.480:0.520) h <-
2010 Oct 13
4
loop
Dear all, I am trying to run a loop in my codes, but the software returns an error: "subscript out of bounds" I dont understand exactly why this is happenning. My codes are the following: rm(list=ls()) #remove almost everything in the memory set.seed(180185) nsim <- 10 mresultx <- matrix(-99, nrow=1000, ncol=nsim) mresultb <- matrix(-99, nrow=1000, ncol=nsim) N
2006 Jul 20
1
Loss of numerical precision from conversion to list ?
I?m working on an R-implementation of the simulation-based finite-sample null-distribution of (R)LR-Test in Mixed Models (i.e. testing for Var(RandomEffect)=0) derived by C. M. Crainiceanu and D. Ruppert. I'm in the beginning stages of this project and while comparing quick and dirty grid-search-methods and more exact optim()/optimize()-based methods to find the maximum of a part of the
2010 Oct 07
3
quantile regression
Dear all, I am a new user in r and I am facing some problems with the quantile regression specification. I have two matrix (mresultb and mresultx) with nrow=1000 and ncol=nsim, where I specify (let's say) nsim=10. Hence, the columns in my matrix represents each simulation of a determined variable. I need to regress each column of mresultb on mresultx. My codes are the following:
2011 Nov 07
1
How do I return to the row values of a matrix after computing distances
## Package Needed library(fields) ## Assumptions set.seed(123) nsim<-5 p<-2 ## Generate Random Matrix G G <- matrix(runif(p*nsim),nsim,p) ## Set Empty Matraces dmax and dmin dmax<- matrix(data=NA,nrow=nsim,ncol=p) dmin<- matrix(data=NA,nrow=nsim,ncol=p) ## Loop to Fill dmax and dmin for(i in 1:nsim) { dmax[i]<- max(rdist(G[i,,drop=FALSE],G)) dmin[i]<-
2011 May 04
1
hurdle, simulated power
Hi all-- We are planning an intervention study for adolescent alcohol use, and I am planning to use simulations based on a hurdle model (using the hurdle() function in package pscl) for sample size estimation. The simulation code and power code are below -- note that at the moment the "power" code is just returning the coefficients, as something isn't working quite right. The
2011 Feb 17
1
How to speed up a for() loop
Dear all, Does anyone have any idea on how to speed up the for() loop below. Currently it takes approximately 2 minutes and 30 seconds. Because of the size of Nsim and N, simulating a multivariate normal (instead of simulating Nsim times a vector of N normal distributions) would require too much memory space. Many thanks for your kind help, Simona N=3000 PD=runif(N,0,1) cutoff.=qnorm(PD)
2008 Sep 12
1
Error in "[<-"(`*tmp*`, i, value = numeric(0)) :
I use "while" loop but it produces an errro. I have no idea about this. Error in "[<-"(`*tmp*`, i, value = numeric(0)) : nothing to replace with The problem description is The likelihood includes two parameters to be estimated: lambda (=beta0+beta1*x) and alpha. The algorithm for the estimation is as following: 1) with alpha=0, estimate lambda (estimate beta0
2008 Aug 22
2
WinBUGS with R
Dear Users, I am new to both of things, so do not blame me too much... I am busy with semiparametric regression and use WinBUGS to sample posteriors. The code to call Winbugs is as follows: data <- list("y","X","n","m") #My variables inits.beta <- rep(0,K) inits.beta0 <- 0 inits <-
2007 Oct 11
3
reason for error in small function?
Running the function below, tested using the cardiff dataset from splancs generates the following error. What changes do I need to make to get the function to work? Thanks. --Dale > gen.rpoints(events, poly, 99) > rpoints Error: object "rpoints" not found # test spatial data library(splancs) data(cardiff) attach(cardiff) str(cardiff) events <- as.points(x,y) ###
2015 Feb 02
2
Agregar variables
Hola a todos, a ver si me pueden echar una mano que estoy atascado.tengo estas dos tablas: > head (intento1)      codigo     categoria         talla             num1       1                904                400               12       1                904                460               13       1                904                470               44       1                904  
2006 Mar 08
1
power and sample size for a GLM with Poisson response variable
Craig, Thanks for your follow-up note on using the asypow package. My problem was not only constructing the "constraints" vector but, for my particular situation (Poisson regression, two groups, sample sizes of (1081,3180), I get very different results using asypow package compared to my other (home grown) approaches. library(asypow) pois.mean<-c(0.0065,0.0003) info.pois <-
2009 Sep 02
1
problem in loop
Hi R-users, I have a problem for updating the estimates of correlation coefficient in simulation loop. I want to get the matrix of correlation coefficients (matrix, name: est) from geese by using loop(500 times) . I used following code to update, nsim<-500 est<-matrix(ncol=2, nrow=nsim) for(i in 1:nsim){ fit <- geese(x ~ trt, id=subject, data=data_gee, family=binomial,