similar to: foreach loop - rejection method

Displaying 20 results from an estimated 500 matches similar to: "foreach loop - rejection method"

2012 Oct 04
2
Help with R Fitting an inverse Gamma
Dear all, I am new in R and would like to ask for someone's help in understanding where I go wrong with the following code: rm(list=ls()) # Required packages library(MCMCpack) # Simulated data set.seed(1) data = rinvgamma(n=250, shape = 5, scale = 2) + 2 hist(data) # log-likelihood ll = function(par){ if(par[1]>0 & par[2]>0 & par[3]<min(data)) return(
2009 Oct 04
1
multicore - no parallel
Hi everyone, Thanks for the help in advance. I just want to know if there is absolutely any way of using multicore if my loop can't run in parallel as each iteration depends on the previous iteration. I have Windows R 2.9.2 and REvolution R Enterprise 2.0 for Windows 64 bit. I also have if necessary R on Ubuntu. 8gb of ram and a core 2 duo processor but I could use a quad core as well. Many
2012 Jan 24
2
Writing a function to return column position XXXX
Hello everyone, I am writing my own function to return the column index of all variables (these are currently character vectors) in a data frame that contain a dollar sign($). A small piece of the data look like this: can_sta can_zip ind_ite_con ind_uni_con AL 36106 $251,895.80 $22,874.43 AL 35802 $141,373.60 $7,100.00 AL 35201 $273,208.50 $18,193.66 AR 72404 $186,918.00 $25,391.00 AR
2007 Dec 12
2
problem applying a conditional formula to each element of a matrix
I'm applying a function (Cov.f) defined below to each element of a distance matrix. When I run the code below, I get a warning message (below) and elements of returned matrix [2,3] and [3,2] are not zero as I would expect. Clearly, there is an error... What am I doing wrong? Thanks. --Dale Warning message: In if (h <= phi) { : the condition has length > 1 and only the first element
2005 Mar 07
3
R crashes using the em function of package mclust (PR#7719)
Hi, I got the same problem like http://tolstoy.newcastle.edu.au/R/devel/04/11/1204.html R crashes when I use the em function from the mclust package on univariate data and on a special case on bivariate data (when the matrix is not provided as written in the manual). It seems as if the problem is the format of the data to be analyzed. Operating System: Windows XP (SP2) R version: R-2.0.1 The
2012 Oct 11
2
survey package question
Hello, I have got a cluster sample using an election dataset where I already had the final results of a county-specific election. I am trying to figure out what would be the best sampling design for my data. The structure of the dataset is: 1) polling station (in general schools where people vote, for a county, for example, there are 15 polling stations) 2) inside each polling station, there
2005 Oct 21
1
finite mixture model (2-component gaussian): plotting component gaussian components?
Dear Knowledgeable R Community Members, Please excuse my ignorance, I apologize in advance if this is an easy question, but I am a bit stumped and could use a little guidance. I have a finite mixture modeling problem -- for example, a 2-component gaussian mixture -- where the components have a large overlap, and I am trying to use the "mclust" package to solve this problem. I need
2011 Jan 13
1
Fitting an Inverse Gamma Distribution
http://r.789695.n4.nabble.com/file/n3216865/Inverse_Gamma.png Hello, I am seeking help in estimating the parameters of an inverse gamma distribution (from the 'actuar' package) using a function like 'fitdistr'. Unfortunately I haven't found such a package using findFn('fit Inverse Gamma') from the 'sos' package and was therefore hoping someone might be aware
2007 Mar 07
2
Power calculation for detecting linear trend
Dear people, I've a problem in doing a power calculation. In Fryer and Nicholson (1993), ICES J. mar. Sci. 50: 161-168 page 164 an example is given with the following characteristics T=5, points in time R=5, replicates Var.within=0.1 q=10, a 10% increase per year The degrees of freedom for the test are calculated as Vl=T*R-2=23 and the non-centrality parameter Dl=4.54. Using this they get a
2010 Apr 29
2
dopar parallel assignments
Hi guys, I was wondering why this piece of code doesn't work: foreach (i = c(1.25,1.50)) %dopar% { assign(paste("test_",i,sep=""),i) } but, this does: foreach (i = c(1.25,1.50)) %do% { assign(paste("test_",i,sep=""),i) } Obviously, the difference is %dopar% vs. %do%. If I use %do%, I get objects test_1.25 and test_1.50, but I don't get these
2012 Feb 18
3
foreach %do% and %dopar%
Hi everyone, I'm working on a script trying to use foreach %dopar% but without success, so I manage to run the code with foreach %do% and looks like this: The code is part of a MCMC model for projects valuation, returning the most important results (VPN, TIR, EVA, etc.) of the simulation. foreach (simx = NsimT, .combine=cbind, .inorder=FALSE, .verbose=TRUE) %do% { MCPVMPA = MCVAMPA[simx]
2011 Sep 04
2
mclust: modelName="E" vs modelName="V"
Hi, I'm trying to use the library mclust for gaussian mixture on a numeric vector. The function Mclust(data,G=3) is working fine but the fitting is not optimal and is using modelNames="E". When I'm trying Mclust(data,G=3,modelName="V") I have the following message: Error in if (Sumry$G > 1) ans[c(orderedNames, "z")] else ans[orderedNames] : argument is
2007 Oct 10
11
please help me
dear list I am student M.S. statistics in department statistics . I am working in the function "nls" in the [R 2.3.1] with 246 data and want to fit the "exp" model to vectors( v and u ) but I have a problem to use it u 5.000000e-13 2.179057e+03 6.537171e+03 1.089529e+04 1.525340e+04 1.961151e+04 2.396963e+04 2.832774e+04 3.268586e+04 3.704397e+04 4.140209e+04
2011 Jul 12
2
foreach not recognizing functions in memory
All, I am not understanding the scoping used in foreach when it is used inside a function. I keep getting "could not find function" errors for functions that are in memory when I try to use foreach within a function call. I have a simple example below. "testFun" is in memory and works when called by foreach directly, but when I place foreach in a function called
2017 Jun 13
1
fedback from foreach
Hi useRs, I am running a foreach loop and hoped to get a small message when it hits a multiple of 1000, but it does not work. p <- foreach(i=1:10000, .combine='c') %dopar% { if(i%%1000==0) print(i) sqrt(i) } What is the proper way to do it. Thanks everybody. Stephen B [[alternative HTML version deleted]]
2011 Feb 08
3
Parallel processing question ...
I am experimenting with parallel processing using foreach and seem to be missing something fundamental. Cool stuff. I've gone through the list and seen a couple of closely related issues, but nothing I've tried seems to work. I know that the results from foreach are combined, but what if there is more than one variable within the loop? Below is a snippet (non-functioning) of code that I
2015 Mar 05
3
Submit a package which use doParallel
Hi, I'm trying to submit my first package which depends on doParallel: Depends: R (>= 3.0), igraph, doParallel Running hadley devtools: devtools::check() and devtools::release() result in no problem (no ERROR nor NOTE on Linux, Mac and Windows). However, when in use the devtools::build_win() command, it results in the following note: * checking R code for possible problems ... NOTE
2012 Sep 21
2
Parallel Programming
I am trying to do parallel programming and I tried this library(doSNOW) library(foreach) testfunc<-function(x){ x<-x+1 x } noc<-2 cl <- makeCluster(do.call(rbind,rep(list("localhost"),noc)), type = "SOCK") registerDoSNOW(cl) clusterExport(cl=cl,c("testfunc.r")) testl<-foreach(pp=1:2) %dopar% { testfunc(pp) } And this works but if I try to
2007 May 26
1
Why ?rmvnorm not working
Hi, My R version is 2.4.1 and I installed the the packages MASS and run command library("MASS"), however when I type ?rmvnorm, no help topic found, it worked before. I tried to ype ?rinvgamma from "MCMCpack" which works great. Anybody have idea? I also reinstalled MASS package, but when I try to type rmvnorm(), no functions found. Pat
2015 May 11
1
Foreach %dopar% operator incorrectly load balancing
Dear R-SIG-Debian, I am using R version 3.1.2 with rstudio-server 0.98.113 on debian build 3.2.0-4-amd64 #1 SMP Debian 3.2.68-1+deb7u1 x86_64 GNU/Linux. I often use the %dopar% operator in from the foreach package to run code in parallel. However, the only other use on the box seemingly installed a few items and suddenly %dopar% will use far more than the number of cores I am specifying and