Software: IVEware: Imputation and Variance Estimation Software: IVEware Version 0.3 Documentation: IVEware User Guide

Chapter 10: IVEware and Stata, SPSS, and R

10.1 Introduction

Chapter 10 presents syntax to replicate the examples in Chapter 9, again using IVEware with the SRCware Shell editor with Stata, SPSS and R. In this chapter, just the IVEware command syntax is presented while subsequent coding and analyses are left to the analyst to code in a software of choice. Though the software with IVEware differs, the IVEware and resultant output should match the Chapter 9 examples.

Back to top

10.2 IMPUTE Example, IVEware and Stata

The first example demonstrates use of IVEware and Stata with IMPUTE, using NCS-R data. After imputation, the 5 multiples are stored in data sets called ”imputem_ult1-impute mult5”. By default, these are saved in Stata .dta format and can be used in additional analyses.

<stata name="Impute Example with Stata">

use "P:\IVEware_and_MI_Applications_Book\Chapter3\Examples\Stata\ncsr_ex1.dta"

/* Multiple Imputation*/
<impute name="Impute">
title Multiple Imputation Using IMPUTE ;
datain ncsr_ex1 ;
dataout impute_mult1;
default categorical;
continuous bmi intwage ncsrwtsh sestrat;
transfer caseid;
iterations 5;
multiples 5;
seed 2001;
run;
</impute>

/*Extract remaining 4 data sets*/
<putdata name="Impute" mult="2" dataout="impute_mult2"/>
<putdata name="Impute" mult="3" dataout="impute_mult3"/>
<putdata name="Impute" mult="4" dataout="impute_mult4"/>
<putdata name="Impute" mult="5" dataout="impute_mult5"/>

</stata>

Back to top

10.3 BBDESIGN Example, IVEware and SPSS

Section 10.3 demonstrates use of IVEware and SPSS with the BBDESIGN command to produce an output population data set called ”bbdesign samples.sav” (SPSS format). As usual, the output data set can be used in additional analyses within SPSS or transferred to another statistical software package.

<spss name="BBDESIGN Examples">
/* example uses 2011 - 2012 NHANES data, subset for age 18+ for adults*/
/* SPSS .sav file is stored in working folder */

<bbdesign name="BBdesign">
title Use of BBdesign;
datain nhanes1112_adult;
dataout bbdesign_samples ;
stratum sdmvstra ;
cluster sdmvpsu ;
weight wtmec2yr ;
csamples 5 ;
wsamples 5 ;
seed 2001;
run;
</bbdesign>
</spss>

Back to top

10.4 DESCRIBE Example, IVEware and R

The DESCRIBE command uses IVEware and R to perform a descriptive analysis of age of interview and Body Mass Index with a gender contrast. This examples uses NCS-R data with a design-based/multiple imputation approach for variance estimation. The five previously imputed NCS-R data sets are first imported into R and then used in the DESCRIBE command.

<R name="DESCRIBE Example">
# iveware examples - R version

# import the input datasets
impute_mult1 <- read.delim("impute_mult1.txt")
save(impute_mult1, file="impute_mult1.rda")

impute_mult2 <- read.delim("impute_mult2.txt")
save(impute_mult2, file="impute_mult2.rda")

impute_mult3 <- read.delim("impute_mult3.txt")
save(impute_mult3, file="impute_mult3.rda")

impute_mult4 <- read.delim("impute_mult4.txt")
save(impute_mult4, file="impute_mult4.rda")

impute_mult5 <- read.delim("impute_mult5.txt")
save(impute_mult5, file="impute_mult5.rda")

# Descriptive Analysis of Age at Interview and BMI
<describe name="DESCRIBE">
title MI Design-based Description;
datain impute_mult1 impute_mult2 impute_mult3 impute_mult4 impute_mult5;
stratum sestrat;
cluster seclustr;
weight ncsrwtsh ;
model mult;
mean intwage bmi;
contrast sexf;
run;
</describe>

</R>

Back to top

10.5 REGRESS Example, IVEware and Stata

The REGRESS example inputs five previously imputed NCS-R data sets and performs linear regression with IVEware and Stata. Note that the imputed input data sets were previously stored as Stata data sets in .dta format.

&60;stata name="REGRESS Example with Stata">
/* Analyze 5 imputed data sets with Linear Regression */
<regress name="REGRESS for Linear Regression with Imputed Data Sets">
title Example of REGRESS ;
datain impute_mult1 impute_mult2 impute_mult3 impute_mult4 impute_mult5 ;
estout impute_regress;
stratum sestrat;
cluster seclustr;
weight ncsrwtsh;
dependent bmi;
predictor mde sexf intwage ;
run;
</regress>
</stata>

Back to top

10.6 SYNTHESIZE Example, IVEware and Stata

This example uses IVEware and Stata to synthesize all variables in the Primary Cardiac Arrest data set. An output data set called ”synthesize.dta” contains the synthesized and multiply imputed data.

* Synthesize Example Using PCA and Omega 3 Fatty Acids Data */
<stata name="SYNTHESIZE Example">

<synthesize name="Synthesize All Variables Using PCA and Omega3 Data">
datain test;
continuous AGE NUMCIG YRSSMOKE FATINDEX DHA_EPA REDTOT WGTKG TOTLKCAL HGTCM ;
categorical CASECNT GENDER RACE3 HYPER DIAB SMOKE FAMMI EDUSUBJ3 CHOLESTH ;
mixed CAFFTOT ALCOHOL3 ;
transfer STUDYID ;
synthesize CASECNT AGE GENDER RACE3 HYPER DIAB SMOKE NUMCIG YRSSMOKE FATINDEX
   FAMMI EDUSUBJ3 DHA_EPA REDTOT CHOLESTH CAFFTOT WGTKG TOTLKCAL ALCOHOL3 HGTCM ;
restrict NUMCIG(smoke=2,3) YRSSMOKE(smoke=2,3) ;
bounds NUMCIG(>0) YRSSMOKE(>0, <age-12) DHA_EPA(>0) REDTOT(>0) CAFFTOT(>0) TOTLKCAL(>0) ALCOHOL3(>0);
ITERATIONS 2;
MULTIPLES 5;
SEED 2001;
IMPLICATES 5;
DATAOUT synthesize all ;
run;
</synthesize>
</stata>

Back to top

10.7 COMBINE Example, IVEware and R

The COMBINE example pairs IVEware with R to demonstrate how to combine multiple data sets. The four HRS data sets (2006, 2008, 2010, 2012) are first imported into R using the Foreign package and then concatenated by COMBINE. An output data set called “combined hrs 2006 2012” in R format is created for subsequent imputation and analysis.

<R name="COMBINE Example">
# iveware examples - R version

# load foreign package and read in SAS data sets
library(foreign)
hrs2006_27jul2016r <- read.xport("hrs2006_27jul2016.xpt")
hrs2008_27jul2016r <- read.xport("hrs2008_27jul2016.xpt")
hrs2010_27jul2016r <- read.xport("hrs2010_27jul2016.xpt")
hrs2012_27jul2016r <- read.xport("hrs2012_27jul2016.xpt")

<combine name="COMBINE_Example_R">
datain hrs2006_27jul2016r hrs2008_27jul2016r hrs2010_27jul2016r hrs2012_27jul2016r ;
dataout combined_hrs_2006_2012;
run;
</combine>

summary(combined_hrs_2006_2012)

</R>

Back to top