Learn R Programming

BIFIEsurvey (version 1.5-0)

BIFIE.data: Creates an Object of Class BIFIEdata

Description

This function creates an object of class BIFIEdata. Finite sampling correction of statistical inferences can be conducted by specifying appropriate input in the fayfac argument.

Usage

BIFIE.data(data.list, wgt = NULL, wgtrep = NULL , fayfac = 1, cdata=FALSE, NMI=FALSE)

## S3 method for class 'BIFIEdata':
summary(object,...)

Arguments

data.list
List of multiply imputed datasets. Can be also a list of list of imputed datasets in case of nested multiple imputation. Then, the argument NMI=TRUE must be specified.
wgt
A string indicating the label of case weight or a vector containing all case weights.
wgtrep
Optional vector of replicate weights
fayfac
Fay factor for calculating standard errors, a numeric value. If finite sampling correction is requested, an appropriate vector input can be used (see Example 3).
cdata
An optional logical indicating whether the BIFIEdata object should be compactly saved. The default is FALSE.
NMI
Optional logical indicating whether data.list is obtained by nested multiple imputation.
object
Object of class BIFIEdata
...
Further arguments to be passed

Value

  • An object of class BIFIEdata saved in a non-compact or compact way, see value cdata. The following entries are included in the list:
  • datalistMStacked list of imputed datasets (if cdata=FALSE)
  • wgtVector with case weights
  • wgtrepMatrix with replicate weights
  • NimpNumber of imputed datasets
  • NNumber of observations in a dataset
  • dat1Last imputed dataset
  • varnamesVector with variable names
  • fayfacFay factor.
  • RRNumber of replicate weights
  • NMILogical indicating whether the dataset is nested multiply imputed.
  • cdataLogical indicating whether the BIFIEdata object is in compact format (cdata=TRUE) or in a non-compact format (cdata=FALSE).
  • NvarsNumber of variables
  • variablesData frame including some informations about variables. All transformations are saved in the column source.
  • datalistM_indData frame with response indicators (if cdata=TRUE)
  • datalistM_imputedData frame with imputed values (if cdata=TRUE)

See Also

See BIFIE.data.transform for data transformations on BIFIEdata objects. For saving and loading BIFIEdata objects see save.BIFIEdata. For converting PIRLS/TIMSS or PISA datasets into BIFIEdata objects see BIFIE.data.jack.

Examples

Run this code
#############################################################################
# EXAMPLE 1: Create BIFIEdata object with multiply-imputed TIMSS data
#############################################################################
data(data.timss1)
data(data.timssrep)

bdat <- BIFIE.data( data.list=data.timss1 , wgt= data.timss1[[1]]$TOTWGT ,
            wgtrep=data.timssrep[, -1 ] )
summary(bdat)            
# create BIFIEdata object in a compact way
bdat2 <- BIFIE.data( data.list=data.timss1 , wgt= data.timss1[[1]]$TOTWGT ,
            wgtrep=data.timssrep[, -1 ] , cdata=TRUE)
summary(bdat2)  

#############################################################################
# EXAMPLE 2: Create BIFIEdata object with one dataset
#############################################################################
data(data.timss2)

# use first dataset with missing data from data.timss2
bdat <- BIFIE.data( data.list=data.timss2[[1]] , wgt=data.timss2[[1]]$TOTWGT )

#############################################################################
# EXAMPLE 3: BIFIEdata objects with finite sampling correction
#############################################################################

data(data.timss1)
data(data.timssrep)

#-----
# BIFIEdata object without finite sampling correction
bdat1 <- BIFIE.data( data.list=data.timss1 , wgt= data.timss1[[1]]$TOTWGT ,
            wgtrep=data.timssrep[, -1 ] )
summary(bdat1)            

#-----
# generate BIFIEdata object with finite sampling correction by adjusting 
# the "fayfac" factor
bdat2 <- bdat1
#-- modify "fayfac" constant
fayfac0 <- bdat1$fayfac
# set fayfac = .75 for the first 50 replication zones (25% of students in the
# population were sampled) and fayfac = .20 for replication zones 51-75
# (meaning that 80% of students were sampled)
fayfac <- rep( fayfac0 , bdat1$RR )
fayfac[1:50] <- fayfac0 * .75
fayfac[51:75] <- fayfac0 * .20
# include this modified "fayfac" factor in bdat2
bdat2$fayfac <- fayfac
summary(bdat2)
summary(bdat1)

#---- compare some univariate statistics
# no finite sampling correction
res1 <- BIFIE.univar( bdat1 , vars="ASMMAT")
summary(res1)
# finite sampling correction
res2 <- BIFIE.univar( bdat2 , vars="ASMMAT")
summary(res2)

#############################################################################
# EXAMPLE 4: Create BIFIEdata object with nested multiply imputed dataset
#############################################################################

data(data.timss4)
data(data.timssrep)

# nested imputed dataset, save it in compact format
bdat <- BIFIE.data( data.list=data.timss4 , wgt= data.timss4[[1]]$TOTWGT ,
            wgtrep=data.timssrep[, -1 ] , NMI=TRUE , cdata=TRUE )
summary(bdat)

Run the code above in your browser using DataLab