Displaying 20 results from an estimated 11000 matches similar to: "Random number generator in R compared"
2007 Apr 25
2
creating random numbers
l want to create a  column of 1 and 2 randomly what command should l use 
  eg
  treatment          strata
      
  1                      1
  2                      0
  1                      1
  2                      1
  2                      0          
  2                      1
  2                      0
  1                      0
  these should be created randomly
  
  secondly if l have
2007 Apr 26
3
adding a column to a matrix
i would like to add a variable to an existing matrix by manipulating 2 previous variables eg for the data
  m
         treat strata      censti     survTime
    [1,]     1      2  284.684074  690.4961005
    [2,]     1      1  172.764515   32.3990335
    [3,]     1      1 2393.195400   24.6145279
    [4,]     2      1   30.364771    8.0272267
    [5,]     1      1  523.182282  554.7659501
  
  l
2007 May 07
4
creating a new column
hie l would like to create a 6th column "actual surv time" from the following data 
  
  the condition being
  if  censoringTime>survivaltime then actual survtime =survival time
  else actual survtime =censoring time
  
  the code l used to create the data is
  
       s=2
       while(s!=0){ n=20
         m<-matrix(nrow=n,ncol=4)
        
2005 Aug 16
2
specify seed for Random Number Generator
I need to generate 100 I.I.D samples from an exponential distribution.  I 
use rexp(100,parameter).  Is there anyway to specify a seed to determine the 
first input for the uniform random number generator used to generate these 
exponentials?
-Dhiren
2012 Jan 27
3
generate a random number with rexp ?
dear list
I use runif to generate a ramdom number between min and max
runif(n, min=0, max=1)
however , the syntaxe of rexp does not allow that
rexp(n, rate = 1)
and it generate a number with the corresponding rate.
The question is: how to generate a number between min and max using rexp().
Regards
-- 
PhD candidate in Computer Science
Address
3 avenue lamine, cité ezzahra, Sousse 4000
2007 May 01
7
logrank test
how do l programme the logrank test. l am trying to compare 2 survival curves
  
  
       
---------------------------------
	[[alternative HTML version deleted]]
2007 May 17
2
controling the size of vectors in a matrix
hie R users
   
  l have the following matrix
      n=20
      m<-matrix(nrow=n,ncol=4)
      colnames(m)=c("treatmentgrp","strata","survivalTime")                  
          for(i in 1:n) m[i,]<-c(sample(c(1,2),1,replace=TRUE),sample(c(1:2),1,replace=TRUE),rexp(1,0.07),rexp(1,0.02))                                                                  
   
     
2009 Apr 12
2
"taking the log then later exponentiate the result" query
Hi,
 
I am trying to figure out the observed acceptance rate and M, using generalised rejection sampling to generate a sample from the posterior distribution for p.
 
I have been told my code doesn't work because I need to  "take the log of the expression for M, evaluate it and then exponentiate the result." This is because R is unable to calculate high powers such as 545.501.
 
As
2007 Nov 13
3
cronbach's alpha
hie 
    1...i'm trying to carryout a relibility testusing cronbach's alpha what fuctin do i use.
    
    2.. this is more of a statistical question.if the alpha value  for all the variables  is negative what does it mean. and if the  alpha value is negative for all tyha variables but is greater than 0.7  for some sections of the variables what does that mean
  
  thanks in advance
  
  
2002 May 03
6
problems with rexp ?
Does anyone know if R have any problems with the exponential random number
generation (function rexp)?
I comment it because I executed
data<-sort(rexp(100))
plot(data,dexp(data)/(1-pexp(data)),type="l")
and the graphic isn't constant.
(Note: exponential distribution have a constant hazard failure rate).
Thank you,
Juan
2009 Jul 09
5
Best way to export values from a function?
Maybe there is a great website out there or white paper that discusses this but again my Google skills (or lack there of) let me down.
I would like to know the best way to export several doubles from a function, where the doubles are not an array.  
Here is a contrived function similar to my needs:
multipleoutput<-function(x)
{
	squared<-x^2
	cubed<-x^3
	exponentioal<-exp(x)
2007 May 17
1
creating columns
l would like to create the following matrice
  
  treatmentgrp            strata
                   1    1          1    1          1    1          1    2          1    2          1    2          2    1          2    1          2    1          2    2          2    2          2    2       l should be able to choose the size of the treatment grps and stratas the method l used intially creates the
2010 Jun 16
2
Question
Dear Mr.
for writing program about Gibbs sampling, i have a question.
if i want to generate data from Exponential distribution but range of X is restricted, how can i do?
regards,
A.Rashidi
 
      
	[[alternative HTML version deleted]]
2011 Jul 19
3
calculating the mean of a random matrix (by row) and some general questions
Hi everyone!
I'm trying to teach myself R in order to do some data analysis. I'm a
mathematics student and (only) familiar with matlab and latex. I'm working
trough the "official" introduction to R at the moment, while simultaneously
solving some exercises I found in the web. Before I post my (probably
stupid) question, I'd like to ask you for some general advice. How do
2009 Dec 18
2
how to combine multiple indicator variables in a single factor
Say I have a dataframe like this:
df <- data.frame(cbind(c(1,0,0,1),c(0,1,0,0),c(0,0,1,0)))
names(df) <- c('a','b','c')
I would like to create a factor in a new column, where the factor values are taken from the column names, like this:
> df2
  a b c f
1 1 0 0 a
2 0 1 0 b
3 0 0 1 c
4 1 0 0 a
How would I do this?  Thanks,
Dan
Daniel Nordlund
Bothell, WA USA
2006 Aug 15
1
rexp question
I am using rexp to generate several exponential distributions. I am passing
rexp a vector of rates , r. I am wanting to simulate a sample of size 200
for each rate so the code looks like: rexp(n=200*length(r),rate=r) this
gives me a vector of the random exponential variables, but they are all
disjointed b/c rexp goes through and simulates an exponential variable for
each rate and it does that 200 
2009 Aug 24
6
Combining matrices
If I have two matrices like
x <- matrix(rep(c(1,2,3),3),3)
y <- matrix(rep(c(4,5,6),3),3)
How can I combine  them to get ?
1 1 1 4 4 4
1 1 1 5 5 5
1 1 1 6 6 6
2 2 2 4 4 4
2 2 2 5 5 5
2 2 2 6 6 6
3 3 3 4 4 4
3 3 3 5 5 5
3 3 3 6 6 6
The number of rows and the actual numbers above are unimportant, they are given so as to illustrate how I want to combine the matrices.  I.e., I am looking for
2007 Apr 20
4
importing sas datasets
Hello,
I wanted to ask help about importing sas datasets.
1)I tried with some functions as read.ssd (foreign package),
but it doesn't import the file if the length of the
variables' names are longer than 8 bite (it has to conform
to the 6 version). 
2)I then tried with the sas.get function (Hmisc package) but
with the command:
 c<- sas.get(lib="c:\\ghan",
2011 Jun 14
2
How to generate bivariate exponential distribution?
Any one know is there any package or function to generate bivariate
exponential distribution? I gusee there should be three parameters, two rate
parameters and one correlation parameter. I just did not find any function
available on R.  Any suggestion is appreciated. 
--
View this message in context:
2003 Jul 22
4
greek in main title
Hello,
I have written a function that demonstrates the CLT by
generating samples following the exponential distribution,
calculating the means, plotting the histogram, and drawing
the limiting normal curve as an overlay.  I have the title
of each histogram state the sample size and rate (1/theta)
for the exponential (the output is actually 4 histograms),
but I can't get the greek letter theta