similar to: sample(c(0, 1)...) vs. rbinom

Displaying 20 results from an estimated 30000 matches similar to: "sample(c(0, 1)...) vs. rbinom"

2023 Apr 08
1
Error message for infinite probability parameters in rbinom() and rmultinom()
On 08/04/2023 5:53 p.m., Martin Maechler wrote: >>>>>> Christophe Dutang >>>>>> on Sat, 8 Apr 2023 14:21:53 +0200 writes: > > > Dear all, > > > Using rmultinom() in a stochastic model, I found this function returns an error message 'NA in probability' for an infinite probability. > > > Maybe, a more
2023 Apr 08
1
Error message for infinite probability parameters in rbinom() and rmultinom()
>>>>> Christophe Dutang >>>>> on Sat, 8 Apr 2023 14:21:53 +0200 writes: > Dear all, > Using rmultinom() in a stochastic model, I found this function returns an error message 'NA in probability' for an infinite probability. > Maybe, a more precise message will be helpful when debugging. >> rmultinom(1, 3:5, c(1/2, 1/3,
2023 Apr 08
1
Error message for infinite probability parameters in rbinom() and rmultinom()
Dear all, Using rmultinom() in a stochastic model, I found this function returns an error message 'NA in probability' for an infinite probability. Maybe, a more precise message will be helpful when debugging. > rmultinom(1, 3:5, c(1/2, 1/3, Inf)) Error in rmultinom(1, 3:5, c(1/2, 1/3, Inf)) : NA in probability vector > rmultinom(1, 3:5, c(1/2, 1/3, NA)) Error in rmultinom(1,
2014 Jan 15
1
rbinom in RcppArmadillo?
What is the RcppArmadillo way to make binomial draws from a vector of probs, similar to what rbinom does in R? Thanx! -- View this message in context: http://r.789695.n4.nabble.com/rbinom-in-RcppArmadillo-tp4683593.html Sent from the R devel mailing list archive at Nabble.com.
2000 Feb 17
2
bug in rbinom? (PR#448)
# Your mailer is set to "none" (default on Windows), # hence we cannot send the bug report directly from R. # Please copy the bug report (after finishing it) to # your favorite email program and send it to # # r-bugs@biostat.ku.dk # ###################################################### In version 0.99.0 for Windows NT I get the following: > .Random.seed [1] 0 21012
2008 Jul 09
3
rbinom for a matrix
I have a large matrix full of probabilities; I would like to convert each probability to a 1 or a 0 using rbinom. How can I do this on the entire matrix? The matrix was converted from a raster ArcMap dataset, so the matrix is essentially a map. Because of this, I have no column headings. Thanks! -- View this message in context: http://www.nabble.com/rbinom-for-a-matrix-tp18366867p18366867.html
2011 Feb 04
1
rbinom and probability
Hello compadRes, I'm developing a script that selects "cells" over a certain metabolic rate to kill them. A rate between 9 and 12 means that the cells are candidates for death. I'll show you what I mean: # a would be a vector of cell metabolic rates. a<-c(8, 7, 9, 6, 10, 11, 4, 5, 6) #now identify which cells will be candidates for death, namely those cells with metabolic
2008 May 28
5
"rbinom" not using probability of success right
I am trying to simulate a series of ones and zeros (1 or 0) and I am using "rbinom" but realizing that the number of successes expected is not accurate. Any advice out there. This is the example: N<-500 status<-rbinom(N, 1, prob = 0.15) count<-sum(status) 15 percent of 500 should be 75 but what I obtain from the "count" variable is 77 that gives the probability of
2009 Dec 08
4
lower.tail option in pnorm
Hi, I would have thought that these two constructions would produce the same result but they do not. Resp <- rbinom(10, 1, 0.5) Stim <- rep(0:1, 5) mm <- model.matrix(~ Stim) Xb <- mm %*% c(0, 1) ifelse(Resp, log(pnorm(Xb)), log(1 - pnorm(Xb))) pnorm(as.vector(Xb), lower.tail = Resp, log.p = TRUE) > ifelse(Resp, log(pnorm(Xb)), log(1 - pnorm(Xb))) [1] -0.6931472 -1.8410216
2012 Jan 03
1
nls and rbinom function: step factor 0.000488281 reduced below 'minFactor' of 0.000976562
I  am trying to learn nls using a simple simulation. I assumed that the binomial prob varies linearly as 0.2 + 0.3*x in  x {0,1}, and the objective is to recover the known parameters a=0.2, b=0.3 ..data frame d has 1000 rows... d$x<-runif(0,1)               d$y<-rbinom(1000,1,0.2+0.3*d$x)  table(d$y,cut(d$x,breaks=5));   (-0.000585,0.199] (0.199,0.399] (0.399,0.599] (0.599,0.799]
2007 Nov 08
2
mapply, coxph, and model formula
Hello - I am wanting to create some Cox PH models with coxph (in package survival) using different datasets. The code below illustrates my current approach and problem with completing this. ### BEGIN R SAMPLE CODE ############################## library(survival) #Define a function to make test data makeTestDF <- function(n) { times <- sample(1:200, n, replace = TRUE) event
2019 Mar 03
2
bug: sample( x, size, replace = TRUE, prob= skewed.probs) produces uniform sample
When `length( skewed.probs ) > 200' uniform samples are generated in R-devel. R-3.5.1 behaves as expected. `epsilon` can be a lot bigger than illustrated and still the uniform distribution is produced. Chuck > set.seed(123) > > epsilon <- 1e-10 > > ## uniform to 200 then small > p200 <- prop.table( rep( c(1, epsilon), c(200, 999-200))) > ## uniform to 201
2008 Sep 17
3
Is there a way to not use an explicit loop?
I have a problem in where i generate m independent draws from a binomial distribution, say draw1 = rbinom( m , size.a, prob.a ) then I need to use each draw to generate a beta distribution. So, like using a beta prior, binomial likelihood, and obtain beta posterior, m many times. I have not found out a way to vectorize draws from a beta distribution, so I have an explicit for loop
2008 May 21
2
how to do pairwise sums in a matrix
I am looking for an efficient way to solve the following problem. I have a large matrix of continuous values with a small proportion of missing values. Columns correspond to variables where each variable has two measurements, call them A and B. The matrix is such that the columns are in sequence with respect to the variables. I would like to sum up the two measurements for each variable and each
2015 Mar 24
4
Aleatoriedad
Hola de nuevo, ya empiezo a ser pesado ¿no? bueno, no importa porque aprendemos todos. Eso, al menos, me parece. Hoy estuve estudiando en R el tema de la aleatoriedad. Veo que hay múltiples posibilidades pero me están chocando mucho. Encuentro que el generador de números pseudo aleatorios es más pseudo de lo que debería. Me explico, quiero generar 0 y 1 aleatorios. Estoy trabajando con una
2006 Jun 29
1
using "rbinom" in C code gives me erroneous results... random variable is not random (always zero)...
Dear Listers, I am trying to use "rbinom" in my C code, but i always get zeros as output no matter the probability. Am not sure what I am doing wrong because the function has worked before. Attached in an example. Noticed that "rbinom" expects 'n' to be REAL. Regards, Vumani R 2.3.1 (2006-06-01) Windows XP Gcc /* Called this file binom.c and then ran rcmd shlib on it
2007 Nov 09
2
wrapper for coxph with a subset argument
Dear R-help - Thanks to those who replied yesterday (Christos H. and Thomas L.) regarding my question on coxph and model formula, the answers worked perfectly. My new question involves the following. I want to run several coxph models (package survival) with the same dataset, but different subsets of that dataset. I have found a way to do this, described below in functions subwrap1 and
2007 Jul 06
2
How does the r-distribution function work
I am trying to understand what rbinom function does. Here is some sample code. Are both the invocations of bfunc effectively doing the same or I am missing the point? Thanks, Pieter bfunc <- function(n1,p1,sims) { c<-rbinom(sims,n1,p1) c } a=c() b=c() p1=.5 for (i in 1:10000){ a[i]=bfunc(30,p1,1) } b=bfunc(30,p1,10000)
2008 Aug 01
1
Properly Parsing Pre-Superscripts & Displaying Them With grid.text
Hi all... I?m making a chart dealing with frequencies of isotopes of various elements. For instance, I'd like the following text to appear on a chart with the "35" and "37" as superscripts: Based upon: 35Cl: 75% 37Cl: 25% I am having problems properly parsing the superscript that preceeds the "Cl", since there is no character ahead of the superscript (I saw
2003 Oct 09
3
simulate binary data from a logistic regression model
Hi. How can i simulate a binary data set from a logistic regression model?I need to manipulate parameters and so obtain my set of data. I want to show the improve in analyzing binary data with GLM(binomial) model instead of classical ANOVA or NON-MODELS procedures(relative risk-odds ratio-Pearson test of godness of fit...) Can you say me what is the right function to use? Do you know any