Please, I want to simulate a dataset with 4 blocks and 4 treatments and counts following a Poisson and negative binomial distribution. Is it possible is SAS?
Sure,
function RAND generates pseudo random numbers from many distributions
Pois = rand("Poisson", m); /* Generates a Poisson variate */
NegBin = rand("NegBinomial", p, k); /* Genarates a negative binomial variate */
Check the documentation for the precise parameterisation.
Here is an example. Your model will determine the definitions of mu, r, and p. I just invented a few values to demonstrate the basic idea.
data SimBlock;
call streaminit(123);
do Block = 1 to 4;
do Treatment = 1 to 4;
/* invent a formula for the expected count */
mu = ( Block + (Treatment-2.5)**2 );
PoisCount = rand("Poisson", mu);
/* invent a probability and number of trials */
r = mu / 8; /* prob of success */
k = 1; /* number of successes */
NBCount = rand("NegBin", r, k); /* number of failures before k successes */
output;
end;
end;
drop mu k r;
run;
proc means data=SimBlock;
run;
No reason. I just invented some numbers because you did not provide any information about the design of the simulation. The number 2.5 represents the average treatment effect. I used 8 to make sure r is a probability in [0, 1].
Thank you for your prompt response. Here is the description of the experiment :
i. block - 4
ii. treatments = 4
iii. repetition = 8
iv. counts = containing some zeros
Question: Simulate the count as coming from
i. a NegBin distribution
ii. a Poisson distribution
Thank you, again, in anticipation.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: