[R] Question on Data Simulation

Rau, Roland Rau at demogr.mpg.de
Thu Apr 1 17:11:31 CEST 2004


> -----Original Message-----
> From:	"Jingky P. Lozano" [SMTP:jlozano at apoy.upm.edu.ph]
> Sent:	Thursday, April 01, 2004 2:15 PM
> To:	r-help at stat.math.ethz.ch
> Subject:	[R] Question on Data Simulation 
> Dear mailing list,
> Do you know a specific package in R where I can create an artificial
> survival 
> data with controlled censoring condition?  (For example, I want to
> simulate a 
> data set with 5 variables and 20% of the observations are censored.)
	maybe I misunderstood something but why don't you create a variable,
often denoted by 'status' in survival analysis, where the probabilities are
0.2 for censoring and 0.8 for the event and add this to your other data?
	The code should like like this (for a hypothetical size of 1000

	status = sample(x=c(0,1), size=1000, replace=TRUE, prob=c(0.2,0.8))


	P.S. Just a matter of style: if you (=mailing list members) are
asked by someone how to do something in R, do you prefer to give the names
of the arguments in the functions, or do you prefer to keep it short like:
	status = sample(c(0,1), 1000, TRUE, c(0.2,0.8))

This mail has been sent through the MPI for Demographic Rese...{{dropped}}

More information about the R-help mailing list