similar to: Simulation based on runif to get mean

Displaying 20 results from an estimated 10000 matches similar to: "Simulation based on runif to get mean"

2018 Jan 30
0
Simulation based on runif to get mean
On 1/29/2018 9:03 PM, smart hendsome via R-help wrote: > Hello everyone, > I have a question regarding simulating based on runif.? Let say I have generated matrix A and B based on runif. Then I find mean for each matrix A and matrix B.? I want this process to be done let say 10 times. Anyone can help me.? Actually I want make the function that I can play around with the number of simulation
2018 Jan 30
1
Simulation based on runif to get mean
Hello, Another way would be to use ?replicate and ?colMeans. set.seed(2511) # Make the results reproducible fun <- function(n){ f <- function(){ a <- runif(5, 1, 10) b <- runif(5, 10, 20) colMeans(cbind(a, b)) } replicate(n, f()) } fun(10) Hope this helps, Rui Barradas On 1/30/2018 8:58 AM, Daniel Nordlund wrote: > On 1/29/2018
2018 Jan 30
0
Simulation based on runif to get mean
Hello, Right. Missed that one. Rui Barradas Enviado a partir do meu smartphone Samsung Galaxy.-------- Mensagem original --------De: Eric Berger <ericjberger at gmail.com> Data: 30/01/2018 10:12 (GMT+00:00) Para: Rui Barradas <ruipbarradas at sapo.pt> Cc: Daniel Nordlund <djnordlund at gmail.com>, smart hendsome <putra_autumn86 at yahoo.com>, r-help at r-project.org
2018 Jan 29
2
Result show the values of fitting gamma parameter
Hi, Let say I have data by two columns A and B, and I have fit each column using the gamma distribution by 'fitdist' . I just want the result show only the shape and rate only. Eg: library(fitdistrplus) A <-c(1,2,3,4,5) B<-c(6,7,8,9,10) C <-cbind(A,B) apply(C, 2, fitdist, "gamma") Output show like this: $A Fitting of the distribution ' gamma ' by maximum
2018 May 27
1
if else with 4 conditions problem
Hi everyone, I have two columns: ? ?A? ? ? ? ? ? ? ?B ? ?1? ? ? ? ? ? ? ?1? ?1? ? ? ? ? ? ? ?0 ? ?0? ? ? ? ? ? ? ?1 ? ?0? ? ? ? ? ? ? ?0 I have 4 categories which are: 1) if A = 1 and B =1 then A1 = 1, else A2 = 0, A3 = 0, A4 = 0 2) if A = 1 and B =0 then A1 = 0, else A2 =1, A3 = 0, A4 = 0 3) if A = 0 and B = 1 then A1 = 0, else A2 = 0, A3 = 1, A4 = 0 4) if A = 0 and B =0 then A1 = 0, else A2 =
2018 Jan 29
0
Result show the values of fitting gamma parameter
Capture the results of the apply command into an object and then work with that. Here is one way to do it: > res <- apply(C, 2, fitdist, "gamma") > out <- c( res$A$estimate["shape"], res$B$estimate["shape"], res$A$estimate["rate"], res$B$estimate["rate"]) > names(out) <- c("A shape","B shape","A
2007 Oct 03
2
Speeding up simulation of mean nearest neighbor distances
I've written the function below to simulate the mean 1st through nth nearest neighbor distances for a random spatial pattern using the functions nndist() and runifpoint() from spatsat. It works, but runs relatively slowly - would appreciate suggestions on how to speed up this function. Thanks. --Dale library(spatstat) sim.nth.mdist <- function(nth,nsim) { D <- matrix(ncol=nth,
2013 Feb 09
3
Addressing Columns in a Data Frame
Dear All, Probably a one liner, but I am banging my head against the floor. Consider the following DF <- data.frame( x=1:10, y=10:1, z=rep(5,10), a=11:20 ) mn<-names(DF) but then I cannot retrieve a column by doing e.g, DF$mn[2] I tried to play with the quotes and so on, but so far with no avail. Any suggestion is welcome. Cheers Lorenzo
2012 Apr 26
2
Lambert (1992) simulation
Hi, I am trying to replicate Lambert (1992)'s simulation with zero-inflated Poisson models. The citation is here: @article{lambert1992zero, Author = {Lambert, D.}, Journal = {Technometrics}, Pages = {1--14}, Publisher = {JSTOR}, Title = {Zero-inflated {P}oisson regression, with an application to defects in manufacturing}, Year = {1992}} Specifically I am trying to recreate Table 2. But my
2009 Jul 15
1
Simulation code error
Dear List, I have some problem with my simulation code. Here is output from R: > sim.sp <- function(data,CM,n,N) + { + C <- matrix(rep(NA,N),ncol=1) + for(i in 1:N) + { + j <- n + xx <- which(colSums(CM[j,])==1) + V <- names(xx) + V <- paste(V, collapse="+") + V <- paste("SBA~", V) + rd <- round(nrow(data)*(2/3)) + d <-
2008 Mar 13
1
sorting a data.frame by mean values of grouped data
Hi, I have what I think is a fairly straightforward problem. I've looked through the FAQ's and mailing lists but have been unable to identify a solution, probably because I don't understand the language well enough. I have a set of data d, with 3 columns as shown, I want to sort the data Group, mean(Value by Label). I know that this can be done for one level, say Label, using
2009 Jul 15
1
Error in simulation R-code
Dear List, I have got error message when I run the R-code. Can anyone has a suggestion? v.code <- df.bm7[,c(10:31)]; v.code[1:3,] names(v.code) CM = v.code # variable binomial code sim.sp <- function(data,CM,n,N) { C <- matrix(rep(NA,N),ncol=1) for(i in 1:N) { j <- n xx <- which(colSums(CM[j,])==1) V <- names(xx) V <- paste(V,
1997 Sep 05
2
R-beta: help with R simulation
[[this bounced first, because it has 'help' in the Subject line ... -- Martin Maechler ]] I am a complete novice R programmer. (Though I know C quite well) I am trying to write some R code to do the following simulation. There is a 2-frame "movie" of noise and signal dots. the noise dots have random positions in each frame. The signal dots are placed randomly in frame 1,
2007 Jun 02
2
spatial simulation
Dear R-users, I'm trying to do some spatial simulation. I have two covariates, Z and C. I want to examine their relationship under different spatial distribution. I have no problem simulating completely spatial random process but I'm totally stuck on poisson (cluster) pattern. I already have a dataset with Z and C (obs=575) and I know the relationship between them. Using these 575
2013 Feb 01
2
Nested loop and output help
Hello Everyone, My name is Thomas and I have been using R for one week. I recently found your site and have been able to search the archives of posts. This has given me some great information that has allowed me to craft an initial design to an inquiry I would like to make into the breakdown of McNemar's test. I have read an intro to R manual and the posting guides and hope I am not violating
2007 May 01
2
Simulation using parts of density function
Hi My simulation with the followin R code works perfectly: sim <- replicate(999, sum(exp(rgamma(rpois(1,2000), scale = 0.5, shape = 12)))) But now I do not want to have values in object "sim" exceeding 5'000'000, that means that I am just using the beginning of densitiy function gamma x < 15.4. Is there a possibility to modify my code in an easy way? Thanks for any help!
2007 Feb 13
1
simulating from Langevin distributions
Dear all, I have been looking for a while for ways to simulate from Langevin distributions and I thought I would ask here. I am ok with finding an algorithmic reference, though of course, a R package would be stupendous! Btw, just to clarify, the Langevin distribution with (mu, K), where mu is a vector and K>0 the concentration parameter is defined to be: f(x) = exp(K*mu'x) / const where
2008 Mar 05
2
simulating the anova
I have been trying to figure out how to run a simple simulation of the ANOVA and I'm coming up just a bit short. The code I've got is: cohen.f = .25 groups = 4 between.var = 19 within.var = between.var / cohen.f ^ 2 n = 500 sim.means = rnorm(n = groups, mean = 0, sd = sqrt(between.var)) sim.data = lapply(sim.means, function(mean) rnorm(n = n, mean = mean, sd = sqrt(within.var)))
2008 May 28
1
Grouped weighted.mean
Dear all -- I want to compute weighted.mean() for grouped rows. Data frame extract is just below. For each Key, I want the mean of IAC weighted by Wt. DP0[1:20,] Key IAC Wt 2 C3-PD030020050.PD030020050.3.12.3.0 0.765 0.8590000 3 C3-PD030020050.PD030020050.3.12.3.0 0.764 0.8449651 4 C3-PD030020050.PD030020050.3.12.3.0
2012 Jan 26
1
eRm package - Rasch simulation
When I try to create a Rasch simulation of data using the sim.rasch function, I get more items than I intend #My code library(eRm) #Number of items k <- 20 #Number of participants n <- 100 #Create Rasch Data #sim.rasch(persons, items, seed = NULL, cutpoint = "randomized") r.simulation <- sim.rasch(n,k) I end up with 20 participants and 100 items, but the instructions say