with.svyimputationList: Analyse multiple imputations

Description Usage Arguments Value See Also Examples

View source: R/svymi.R

Description

Performs a survey analysis on each of the designs in a svyimputationList objects and returns a list of results suitable for MIcombine. The analysis may be specified as an expression or as a function.

Usage

1
2
3
4
## S3 method for class 'svyimputationList'
with(data, expr, fun, ...,multicore=getOption("survey.multicore"))
## S3 method for class 'svyimputationList'
subset(x, subset,...)

Arguments

data,x

A svyimputationList object

expr

An expression giving a survey analysis

fun

A function taking a survey design object as its argument

...

for future expansion

multicore

Use multicore package to distribute imputed data sets over multiple processors?

subset

An logical expression specifying the subset

Value

A list of the results from applying the analysis to each design object.

See Also

MIcombine, in the mitools package

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
library(mitools)
data.dir<-system.file("dta",package="mitools")
files.men<-list.files(data.dir,pattern="m.\\.dta$",full=TRUE)
men<-imputationList(lapply(files.men, foreign::read.dta))
files.women<-list.files(data.dir,pattern="f.\\.dta$",full=TRUE)
women<-imputationList(lapply(files.women, foreign::read.dta))
men<-update(men, sex=1)
women<-update(women,sex=0)
all<-rbind(men,women)

designs<-svydesign(id=~id, strata=~sex, data=all)
designs

results<-with(designs, svymean(~drkfre))

MIcombine(results)

summary(MIcombine(results))

Example output

Loading required package: grid
Loading required package: Matrix
Loading required package: survival

Attaching package: 'survey'

The following object is masked from 'package:graphics':

    dotchart

Warning messages:
1: In FUN(X[[i]], ...) : value labels ('mis') for 'mdrkfre' are missing
2: In FUN(X[[i]], ...) : value labels ('mis') for 'mdrkfre' are missing
3: In FUN(X[[i]], ...) : value labels ('mis') for 'mdrkfre' are missing
4: In FUN(X[[i]], ...) : value labels ('mis') for 'mdrkfre' are missing
5: In FUN(X[[i]], ...) : value labels ('mis') for 'mdrkfre' are missing
Warning messages:
1: In FUN(X[[i]], ...) : value labels ('mis') for 'mdrkfre' are missing
2: In FUN(X[[i]], ...) : value labels ('mis') for 'mdrkfre' are missing
3: In FUN(X[[i]], ...) : value labels ('mis') for 'mdrkfre' are missing
4: In FUN(X[[i]], ...) : value labels ('mis') for 'mdrkfre' are missing
5: In FUN(X[[i]], ...) : value labels ('mis') for 'mdrkfre' are missing
Multiple (5) imputations: svydesign(id = ~id, strata = ~sex, data = all)
Multiple imputation results:
      with(designs, svymean(~drkfre))
      MIcombine.default(results)
                          results         se
drkfreNon drinker      0.41692308 0.02705950
drkfrenot in last wk   0.33555556 0.02082624
drkfre<3 days last wk  0.20632479 0.01701647
drkfre>=3 days last wk 0.04119658 0.00776177
Multiple imputation results:
      with(designs, svymean(~drkfre))
      MIcombine.default(results)
                          results         se     (lower     upper) missInfo
drkfreNon drinker      0.41692308 0.02705950 0.36387940 0.46996676      2 %
drkfrenot in last wk   0.33555556 0.02082624 0.29469352 0.37641759      6 %
drkfre<3 days last wk  0.20632479 0.01701647 0.17297052 0.23967906      2 %
drkfre>=3 days last wk 0.04119658 0.00776177 0.02596223 0.05643093      7 %

survey documentation built on Oct. 24, 2018, 3 a.m.