Este script ilustra cómo realizar una imputación múltiple cuando se supone que los datos faltantes no son aleatorios (MNAR). Comienza creando un conjunto de datos sintético ('Fcs1') con valores faltantes simulados. Luego, utiliza `PROC MI` con la opción `FCS` (Fully Conditional Specification) y la instrucción `MNAR` para ajustar los valores imputados de las variables `y1` e `y2` específicamente para el grupo de tratamiento `Trt='1'`, aplicando desplazamientos (shift).
Datenanalyse
Type : CREACIÓN_INTERNA
Los datos se generan artificialmente en el paso DATA `Fcs1` utilizando bucles y funciones de generación de números aleatorios (`rannor`, `ranuni`) para simular datos de ensayos clínicos.
1 Codeblock
DATA STEP Data
Erklärung : Creación del conjunto de datos `Fcs1`. Genera variables `y0`, `y1`, `y2` basadas en una distribución normal e introduce aleatoriamente valores faltantes (`.`) para `y1` o `y2`.
Kopiert!
data Fcs1;
do Trt=0 to 1;
do j=1 to 5;
y0=10 + rannor(99);
y1= y0 + 0.9*Trt + rannor(99);
y2= y0 + 0.9*Trt + rannor(99);
if (ranuni(99) < 0.3) then y1=.;
else if (ranuni(99) < 0.3) then y2=.;
output;
end; end;
do Trt=0 to 1;
do j=1 to 45;
y0=10 + rannor(99);
y1= y0 + 0.9*Trt + rannor(99);
y2= y0 + 0.9*Trt + rannor(99);
if (ranuni(99) < 0.3) then y1=.;
else if (ranuni(99) < 0.3) then y2=.;
output;
end; end;
drop j;
run;
1
DATA Fcs1;
2
DO Trt=0 to 1;
3
DO j=1 to 5;
4
y0=10 + rannor(99);
5
y1= y0 + 0.9*Trt + rannor(99);
6
y2= y0 + 0.9*Trt + rannor(99);
7
IF (ranuni(99) < 0.3) THEN y1=.;
8
ELSEIF (ranuni(99) < 0.3) THEN y2=.;
9
OUTPUT;
10
END; END;
11
DO Trt=0 to 1;
12
DO j=1 to 45;
13
y0=10 + rannor(99);
14
y1= y0 + 0.9*Trt + rannor(99);
15
y2= y0 + 0.9*Trt + rannor(99);
16
IF (ranuni(99) < 0.3) THEN y1=.;
17
ELSEIF (ranuni(99) < 0.3) THEN y2=.;
18
OUTPUT;
19
END; END;
20
drop j;
21
RUN;
2 Codeblock
PROC PRINT
Erklärung : Muestra las primeras 10 observaciones del conjunto de datos generado para verificación.
Kopiert!
proc print data=Fcs1(obs=10);
var Trt Y0 Y1 Y2;
title 'First 10 Obs in the Trial Data';
run;
1
PROC PRINTDATA=Fcs1(obs=10);
2
var Trt Y0 Y1 Y2;
3
title 'First 10 Obs in the Trial Data';
4
RUN;
3 Codeblock
PROC MI Data
Erklärung : Ejecuta la imputación múltiple. Utiliza el método `FCS` con 25 iteraciones. La instrucción `MNAR` aplica un ajuste (desplazamiento de -0.4 para `y1` y -0.5 para `y2`) únicamente para las observaciones donde `Trt='1'`, simulando un sesgo para los datos faltantes.
Kopiert!
proc mi data=Fcs1 seed=52387 out=outex16;
class Trt;
fcs nbiter=25 reg( /details);
mnar adjust( y1 /shift=-0.4 adjustobs=(Trt='1'))
adjust( y2 /shift=-0.5 adjustobs=(Trt='1'));
var Trt y0 y1 y2;
run;
1
PROC MIDATA=Fcs1 seed=52387 out=outex16;
2
class Trt;
3
fcs nbiter=25 reg( /details);
4
mnar adjust( y1 /shift=-0.4 adjustobs=(Trt='1'))
5
adjust( y2 /shift=-0.5 adjustobs=(Trt='1'));
6
var Trt y0 y1 y2;
7
RUN;
4 Codeblock
PROC PRINT
Erklärung : Muestra las primeras 10 observaciones del conjunto de datos de salida `outex16`, que contiene los datos imputados.
Kopiert!
proc print data=outex16(obs=10);
var _Imputation_ Trt y0 y1 y2;
title 'First 10 Observations of the Imputed Data Set';
run;
1
PROC PRINTDATA=outex16(obs=10);
2
var _Imputation_ Trt y0 y1 y2;
3
title 'First 10 Observations of the Imputed Data Set';
4
RUN;
Dieses Material wird von We Are Cas "wie besehen" zur Verfügung gestellt. Es gibt keine ausdrücklichen oder stillschweigenden Garantien hinsichtlich der Marktgängigkeit oder Eignung für einen bestimmten Zweck in Bezug auf die hierin enthaltenen Materialien oder Codes. We Are Cas ist nicht verantwortlich für Fehler in diesem Material, wie es jetzt existiert oder existieren wird, noch bietet We Are Cas technischen Support dafür an.
Urheberrechtsinformationen : SAS SAMPLE LIBRARY, NAME: MIEX16, PRODUCT: STAT
Zugehörige Dokumentation
Aucune documentation spécifique pour cette catégorie.
SAS und alle anderen Produkt- oder Dienstleistungsnamen von SAS Institute Inc. sind eingetragene Marken oder Marken von SAS Institute Inc. in den USA und anderen Ländern. ® zeigt die Registrierung in den USA an. WeAreCAS ist eine unabhängige Community-Site und nicht mit SAS Institute Inc. verbunden.
Diese Website verwendet technische und analytische Cookies, um Ihre Erfahrung zu verbessern.
Mehr erfahren.