This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Significant effects where there are none */ | |
%let ErrorVariance=1000; | |
%let nrep=10; | |
%let nsim=100; | |
DATA CRD; | |
call streaminit(123); | |
do isim = 1 to ≁ | |
do rep=1 to &nrep; | |
do trt=1 to 5; | |
if trt=1 then y=791.5 + rand('Normal', 0, sqrt(&ErrorVariance)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data REGRESS2; | |
call streaminit(12345); | |
do i=1 to 1000 by 1; | |
x=rand("Uniform",0,100); | |
error=rand("Normal", 0, 0.2); | |
y=2+(0.5*x)+error; | |
output; | |
end; | |
run; | |
proc univariate data=REGRESS2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Tabulate counts and plot data */ | |
%let N=150; | |
data CountData; | |
array xx1{&N} _temporary_; | |
array xx2{&N} _temporary_; | |
call streaminit(1); | |
/* simulate fixed effects */ | |
do i=1 to &N; | |
xx1{i}=rand("Uniform"); | |
xx2{i}=rand("Normal", 0 , 0.5); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Simulate binomial data, then analyze it it with Logistic Regression **/ | |
/* Simulate dataset */ | |
%let N=150; | |
data LogisticData; | |
array xx1{&N} _temporary_; | |
array xx2{&N} _temporary_; | |
call streaminit(1); | |
/* simulate fixed effects */ | |
do i=1 to &N; | |
xx1{i}=rand("Uniform"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* PROC IML --> using different degrees of freedom */ | |
ods graphics on / outputfmt=svg; | |
proc iml; | |
call randseed(1234); /* set random number seed */ | |
n = j(100,1); | |
t2 = j(100,1); | |
t4 = j(100,1); | |
t8 = j(100,1); | |
t16 = j(100,1); | |
t32 = j(100,1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%let CovBlock=0.000819; | |
%let CovPen=0.001557; | |
%let CovResidual=0.03129; | |
data sim; | |
array trtmean{4} _temporary_ (2.1223 2.1046 2.0919 2.0773); | |
array covpen{4} _temporary_ (0.001361 0.000012 0.002008 0.002880); | |
do blocknum=12; | |
do animalnum=2 to 25 by 2; | |
do sim=1 to 1000 by 1; | |
do block=1 to blocknum; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data IB; | |
do sim=1; | |
do dose=0,20,40,60,80,100,160 ; | |
do pen=1 to 100; | |
if dose=0 then Y=200 + rand("Normal", 0, sqrt(480.779)); | |
if dose=20 then Y=304 + rand("Normal", 0, sqrt(480.779)); | |
if dose=40 then Y=317 + rand("Normal", 0, sqrt(480.779)); | |
if dose=60 then Y=321 + rand("Normal", 0, sqrt(480.779)); | |
if dose=80 then Y=326 + rand("Normal", 0, sqrt(480.779)); | |
if dose=100 then Y=332 + rand("Normal", 0, sqrt(480.779)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%let nsim=100; | |
data power; | |
length TT $30; | |
array a[4] _temporary_ (314.31 347 314.31 308.4); | |
array k[4] _temporary_ (0.06158 0.00975 0.06158 0.0296); | |
array t[4] _temporary_ (-15.442 -205.4 -18.9413 -63.43); /* You can already see that the estimates of T are not precies and helpfull --> carefull attention is needed for these */ | |
do sim=1 to ≁ | |
do treatment=1 to 4; | |
if treatment=1 then TT="A"; | |
if treatment=2 then TT="B"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%let SigmaBlock=2520.38; | |
%let block=11; | |
%let treat=9; | |
%let time=2; | |
%let isim=200; | |
proc iml; | |
/* Create dataset */ | |
create WIDEAMEN var {"ISIM" "Block" "RndBlock" "Time" "T1" "T2" "T3" "T4" "T5" "T6" "T7" "T8" "T9"}; | |
call randseed(4321); | |
/* Create # simulations of correlated data for 9 Treatments & Two Timepoints */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FILENAME REFFILE '//nlws0844/mjacobs$/StatisticsPlatform/Website/ELearning/Workshops/Time-Series/Data/Deceased.xlsx'; | |
PROC IMPORT DATAFILE=REFFILE | |
DBMS=XLSX | |
OUT=WORK.IMPORT; | |
GETNAMES=YES; | |
RUN; | |
/* Delete row | |
/** Content of the data **/ | |
proc freq data=import nlevels;table year*week;run; | |
/** DATA WRANGLING **/ |