Displaying 20 results from an estimated 2000 matches similar to: "Running a function through a vector with the scalars as arguments"
2010 Jul 11
2
simple apply syntax
I know this is a simple question, but I have yet to master the apply
statements. Any help would be appreciated.
I have a column of probabilities and sample sizes, I would like to create a
column of binomial random variables using those corresponding probabilities.
Eg.
mat = as.matrix(cbind(p=runif(10,0,1), n=rep(1:5)))
p n
[1,] 0.5093493 1
[2,] 0.4947375 2
[3,]
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
2010 Jun 23
1
Generation of binomial numbers using a loop
Dea'R' helpers
I have following data -
prob = c(0.1, 0.2, 0.3, 0.4, 0.5)
frequency = c(100, 75, 45, 30, 25)
no_trials = c(10, 8, 6, 4, 2)
freq1 = rbinom(frequency[1], no_trials[1], prob[1])
freq2 = rbinom(frequency[2], no_trials[2], prob[2])
freq3 = rbinom(frequency[3], no_trials[3], prob[3])
freq4 = rbinom(frequency[4], no_trials[4], prob[4])
freq5 = rbinom(frequency[5],
2005 Apr 02
2
Solaris10/amd64 + SunSutio Compile (PR#7767)
Full_Name: Teru KAMOGASHRIA
Version: 2.0.1
OS: SunOS sun 5.10 Generic i86pc i386 i86pc
Submission from: (NULL) (219.5.176.24)
rbinom.c cannot be compiled because of the casting problem.
/opt/SUNWspro/bin/cc -I. -I../../src/include -I../../src/include
-I/usr/local/include -DHAVE_CONFIG_H -D__NO_MATH_INLINES -g -c rbinom.c -o
rbinom.o
"rbinom.c", line 60: operand must have real
2006 Sep 20
1
Simulation help
I'm trying to simulate trend data over a five year period. I want
different trend profiles...the simplest being a linear trend. I've been
using the following code:
patBdta1 <- NULL
for(i in 1:100)
patBdta1 <- rbind(patBdta1,c(yr1= mean(rbinom(50,1,.50)),
yr2 =mean(rbinom(50,1,.51)),
yr3 =mean(rbinom(50,1,.52)),
2012 Jan 04
5
a quick question about "rbinom"
Hello, I have the following code using rbinom, but I don't understand what
*"+1"* means in the code. Could someone help? Thanks so much,
> X1<-c("A","B")[rbinom(n,1,0.6)+1]
> X2<-c("C","D")[rbinom(n,1,0.1)+1]
--
View this message in context: http://r.789695.n4.nabble.com/a-quick-question-about-rbinom-tp4262977p4262977.html
Sent
2012 Jun 18
6
Trying to speed up an if/else statement in simulations
Dear R-help,
I am trying to write a function to simulate datasets of size n which contain
two time-to-event outcome variables with associated 'Event'/'Censored'
indicator variables (flag1 and flag2 respectively). One of these indicator
variables needs to be dependent on the other, so I am creating the first and
trying to use this to create the second using an if/else statement.
2007 Oct 17
3
how to repeat the results of a generated probabilities
hello,
I want to simulate 200 times the mean of a joint probability (y1) and 200
times the mean of another joint distribution (y2),
that is I'm expecting to get 200 means of y1 and 200 means of y2.
y1 and y2 are probabilities that I calculate from the marginal prob. (z1 and
z2 respectively) multiple by the conditional prob. (x1 and x2 respectively),
which I generaterd from the binomial
2010 Feb 17
1
lapply to apply a function using a vector
Hi,
First, thank you all for your help.
Here is my problem (simplified):
Say I have a list:
a=list(matrix(50,nrow=5,ncol=5),matrix(25,nrow=5,ncol=5),matrix(10,nrow=5,ncol=5))
I'd like to use rbinom with a different probability for each matrix. I
tried:
b=c(.8,.1,.9)
brep=rep(b,each=25)
lapply(a,function(a) rbinom(25,a,brep))
but that doesn't work-- it just uses the first value of b
2008 Sep 09
2
naive variance in GEE
Hi,
The standard error from logistic regression is slightly different
from the naive SE from GEE under independence working correlation structure.
Shouldn't they be identical? Anyone has insight about this?
Thanks,
Qiong
a<-rbinom(1000,1)
b<-rbinom(1000,2,0.1)
c<-rbinom(1000,10,0.5)
summary(gee(a~b, id=c,family="binomial",corstr="independence"))$coef
2005 Aug 16
2
quirky behavior from rbinom (PR#8071)
Full_Name: Chris Paulse
Version: 2.1.1
OS: WinXP
Submission from: (NULL) (129.98.60.134)
This seems strange. I have a small block of code that repeatedly calls rbinom.
I put a break in there in case it returns NaN, as I've been having problems with
this. Here is a transcript from the debug session:
Browse[1]> theP
[1] 1
Browse[1]> yleft[dataIndex]
[1] 3
Browse[1]> rbinom(1,3,1)
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,
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
2001 Dec 02
1
bug in rbinom? (PR#1190)
Full_Name: Kert Viele
Version: 1.3
OS: Windows ME and 2000
Submission from: (NULL) (65.6.218.65)
Hello! Thanks for all your efforts on R. They are appreciated!
I was simulating the central limit theorem in class,
but found that repeated use of
mean(rbinom(100000,500,0.4))
resulted in values less than 200 (the expected mean), for example
> mean(rbinom(100000,500,0.4))
[1] 199.0294
>
2005 Feb 28
2
A problem about outer()
Dear all,
I have something about function outer() that I can't understand. Just see the following example. The two NaNs are due to 0/0, but I can't figure out the cause of the last two errors. I wonder if some one can explain this for me.
___________________________________________________________________
> sx=rbinom(10,1,0.5);ot=rbinom(10,1,0.5);ag <- rbinom(10,100,0.3);ho <-
2013 May 21
2
problem with "transform" and "get" functions
Hello, I'm having a problem using the "transform" and "get" functions. I'm
probably making a dumb mistake, and I need help!
I start by making a small simulated dataset. I save the names of the
variables in "var.names." Without getting into the details of it, I have to
create a custom function to perform some statistics. As part of this, I
need to sequentially
2008 Mar 22
1
Simulating Conditional Distributions
Dear R-Help List,
I'm trying to simulate data from a conditional distribution, and
haven't been able to modify my existing code to do so. I searched
the archives, but didn't find any previous post that matched my
question.
n=10000
pop = data.frame(W1 = rbinom(n, 1, .2),
W2 = runif(n, min = 3, max = 8), W3 = rnorm(n, mean=0, sd=2))
pop = transform(pop,
A = rbinom(n, 1,
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,
2009 Dec 02
1
Generate missing data patterns
Dear R-users,
i try to generate missing values in a matrix X according to a given
missingnes pattern R with the probabilities p per row.
X<-matrix(rnorm(3*100),ncol=3)
## indicator matrix for missingnes (1 observed, 0 missing)
R<-matrix(c(1,1,1,
0,0,1,
1,1,0,
0,1,1),ncol=3,byrow=TRUE)
## probabilities for row 1, row 2, row 3 and row 4
2013 Feb 18
1
help with population matrix
Hi guys, I am a biologist and an R newbie, and I'm learning how to create a
simple population model.
So, I have a population matrix ("pop")of 30 age classes of female (1:4 are
non-breeders, 5:30 are breeders) which will be modelled for 100 years.
> pop <- matrix(0,30,100)
I then populate this matrix with 3 young adult females.
> pop[5, 1] <- 3
I then want to run this