## simulate censored data such that most with longest time are censored

Solved
Super Contributor
Posts: 328

# simulate censored data such that most with longest time are censored

Any head on on this????? simulate censored data such that most with longest time are censored

Accepted Solutions
Solution
‎03-06-2013 03:30 PM
Super Contributor
Posts: 328

## Re: simulate censored data such that most with longest time are censored

Posted in reply to Astounding

Thanks  answer the question.I used two weibull distribution  and make sure the the scale parameter for the true weibull is always smaller than that for the one to indicate censoring

All Replies
Super User
Posts: 6,752

## Re: simulate censored data such that most with longest time are censored

Posted in reply to desireatem

Let's see how close this comes to what you need.  It creates a variable named CENSORED, with values of 0 or 1, randomly assigned, with higher probabilities of "1" for longer TIME values.

proc sort data=have;

by time;

run;

data want;

set have nobs=_total_obs_;

censored = ranuni(12345) < _n_/_total_obs_;

run;

Super Contributor
Posts: 328

## Re: simulate censored data such that most with longest time are censored

Posted in reply to Astounding

I do not know what you program is doing since it does not tell me anything where data=have?

This is what I have but can't fix it such that longer t are

data want;

lambdat = 0.0005; *baseline hazard;

lambdac = 0.004; *censoring hazard;

do i = 1 to 100;

t = rand("WEIBULL", 1, lambdaT );

* time of event;

c = rand("WEIBULL", 1, lambdaC);

* time of censoring;

time = min(t, c);    * which came first?;

censored = (c lt t);

output;

end;

run;

proc sort data=want;

by time;

run;

more likely to be consored;

Super User
Posts: 6,752

## Re: simulate censored data such that most with longest time are censored

Posted in reply to desireatem

OK, start with your program, but remove the line about censored = (c lt t).

After sorting, continue with my logic:

data want;

set want nobs=_total_obs_;

censored = ranuni(12345) < _n_ / _total_obs_;

run;

There are many ways to adjust the final assignment.  Toward the beginning of the data, the censor rate is nearly 0, and for the final observation it is 100%.  The idea is to rely on the sorted order so that the further into the data you go, the higher the time value, and the greater the likelihood of censorship.  Just as one example, this formula would have the censorship rate rise to 50% instead of 100% for the highest time values:

censored = ranuni(12345) < 0.5 * _n_ / _total_obs_;

Also note, if you are performing many simulations you may want to vary the seed to the random number function.  A nonzero seed always generates the same stream of random numbers.

Super Contributor
Posts: 328

## Re: simulate censored data such that most with longest time are censored

Posted in reply to Astounding

Thanks, How do I reduce the censored rate? 50% censored rate is very high

Super User
Posts: 6,752

## Re: simulate censored data such that most with longest time are censored

Posted in reply to desireatem

The first number in the formula is the censored rate for the highest time value.  To reduce to a 25% rate, use:

censored = ranuni(12345) < 0.25 * _n_ / _total_obs_;

The censored values are randomly assigned.  But the overall censored rate for the entire data set will be roughly half the number in the formula.  The rate starts at 0% and ends up at 25%, steadily increasing as you make your way through the data set.

Super Contributor
Posts: 328

## Re: simulate censored data such that most with longest time are censored

Posted in reply to Astounding

Thanks, However this is not what I want.THis just sort the censored values and put the censored at the end without taking into consideration their time and censored time

Respected Advisor
Posts: 2,655

## Re: simulate censored data such that most with longest time are censored

Posted in reply to desireatem

What gave is very much how the question was framed:  How to increase the rate of censoring as the observed time increases?  I think you want to ask a different question, and we need an example to help understand what is needed.

Steve Denham

Super User
Posts: 6,752

## Re: simulate censored data such that most with longest time are censored

Posted in reply to desireatem

Did  you actually sort the data first?  Did you check the results?  You'll have to put these two items together:

1. The data set is sorted, so all the highest time values are at the end of the data set.

2. The censor rate increases as you move from the beginning to the end of the data set.

Like Steve said, if you want to change the question, just explain.

Solution
‎03-06-2013 03:30 PM
Super Contributor
Posts: 328

## Re: simulate censored data such that most with longest time are censored

Posted in reply to Astounding

Thanks  answer the question.I used two weibull distribution  and make sure the the scale parameter for the true weibull is always smaller than that for the one to indicate censoring

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
• 9 replies
• 693 views
• 0 likes
• 3 in conversation