diff --git a/DESCRIPTION b/DESCRIPTION index 48f1714..5f9910c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: BIFIEsurvey Type: Package Title: Tools for Survey Statistics in Educational Assessment -Version: 3.6-2 -Date: 2024-02-18 19:47:04 +Version: 3.7-1 +Date: 2024-04-26 09:30:14 Author: BIFIE [aut], Alexander Robitzsch [aut, cre], Konrad Oberwimmer [aut] Maintainer: Alexander Robitzsch diff --git a/R/RcppExports.R b/R/RcppExports.R index b9ec7ae..4c02cb9 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -1,5 +1,5 @@ ## File Name: RcppExports.R -## File Version: 3.006002 +## File Version: 3.007001 # Generated by using Rcpp::compileAttributes() -> do not edit by hand # Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 diff --git a/README.md b/README.md index db56e1a..f35ce6b 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ all necessary information on the used librarys, the R version, and the OS it is The manual may be found here [https://alexanderrobitzsch.github.io/BIFIEsurvey/](https://alexanderrobitzsch.github.io/BIFIEsurvey/) -#### CRAN version `BIFIEsurvey` 3.5-19 (2024-02-18) +#### CRAN version `BIFIEsurvey` 3.6-6 (2024-04-25) [![CRAN_Status_Badge](http://www.r-pkg.org/badges/version-last-release/BIFIEsurvey)](https://cran.r-project.org/package=BIFIEsurvey) @@ -26,9 +26,9 @@ The CRAN version can be installed from within R using: utils::install.packages("BIFIEsurvey") ``` -#### GitHub version `BIFIEsurvey` 3.6-2 (2024-02-18) +#### GitHub version `BIFIEsurvey` 3.7-1 (2024-04-26) -[![](https://img.shields.io/badge/github%20version-3.6--2-orange.svg)](https://github.com/alexanderrobitzsch/BIFIEsurvey)   +[![](https://img.shields.io/badge/github%20version-3.7--1-orange.svg)](https://github.com/alexanderrobitzsch/BIFIEsurvey)   The version hosted [here](https://github.com/alexanderrobitzsch/BIFIEsurvey) is the development version of `BIFIEsurvey`. The GitHub version can be installed using `devtools` as: diff --git a/docs/404.html b/docs/404.html index 9e3d83f..27a6ad9 100644 --- a/docs/404.html +++ b/docs/404.html @@ -1,66 +1,27 @@ - - - - + + + + - Page not found (404) • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + - - - - -
-
- + +
+ + + - - -
+
+
-
- +
+ + - - diff --git a/docs/authors.html b/docs/authors.html index eb86974..760c956 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -1,66 +1,12 @@ - - - - - - - -Citation and Authors • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Authors and Citation • BIFIEsurvey - - + + - - -
-
- -
- -
+
-
-
- +
- - + + diff --git a/docs/index.html b/docs/index.html index 1f55f90..8b076a7 100644 --- a/docs/index.html +++ b/docs/index.html @@ -36,6 +36,8 @@ + +
-
- -
-

-Tools for Survey Statistics in Educational Assessment

-

If you use BIFIEsurvey and have suggestions for improvement or have found bugs, please email me at

-. +
+ +
+

Tools for Survey Statistics in Educational Assessment +

+

If you use BIFIEsurvey and have suggestions for improvement or have found bugs, please email me at . Please always provide a minimal dataset, necessary to demonstrate the problem, a minimal runnable code necessary to reproduce the issue, which can be run on the given dataset, and all necessary information on the used librarys, the R version, and the OS it is run on, perhaps a sessionInfo().

-
-

-Manual

-

The manual may be found here https://alexanderrobitzsch.github.io/BIFIEsurvey/

+
+

Manual +

+

The manual may be found here https://alexanderrobitzsch.github.io/BIFIEsurvey/

-
-

-CRAN version

+
+

CRAN version +

-

The official version of BIFIEsurvey is hosted on CRAN and may be found here. The CRAN version can be installed from within R using:

-
utils::install.packages("BIFIEsurvey")
+

The official version of BIFIEsurvey is hosted on CRAN and may be found here. The CRAN version can be installed from within R using:

+
+utils::install.packages("BIFIEsurvey")
-
-

-GitHub version

-

The version hosted here is the development version of BIFIEsurvey. The GitHub version can be installed using devtools as:

-
devtools::install_github("alexanderrobitzsch/BIFIEsurvey")
+
+

GitHub version +

+

The version hosted here is the development version of BIFIEsurvey. The GitHub version can be installed using devtools as:

+
+devtools::install_github("alexanderrobitzsch/BIFIEsurvey")
-

Site built with pkgdown 1.5.1.

+

+

Site built with pkgdown 2.0.7.

@@ -168,5 +166,7 @@

Developers

+ + diff --git a/docs/pkgdown.css b/docs/pkgdown.css index c01e592..80ea5b8 100644 --- a/docs/pkgdown.css +++ b/docs/pkgdown.css @@ -56,8 +56,10 @@ img.icon { float: right; } -img { +/* Ensure in-page images don't run outside their container */ +.contents img { max-width: 100%; + height: auto; } /* Fix bug in bootstrap (only seen in firefox) */ @@ -78,11 +80,10 @@ dd { /* Section anchors ---------------------------------*/ a.anchor { - margin-left: -30px; - display:inline-block; - width: 30px; - height: 30px; - visibility: hidden; + display: none; + margin-left: 5px; + width: 20px; + height: 20px; background-image: url(./link.svg); background-repeat: no-repeat; @@ -90,17 +91,15 @@ a.anchor { background-position: center center; } -.hasAnchor:hover a.anchor { - visibility: visible; -} - -@media (max-width: 767px) { - .hasAnchor:hover a.anchor { - visibility: hidden; - } +h1:hover .anchor, +h2:hover .anchor, +h3:hover .anchor, +h4:hover .anchor, +h5:hover .anchor, +h6:hover .anchor { + display: inline-block; } - /* Fixes for fixed navbar --------------------------*/ .contents h1, .contents h2, .contents h3, .contents h4 { @@ -244,14 +243,14 @@ nav[data-toggle='toc'] .nav .nav > .active:focus > a { .ref-index th {font-weight: normal;} -.ref-index td {vertical-align: top;} +.ref-index td {vertical-align: top; min-width: 100px} .ref-index .icon {width: 40px;} .ref-index .alias {width: 40%;} .ref-index-icons .alias {width: calc(40% - 40px);} .ref-index .title {width: 60%;} .ref-arguments th {text-align: right; padding-right: 10px;} -.ref-arguments th, .ref-arguments td {vertical-align: top;} +.ref-arguments th, .ref-arguments td {vertical-align: top; min-width: 100px} .ref-arguments .name {width: 20%;} .ref-arguments .desc {width: 80%;} @@ -264,31 +263,26 @@ table { /* Syntax highlighting ---------------------------------------------------- */ -pre { - word-wrap: normal; - word-break: normal; - border: 1px solid #eee; -} - -pre, code { +pre, code, pre code { background-color: #f8f8f8; color: #333; } +pre, pre code { + white-space: pre-wrap; + word-break: break-all; + overflow-wrap: break-word; +} -pre code { - overflow: auto; - word-wrap: normal; - white-space: pre; +pre { + border: 1px solid #eee; } -pre .img { +pre .img, pre .r-plt { margin: 5px 0; } -pre .img img { +pre .img img, pre .r-plt img { background-color: #fff; - display: block; - height: auto; } code a, pre a { @@ -305,9 +299,8 @@ a.sourceLine:hover { .kw {color: #264D66;} /* keyword */ .co {color: #888888;} /* comment */ -.message { color: black; font-weight: bolder;} -.error { color: orange; font-weight: bolder;} -.warning { color: #6A0366; font-weight: bolder;} +.error {font-weight: bolder;} +.warning {font-weight: bolder;} /* Clipboard --------------------------*/ @@ -365,3 +358,27 @@ mark { content: ""; } } + +/* Section anchors --------------------------------- + Added in pandoc 2.11: https://github.com/jgm/pandoc-templates/commit/9904bf71 +*/ + +div.csl-bib-body { } +div.csl-entry { + clear: both; +} +.hanging-indent div.csl-entry { + margin-left:2em; + text-indent:-2em; +} +div.csl-left-margin { + min-width:2em; + float:left; +} +div.csl-right-inline { + margin-left:2em; + padding-left:1em; +} +div.csl-indent { + margin-left: 2em; +} diff --git a/docs/pkgdown.js b/docs/pkgdown.js index 7e7048f..6f0eee4 100644 --- a/docs/pkgdown.js +++ b/docs/pkgdown.js @@ -80,7 +80,7 @@ $(document).ready(function() { var copyButton = ""; - $(".examples, div.sourceCode").addClass("hasCopyButton"); + $("div.sourceCode").addClass("hasCopyButton"); // Insert copy buttons: $(copyButton).prependTo(".hasCopyButton"); @@ -91,7 +91,7 @@ // Initialize clipboard: var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { text: function(trigger) { - return trigger.parentNode.textContent; + return trigger.parentNode.textContent.replace(/\n#>[^\n]*/g, ""); } }); diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 5acf368..af16fc6 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -1,6 +1,6 @@ -pandoc: 1.13.1 -pkgdown: 1.5.1 +pandoc: 3.1.1 +pkgdown: 2.0.7 pkgdown_sha: ~ -articles: [] -last_built: 2022-04-05T09:56Z +articles: {} +last_built: 2024-04-26T07:36Z diff --git a/docs/reference/BIFIE.BIFIEdata2BIFIEcdata.html b/docs/reference/BIFIE.BIFIEdata2BIFIEcdata.html index 0be101c..1f47b79 100644 --- a/docs/reference/BIFIE.BIFIEdata2BIFIEcdata.html +++ b/docs/reference/BIFIE.BIFIEdata2BIFIEcdata.html @@ -1,74 +1,19 @@ - - - - - - - -Conversion and Selection of <code>BIFIEdata</code> Objects — BIFIE.BIFIEdata2BIFIEcdata • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Conversion and Selection of BIFIEdata Objects — BIFIE.BIFIEdata2BIFIEcdata • BIFIEsurvey - - - - - - - - - - - - - + + -
-
- -
- -
+
-
BIFIE.BIFIEdata2BIFIEcdata(bifieobj, varnames=NULL, impdata.index=NULL)
-
-BIFIE.BIFIEcdata2BIFIEdata(bifieobj, varnames=NULL, impdata.index=NULL)
-
-BIFIE.BIFIEdata2datalist(bifieobj, varnames=NULL, impdata.index=NULL,
-    as_data_frame=FALSE)
- -

Arguments

- - - - - - - - - - - - - - - - - - -
bifieobj

Object of class BIFIEdata

varnames

Variables chosen for the selection

impdata.index

Selected indices of imputed datasets

as_data_frame

Logical indicating whether list of length one should -be converted into a data frame

- -

Value

- -

An object of class BIFIEdata saved in a non-compact -or compact way, see value cdata.

-

See also

- - - -

Examples

-
#############################################################################
-# EXAMPLE 1: BIFIEdata conversions using data.timss1 dataset
-#############################################################################
-data(data.timss1)
-data(data.timssrep)
-
-# create BIFIEdata object
-bdat1 <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
-            wgtrep=data.timssrep[, -1 ])
-summary(bdat1)
+    
+
BIFIE.BIFIEdata2BIFIEcdata(bifieobj, varnames=NULL, impdata.index=NULL)
+
+BIFIE.BIFIEcdata2BIFIEdata(bifieobj, varnames=NULL, impdata.index=NULL)
+
+BIFIE.BIFIEdata2datalist(bifieobj, varnames=NULL, impdata.index=NULL,
+    as_data_frame=FALSE)
+
-# convert BIFIEdata object bdat1 into a BIFIEcdata object with -# only using the first three datasets and a variable selection -bdat2 <- BIFIEsurvey::BIFIE.BIFIEdata2BIFIEcdata( bifieobj=bdat1, - varnames=bdat1$varnames[ c(1:7,10) ] ) +
+

Arguments

+
bifieobj
+

Object of class BIFIEdata

-# convert bdat2 into BIFIEdata object and only use the first three imputed datasets -bdat3 <- BIFIEsurvey::BIFIE.BIFIEcdata2BIFIEdata( bifieobj=bdat2, impdata.index=1:3) +
varnames
+

Variables chosen for the selection

-# object summaries -summary(bdat1) -summary(bdat2) -summary(bdat3) +
impdata.index
+

Selected indices of imputed datasets

-if (FALSE) { -############################################################################# -# EXAMPLE 2: Extract unique elements in BIFIEdata object -############################################################################# +
as_data_frame
+

Logical indicating whether list of length one should +be converted into a data frame

-data(data.timss1) -data(data.timssrep) +
+
+

Value

+ -# create BIFIEdata object -bifieobj <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT, - wgtrep=data.timssrep[, -1 ]) -summary(bifieobj) +

An object of class BIFIEdata saved in a non-compact +or compact way, see value cdata.

+
+
+

See also

+ +
-# define variables for which unique values should be extracted -vars <- c( "female", "books","ASMMAT" ) -# convert these variables from BIFIEdata object into a list of datasets -bdatlist <- BIFIEsurvey::BIFIE.BIFIEdata2datalist( bifieobj, varnames=vars ) -# look for unique values in first dataset for variables -values <- lapply( bdatlist[[1]], FUN=function(vv){ - sort( unique( vv ) ) } ) -# number of unique values in first dataset -Nvalues <- lapply( bdatlist[[1]], FUN=function(vv){ - length( unique( vv ) ) } ) -# number of unique values in all datasets -Nvalues2 <- lapply( vars, FUN=function(vv){ - #vv <- vars[1] - unlist( lapply( bdatlist, FUN=function(dd){ - length( unique( dd[,vv] ) ) - } ) ) - } ) -# --> for extracting the number of unique values using BIFIE.by and a user -# defined function see Example 1, Model 3 in "BIFIE.by" -}
+
+

Examples

+
#############################################################################
+# EXAMPLE 1: BIFIEdata conversions using data.timss1 dataset
+#############################################################################
+data(data.timss1)
+data(data.timssrep)
+
+# create BIFIEdata object
+bdat1 <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
+            wgtrep=data.timssrep[, -1 ])
+summary(bdat1)
+
+# convert BIFIEdata object bdat1 into a BIFIEcdata object with
+#  only using the first three datasets and a variable selection
+bdat2 <- BIFIEsurvey::BIFIE.BIFIEdata2BIFIEcdata( bifieobj=bdat1,
+                varnames=bdat1$varnames[ c(1:7,10) ] )
+
+# convert bdat2 into BIFIEdata object and only use the first three imputed datasets
+bdat3 <- BIFIEsurvey::BIFIE.BIFIEcdata2BIFIEdata( bifieobj=bdat2, impdata.index=1:3)
+
+# object summaries
+summary(bdat1)
+summary(bdat2)
+summary(bdat3)
+
+if (FALSE) {
+#############################################################################
+# EXAMPLE 2: Extract unique elements in BIFIEdata object
+#############################################################################
+
+data(data.timss1)
+data(data.timssrep)
+
+# create BIFIEdata object
+bifieobj <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
+            wgtrep=data.timssrep[, -1 ])
+summary(bifieobj)
+
+# define variables for which unique values should be extracted
+vars <- c( "female", "books","ASMMAT" )
+# convert these variables from BIFIEdata object into a list of datasets
+bdatlist <- BIFIEsurvey::BIFIE.BIFIEdata2datalist( bifieobj, varnames=vars )
+# look for unique values in first dataset for variables
+values <- lapply( bdatlist[[1]], FUN=function(vv){
+                sort( unique( vv ) ) } )
+# number of unique values in first dataset
+Nvalues <- lapply( bdatlist[[1]], FUN=function(vv){
+                length( unique( vv ) ) } )
+# number of unique values in all datasets
+Nvalues2 <- lapply( vars, FUN=function(vv){
+    #vv <- vars[1]
+    unlist( lapply( bdatlist, FUN=function(dd){
+                length( unique( dd[,vv]  ) )
+                        }    )     )
+                    } )
+# --> for extracting the number of unique values using BIFIE.by and a user
+#     defined function see Example 1, Model 3 in "BIFIE.by"
+}
+
+
-
- +
- - + + diff --git a/docs/reference/BIFIE.by.html b/docs/reference/BIFIE.by.html index ffef9fa..a13aaf3 100644 --- a/docs/reference/BIFIE.by.html +++ b/docs/reference/BIFIE.by.html @@ -1,67 +1,12 @@ - - - - - - - -Statistics for User Defined Functions — BIFIE.by • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Statistics for User Defined Functions — BIFIE.by • BIFIEsurvey - - - - + + -
-
- -
- -
+
-
BIFIE.by( BIFIEobj, vars, userfct, userparnames=NULL,
-     group=NULL, group_values=NULL, se=TRUE, use_Rcpp=TRUE)
-
-# S3 method for BIFIE.by
-summary(object,digits=4,...)
-
-# S3 method for BIFIE.by
-coef(object,...)
-
-# S3 method for BIFIE.by
-vcov(object,...)
- -

Arguments

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BIFIEobj

Object of class BIFIEdata

vars

Vector of variables for which statistics should be computed

userfct

User defined function. This function must include +

+
BIFIE.by( BIFIEobj, vars, userfct, userparnames=NULL,
+     group=NULL, group_values=NULL, se=TRUE, use_Rcpp=TRUE)
+
+# S3 method for BIFIE.by
+summary(object,digits=4,...)
+
+# S3 method for BIFIE.by
+coef(object,...)
+
+# S3 method for BIFIE.by
+vcov(object,...)
+
+ +
+

Arguments

+
BIFIEobj
+

Object of class BIFIEdata

+ +
vars
+

Vector of variables for which statistics should be computed

+ +
userfct
+

User defined function. This function must include a matrix X and a weight vector w as -arguments. The value of this function must be a vector.

userparnames

An optional vector of parameter names for the - value of userfct.

group

Optional grouping variable(s)

group_values

Optional vector of grouping values. This can be omitted and grouping -values will be determined automatically.

se

Optional logical indicating whether statistical inference -based on replication should be employed.

use_Rcpp

Optional logical indicating whether the user defined -function should be evaluated in Rcpp.

object

Object of class BIFIE.by

digits

Number of digits for rounding output

...

Further arguments to be passed

- -

Value

- -

A list with following entries

-
stat

Data frame with statistics defined in userfct

-
output

Extensive output with all replicated statistics

-
...

More values

- -

See also

- - - -

Examples

-
#############################################################################
-# EXAMPLE 1: Imputed TIMSS dataset
-#############################################################################
-
-data(data.timss1)
-data(data.timssrep)
-
-# create BIFIE.dat object
-bifieobj <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
-           wgtrep=data.timssrep[, -1 ] )
-
-#****************************
-#*** Model 1: Weighted means (as a toy example)
-userfct <- function(X,w){
-        pars <- c( stats::weighted.mean( X[,1], w ),
-                     stats::weighted.mean(X[,2], w )   )
-        return(pars)
-                        }
-res1 <-  BIFIEsurvey::BIFIE.by( bifieobj, vars=c("ASMMAT", "migrant", "books"),
-                userfct=userfct, userparnames=c("MW_MAT", "MW_Migr"),
-                group="female" )
-summary(res1)
-
-# evaluate function in pure R implementation using the use_Rcpp argument
-res1b <-  BIFIEsurvey::BIFIE.by( bifieobj, vars=c("ASMMAT", "migrant", "books" ),
-                userfct=userfct, userparnames=c("MW_MAT", "MW_Migr"),
-                group="female", use_Rcpp=FALSE )
-summary(res1b)
-
-#--- statistical inference for a derived parameter (see ?BIFIE.derivedParameters)
-# define gender difference for mathematics score (divided by 100)
-derived.parameters <- list(
-        "gender_diff"=~ 0 + I( ( MW_MAT_female1 - MW_MAT_female0 ) / 100 )
-                            )
-# inference derived parameter
-res1d <- BIFIEsurvey::BIFIE.derivedParameters( res1,
-                derived.parameters=derived.parameters )
-summary(res1d)
-
-if (FALSE) {
-#****************************
-#**** Model 2: Robust linear model
-
-# (1) start from scratch to formulate the user function for X and w
-dat1 <- bifieobj$dat1
-vars <- c("ASMMAT", "migrant", "books" )
-X <- dat1[,vars]
-w <- bifieobj$wgt
-library(MASS)
-# ASMMAT ~ migrant + books
-mod <- MASS::rlm( X[,1] ~  as.matrix( X[, -1 ] ), weights=w )
-coef(mod)
-# (2) define a user function "my_rlm"
-my_rlm <- function(X,w){
-    mod <- MASS::rlm( X[,1] ~  as.matrix( X[, -1 ] ), weights=w )
-    return( coef(mod) )
-                }
-# (3) estimate model
-res2 <-  BIFIEsurvey::BIFIE.by( bifieobj, vars, userfct=my_rlm,
-                group="female", group_values=0:1)
-summary(res2)
-# estimate model without computing standard errors
-res2a <-  BIFIEsurvey::BIFIE.by( bifieobj, vars, userfct=my_rlm,
-                group="female", se=FALSE)
-summary(res2a)
-
-# define a user function with formula language
-my_rlm2 <- function(X,w){
-    colnames(X) <- vars
-    X <- as.data.frame(X)
-    mod <- MASS::rlm( ASMMAT ~  migrant + books, weights=w, data=X)
-    return( coef(mod) )
-                }
-# estimate model
-res2b <-  BIFIEsurvey::BIFIE.by( bifieobj, vars, userfct=my_rlm2,
-                group="female", group_values=0:1)
-summary(res2b)
-
-
-#****************************
-#**** Model 3: Number of unique values for variables in BIFIEdata
-
-#*** define variables for which the number of unique values should be calculated
-vars <- c( "female", "books","ASMMAT" )
-#*** define a user function extracting these unqiue values
-userfct <- function(X,w){
-        pars <- apply( X, 2, FUN=function(vv){
-                     length( unique(vv))  } )
-        # Note that weights are (of course) ignored in this function
-        return(pars)
-                        }
-#*** extract number of unique values
-res3 <-  BIFIEsurvey::BIFIE.by( bifieobj, vars=vars, userfct=userfct,
-              userparnames=paste0( vars, "_Nunique"),  se=FALSE )
-summary(res3)
-  ##   Statistical Inference for User Definition Function
-  ##               parm Ncases  Nweight    est
-  ##   1 female_Nunique   4668 78332.99    2.0
-  ##   2  books_Nunique   4668 78332.99    5.0
-  ##   3 ASMMAT_Nunique   4668 78332.99 4613.4
-# number of unique values in each of the five imputed datasets
-res3$output$parsrepM
-  ##        [,1] [,2] [,3] [,4] [,5]
-  ##   [1,]    2    2    2    2    2
-  ##   [2,]    5    5    5    5    5
-  ##   [3,] 4617 4619 4614 4609 4608
-
-#****************************
-#**** Model 4: Estimation of a lavaan model with BIFIE.by
-
-#* estimate model in lavaan
-
-data0 <- data.timss1[[1]]
-# define lavaan model
-lavmodel <- "
-  ASSSCI ~ likesc
-  ASSSCI ~~ ASSSCI
-  likesc ~ female
-  likesc ~~ likesc
-  female ~~ female
-"
-
-mod0 <- lavaan::lavaan(lavmodel, data=data0, sampling.weights="TOTWGT")
-summary(mod0, stand=TRUE, fit.measures=TRUE)
-
-#* construct input for BIFIE.by
-vars <- c("ASSSCI","likesc","female","TOTWGT")
-X <- data0[,vars]
-mod0 <- lavaan::lavaan(lavmodel, data=X, sampling.weights="TOTWGT")
-w <- data0$TOTWGT
-
-#* define user function
-userfct <- function(X,w){
-  X1 <- as.data.frame(X)
-  colnames(X1) <- vars
-  X1$studwgt <- w
-  mod0 <- lavaan::lavaan(lavmodel, data=X1, sampling.weights="TOTWGT")
-  pars <- coef(mod0)
-  # extract some fit statistics
-  pars2 <- lavaan::fitMeasures(mod0)
-  pars <- c(pars, pars2[c("cfi","tli")])
-  return(pars)
-}
-
-#* test function
-res0 <- userfct(X,w)
-userparnames <- names(res0)
-
-#* estimate lavaan model with replicated sampling weights
-res1 <-  BIFIEsurvey::BIFIE.by( bifieobj, vars=vars, userfct=userfct,
-                  userparnames=userparnames, use_Rcpp=FALSE )
-summary(res1)
-}
+arguments. The value of this function must be a vector.

+ +
userparnames
+

An optional vector of parameter names for the + value of userfct.

+ +
group
+

Optional grouping variable(s)

+ +
group_values
+

Optional vector of grouping values. This can be omitted and grouping +values will be determined automatically.

+ +
se
+

Optional logical indicating whether statistical inference +based on replication should be employed.

+ +
use_Rcpp
+

Optional logical indicating whether the user defined +function should be evaluated in Rcpp.

+ +
object
+

Object of class BIFIE.by

+ +
digits
+

Number of digits for rounding output

+ +
...
+

Further arguments to be passed

+ +
+
+

Value

+ + +

A list with following entries

+
stat
+

Data frame with statistics defined in userfct

+ +
output
+

Extensive output with all replicated statistics

+ +
...
+

More values

+ +
+
+

See also

+

survey::svyby

+
+ +
+

Examples

+
#############################################################################
+# EXAMPLE 1: Imputed TIMSS dataset
+#############################################################################
+
+data(data.timss1)
+data(data.timssrep)
+
+# create BIFIE.dat object
+bifieobj <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
+           wgtrep=data.timssrep[, -1 ] )
+
+#****************************
+#*** Model 1: Weighted means (as a toy example)
+userfct <- function(X,w){
+        pars <- c( stats::weighted.mean( X[,1], w ),
+                     stats::weighted.mean(X[,2], w )   )
+        return(pars)
+                        }
+res1 <-  BIFIEsurvey::BIFIE.by( bifieobj, vars=c("ASMMAT", "migrant", "books"),
+                userfct=userfct, userparnames=c("MW_MAT", "MW_Migr"),
+                group="female" )
+summary(res1)
+
+# evaluate function in pure R implementation using the use_Rcpp argument
+res1b <-  BIFIEsurvey::BIFIE.by( bifieobj, vars=c("ASMMAT", "migrant", "books" ),
+                userfct=userfct, userparnames=c("MW_MAT", "MW_Migr"),
+                group="female", use_Rcpp=FALSE )
+summary(res1b)
+
+#--- statistical inference for a derived parameter (see ?BIFIE.derivedParameters)
+# define gender difference for mathematics score (divided by 100)
+derived.parameters <- list(
+        "gender_diff"=~ 0 + I( ( MW_MAT_female1 - MW_MAT_female0 ) / 100 )
+                            )
+# inference derived parameter
+res1d <- BIFIEsurvey::BIFIE.derivedParameters( res1,
+                derived.parameters=derived.parameters )
+summary(res1d)
+
+if (FALSE) {
+#****************************
+#**** Model 2: Robust linear model
+
+# (1) start from scratch to formulate the user function for X and w
+dat1 <- bifieobj$dat1
+vars <- c("ASMMAT", "migrant", "books" )
+X <- dat1[,vars]
+w <- bifieobj$wgt
+library(MASS)
+# ASMMAT ~ migrant + books
+mod <- MASS::rlm( X[,1] ~  as.matrix( X[, -1 ] ), weights=w )
+coef(mod)
+# (2) define a user function "my_rlm"
+my_rlm <- function(X,w){
+    mod <- MASS::rlm( X[,1] ~  as.matrix( X[, -1 ] ), weights=w )
+    return( coef(mod) )
+                }
+# (3) estimate model
+res2 <-  BIFIEsurvey::BIFIE.by( bifieobj, vars, userfct=my_rlm,
+                group="female", group_values=0:1)
+summary(res2)
+# estimate model without computing standard errors
+res2a <-  BIFIEsurvey::BIFIE.by( bifieobj, vars, userfct=my_rlm,
+                group="female", se=FALSE)
+summary(res2a)
+
+# define a user function with formula language
+my_rlm2 <- function(X,w){
+    colnames(X) <- vars
+    X <- as.data.frame(X)
+    mod <- MASS::rlm( ASMMAT ~  migrant + books, weights=w, data=X)
+    return( coef(mod) )
+                }
+# estimate model
+res2b <-  BIFIEsurvey::BIFIE.by( bifieobj, vars, userfct=my_rlm2,
+                group="female", group_values=0:1)
+summary(res2b)
+
+
+#****************************
+#**** Model 3: Number of unique values for variables in BIFIEdata
+
+#*** define variables for which the number of unique values should be calculated
+vars <- c( "female", "books","ASMMAT" )
+#*** define a user function extracting these unqiue values
+userfct <- function(X,w){
+        pars <- apply( X, 2, FUN=function(vv){
+                     length( unique(vv))  } )
+        # Note that weights are (of course) ignored in this function
+        return(pars)
+                        }
+#*** extract number of unique values
+res3 <-  BIFIEsurvey::BIFIE.by( bifieobj, vars=vars, userfct=userfct,
+              userparnames=paste0( vars, "_Nunique"),  se=FALSE )
+summary(res3)
+  ##   Statistical Inference for User Definition Function
+  ##               parm Ncases  Nweight    est
+  ##   1 female_Nunique   4668 78332.99    2.0
+  ##   2  books_Nunique   4668 78332.99    5.0
+  ##   3 ASMMAT_Nunique   4668 78332.99 4613.4
+# number of unique values in each of the five imputed datasets
+res3$output$parsrepM
+  ##        [,1] [,2] [,3] [,4] [,5]
+  ##   [1,]    2    2    2    2    2
+  ##   [2,]    5    5    5    5    5
+  ##   [3,] 4617 4619 4614 4609 4608
+
+#****************************
+#**** Model 4: Estimation of a lavaan model with BIFIE.by
+
+#* estimate model in lavaan
+
+data0 <- data.timss1[[1]]
+# define lavaan model
+lavmodel <- "
+  ASSSCI ~ likesc
+  ASSSCI ~~ ASSSCI
+  likesc ~ female
+  likesc ~~ likesc
+  female ~~ female
+"
+
+mod0 <- lavaan::lavaan(lavmodel, data=data0, sampling.weights="TOTWGT")
+summary(mod0, stand=TRUE, fit.measures=TRUE)
+
+#* construct input for BIFIE.by
+vars <- c("ASSSCI","likesc","female","TOTWGT")
+X <- data0[,vars]
+mod0 <- lavaan::lavaan(lavmodel, data=X, sampling.weights="TOTWGT")
+w <- data0$TOTWGT
+
+#* define user function
+userfct <- function(X,w){
+  X1 <- as.data.frame(X)
+  colnames(X1) <- vars
+  X1$studwgt <- w
+  mod0 <- lavaan::lavaan(lavmodel, data=X1, sampling.weights="TOTWGT")
+  pars <- coef(mod0)
+  # extract some fit statistics
+  pars2 <- lavaan::fitMeasures(mod0)
+  pars <- c(pars, pars2[c("cfi","tli")])
+  return(pars)
+}
+
+#* test function
+res0 <- userfct(X,w)
+userparnames <- names(res0)
+
+#* estimate lavaan model with replicated sampling weights
+res1 <-  BIFIEsurvey::BIFIE.by( bifieobj, vars=vars, userfct=userfct,
+                  userparnames=userparnames, use_Rcpp=FALSE )
+summary(res1)
+}
+
+
-
- +
- - + + diff --git a/docs/reference/BIFIE.correl.html b/docs/reference/BIFIE.correl.html index 5166441..07c198f 100644 --- a/docs/reference/BIFIE.correl.html +++ b/docs/reference/BIFIE.correl.html @@ -1,67 +1,12 @@ - - - - - - - -Correlations and Covariances — BIFIE.correl • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Correlations and Covariances — BIFIE.correl • BIFIEsurvey - - - - + + -
-
- -
- -
+
-
BIFIE.correl(BIFIEobj, vars, group=NULL, group_values=NULL, se=TRUE)
-
-# S3 method for BIFIE.correl
-summary(object,digits=4, ...)
-
-# S3 method for BIFIE.correl
-coef(object,type=NULL, ...)
-
-# S3 method for BIFIE.correl
-vcov(object,type=NULL, ...)
- -

Arguments

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BIFIEobj

Object of class BIFIEdata

vars

Vector of variables for which statistics should be computed

group

Optional grouping variable(s)

group_values

Optional vector of grouping values. This can be omitted and grouping -values will be determined automatically.

se

Optional logical indicating whether statistical inference -based on replication should be employed.

object

Object of class BIFIE.correl

digits

Number of digits for rounding output

type

If type="cov", then covariances instead of -correlations are extracted.

...

Further arguments to be passed

- -

Value

- -

A list with following entries

-
stat.cor

Data frame with correlation statistics

-
stat.cov

Data frame with covariance statistics

-
cor_matrix

List of estimated correlation matrices

-
cov_matrix

List of estimated covariance matrices

-
output

Extensive output with all replicated statistics

-
...

More values

- -

See also

- -

stats::cov.wt, +

+
BIFIE.correl(BIFIEobj, vars, group=NULL, group_values=NULL, se=TRUE)
+
+# S3 method for BIFIE.correl
+summary(object,digits=4, ...)
+
+# S3 method for BIFIE.correl
+coef(object,type=NULL, ...)
+
+# S3 method for BIFIE.correl
+vcov(object,type=NULL, ...)
+
+ +
+

Arguments

+
BIFIEobj
+

Object of class BIFIEdata

+ +
vars
+

Vector of variables for which statistics should be computed

+ +
group
+

Optional grouping variable(s)

+ +
group_values
+

Optional vector of grouping values. This can be omitted and grouping +values will be determined automatically.

+ +
se
+

Optional logical indicating whether statistical inference +based on replication should be employed.

+ +
object
+

Object of class BIFIE.correl

+ +
digits
+

Number of digits for rounding output

+ +
type
+

If type="cov", then covariances instead of +correlations are extracted.

+ +
...
+

Further arguments to be passed

+ +
+
+

Value

+ + +

A list with following entries

+
stat.cor
+

Data frame with correlation statistics

+ +
stat.cov
+

Data frame with covariance statistics

+ +
cor_matrix
+

List of estimated correlation matrices

+ +
cov_matrix
+

List of estimated covariance matrices

+ +
output
+

Extensive output with all replicated statistics

+ +
...
+

More values

+ +
+
+

See also

+

stats::cov.wt, intsvy::timss.rho, intsvy::timss.rho.pv, -Hmisc::rcorr, -miceadds::ma.wtd.corNA

- -

Examples

-
#############################################################################
-# EXAMPLE 1: Imputed TIMSS dataset
-#############################################################################
-
-data(data.timss1)
-data(data.timssrep)
-
-# create BIFIE.dat object
-bdat <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
-           wgtrep=data.timssrep[, -1 ] )
-
-# Correlations splitted by gender
-res1 <- BIFIEsurvey::BIFIE.correl( bdat, vars=c("lang", "books", "migrant" ),
-              group="female", group_values=0:1 )
-summary(res1)
-
-# Correlations splitted by gender: no statistical inference (se=FALSE)
-res1a <- BIFIEsurvey::BIFIE.correl( bdat, vars=c("lang", "books", "migrant" ),
-              group="female", group_values=0:1, se=FALSE)
-summary(res1a)
+Hmisc::rcorr, +miceadds::ma.wtd.corNA

+
+ +
+

Examples

+
#############################################################################
+# EXAMPLE 1: Imputed TIMSS dataset
+#############################################################################
+
+data(data.timss1)
+data(data.timssrep)
+
+# create BIFIE.dat object
+bdat <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
+           wgtrep=data.timssrep[, -1 ] )
+
+# Correlations splitted by gender
+res1 <- BIFIEsurvey::BIFIE.correl( bdat, vars=c("lang", "books", "migrant" ),
+              group="female", group_values=0:1 )
+summary(res1)
+
+# Correlations splitted by gender: no statistical inference (se=FALSE)
+res1a <- BIFIEsurvey::BIFIE.correl( bdat, vars=c("lang", "books", "migrant" ),
+              group="female", group_values=0:1, se=FALSE)
+summary(res1a)
+
+
-
- +
- - + + diff --git a/docs/reference/BIFIE.crosstab.html b/docs/reference/BIFIE.crosstab.html index 46eae21..0dec09b 100644 --- a/docs/reference/BIFIE.crosstab.html +++ b/docs/reference/BIFIE.crosstab.html @@ -1,67 +1,12 @@ - - - - - - - -Cross Tabulation — BIFIE.crosstab • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Cross Tabulation — BIFIE.crosstab • BIFIEsurvey - - - - + + -
-
- -
- -
+
-
BIFIE.crosstab( BIFIEobj, vars1, vars2, vars_values1=NULL, vars_values2=NULL,
-     group=NULL, group_values=NULL, se=TRUE )
-
-# S3 method for BIFIE.crosstab
-summary(object,digits=3,...)
-
-# S3 method for BIFIE.crosstab
-coef(object,...)
-
-# S3 method for BIFIE.crosstab
-vcov(object,...)
- -

Arguments

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BIFIEobj

Object of class BIFIEdata

vars1

Row variable

vars2

Column variable

vars_values1

Optional vector of values of variable vars1

vars_values2

Optional vector of values of variable vars2

group

Optional grouping variable(s)

group_values

Optional vector of grouping values. This can be omitted and grouping -values will be determined automatically.

se

Optional logical indicating whether statistical inference -based on replication should be employed.

object

Object of class BIFIE.univar

digits

Number of digits for rounding output

...

Further arguments to be passed

- -

Value

- -

A list with following entries

-
stat.probs

Statistics for joint and conditional probabilities

-
stat.marg

Statistics for marginal probabilities

-
stat.es

Statistics for effect sizes \(w\) (based on \(\chi^2\)), - Cramers \(V\), Goodman's gamma, the PRE lambda measure and - Kruskals tau.

-
output

Extensive output with all replicated statistics

-
...

More values

+
+
BIFIE.crosstab( BIFIEobj, vars1, vars2, vars_values1=NULL, vars_values2=NULL,
+     group=NULL, group_values=NULL, se=TRUE )
+
+# S3 method for BIFIE.crosstab
+summary(object,digits=3,...)
+
+# S3 method for BIFIE.crosstab
+coef(object,...)
+
+# S3 method for BIFIE.crosstab
+vcov(object,...)
+
+ +
+

Arguments

+
BIFIEobj
+

Object of class BIFIEdata

+ +
vars1
+

Row variable

-

See also

+
vars2
+

Column variable

- +
vars_values1
+

Optional vector of values of variable vars1

-

Examples

-
#############################################################################
-# EXAMPLE 1: Imputed TIMSS dataset
-#############################################################################
+
vars_values2
+

Optional vector of values of variable vars2

-data(data.timss1) -data(data.timssrep) +
group
+

Optional grouping variable(s)

-# create BIFIE.dat object -bifieobj <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT, - wgtrep=data.timssrep[, -1 ] ) +
group_values
+

Optional vector of grouping values. This can be omitted and grouping +values will be determined automatically.

+ +
se
+

Optional logical indicating whether statistical inference +based on replication should be employed.

+ +
object
+

Object of class BIFIE.univar

+ +
digits
+

Number of digits for rounding output

+ +
...
+

Further arguments to be passed

+ +
+
+

Value

+ -#--- Model 1: cross tabulation -res1 <- BIFIEsurvey::BIFIE.crosstab( bifieobj, vars1="migrant", - vars2="books", group="female" ) -summary(res1) +

A list with following entries

+
stat.probs
+

Statistics for joint and conditional probabilities

+ +
stat.marg
+

Statistics for marginal probabilities

+ +
stat.es
+

Statistics for effect sizes \(w\) (based on \(\chi^2\)), + Cramers \(V\), Goodman's gamma, the PRE lambda measure and + Kruskals tau.

+ +
output
+

Extensive output with all replicated statistics

+ +
...
+

More values

+ +
+
+

See also

+

survey::svytable, +Hmisc::wtd.table

+
+ +
+

Examples

+
#############################################################################
+# EXAMPLE 1: Imputed TIMSS dataset
+#############################################################################
+
+data(data.timss1)
+data(data.timssrep)
+
+# create BIFIE.dat object
+bifieobj <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
+           wgtrep=data.timssrep[, -1 ] )
+
+#--- Model 1: cross tabulation
+res1 <- BIFIEsurvey::BIFIE.crosstab( bifieobj, vars1="migrant",
+               vars2="books", group="female" )
+summary(res1)
+
+
-
- +
- - + + diff --git a/docs/reference/BIFIE.data.boot.html b/docs/reference/BIFIE.data.boot.html index 1e839e2..e02ac57 100644 --- a/docs/reference/BIFIE.data.boot.html +++ b/docs/reference/BIFIE.data.boot.html @@ -1,68 +1,13 @@ - - - - - - - -Create <code>BIFIE.data</code> Object based on Bootstrap — BIFIE.data.boot • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create BIFIE.data Object based on Bootstrap — BIFIE.data.boot • BIFIEsurvey - - - - + + -
-
- -
- -
+
-
BIFIE.data.boot( data, wgt=NULL,  pv_vars=NULL,
-         Nboot=500, seed=.Random.seed, cdata=FALSE)
- -

Arguments

- - - - - - - - - - - - - - - - - - - - - - - - - - -
data

Data frame: Can be a single or a list of multiply imputed datasets

wgt

A string indicating the label of case weight.

pv_vars

An optional vector of plausible values which define multiply -imputed datasets.

Nboot

Number of -bootstrap samples for usage

seed

Simulation seed.

cdata

An optional logical indicating whether the BIFIEdata -object should be compactly saved. The default is FALSE.

- -

Value

- -

Object of class BIFIEdata

-

See also

- - - -

Examples

-
if (FALSE) {
-#############################################################################
-# EXAMPLE 1: Bootstrap TIMSS data set
-#############################################################################
-data(data.timss1)
-
-# bootstrap samples using weights
-bifieobj1 <- BIFIEsurvey::BIFIE.data.boot( data.timss1, wgt="TOTWGT" )
-summary(bifieobj1)
-
-# bootstrap samples without weights
-bifieobj2 <- BIFIEsurvey::BIFIE.data.boot( data.timss1  )
-summary(bifieobj2)
-}
+
+
BIFIE.data.boot( data, wgt=NULL,  pv_vars=NULL,
+         Nboot=500, seed=.Random.seed, cdata=FALSE)
+
+ +
+

Arguments

+
data
+

Data frame: Can be a single or a list of multiply imputed datasets

+ +
wgt
+

A string indicating the label of case weight.

+ +
pv_vars
+

An optional vector of plausible values which define multiply +imputed datasets.

+ +
Nboot
+

Number of +bootstrap samples for usage

+ +
seed
+

Simulation seed.

+ +
cdata
+

An optional logical indicating whether the BIFIEdata +object should be compactly saved. The default is FALSE.

+ +
+
+

Value

+ + +

Object of class BIFIEdata

+ + +
+
+

See also

+ +
+ +
+

Examples

+
if (FALSE) {
+#############################################################################
+# EXAMPLE 1: Bootstrap TIMSS data set
+#############################################################################
+data(data.timss1)
+
+# bootstrap samples using weights
+bifieobj1 <- BIFIEsurvey::BIFIE.data.boot( data.timss1, wgt="TOTWGT" )
+summary(bifieobj1)
+
+# bootstrap samples without weights
+bifieobj2 <- BIFIEsurvey::BIFIE.data.boot( data.timss1  )
+summary(bifieobj2)
+}
+
+
-
- +
- - + + diff --git a/docs/reference/BIFIE.data.html b/docs/reference/BIFIE.data.html index f5aca18..0d31ce2 100644 --- a/docs/reference/BIFIE.data.html +++ b/docs/reference/BIFIE.data.html @@ -1,70 +1,15 @@ - - - - - - - -Creates an Object of Class <code>BIFIEdata</code> — BIFIE.data • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Creates an Object of Class BIFIEdata — BIFIE.data • BIFIEsurvey - - - - - - - - - - - - - + + -
-
- -
- -
+
-
BIFIE.data(data.list, wgt=NULL, wgtrep=NULL, fayfac=1, pv_vars=NULL,
-     pvpre=NULL, cdata=FALSE, NMI=FALSE)
+    
+
BIFIE.data(data.list, wgt=NULL, wgtrep=NULL, fayfac=1, pv_vars=NULL,
+     pvpre=NULL, cdata=FALSE, NMI=FALSE)
+
+# S3 method for BIFIEdata
+summary(object,...)
+
+# S3 method for BIFIEdata
+print(x,...)
+
-# S3 method for 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.

-# S3 method for BIFIEdata -print(x,...)
+
wgt
+

A string indicating the label of case weight or a vector +containing all case weights.

-

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. +

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).

pv_vars

Optional vector for names of plausible values, see -BIFIE.data.jack.

pvpre

Optional vector for prefixes of plausible values, see -BIFIE.data.jack.

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

x

Object of class BIFIEdata

...

Further arguments to be passed

- -

Value

- -

An object of class BIFIEdata saved in a non-compact + is requested, an appropriate vector input can be used (see Example 3).

+ +
pv_vars
+

Optional vector for names of plausible values, see +BIFIE.data.jack.

+ +
pvpre
+

Optional vector for prefixes of plausible values, see +BIFIE.data.jack.

+ +
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

+ +
x
+

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:

-
datalistM

Stacked list of imputed datasets (if cdata=FALSE)

-
wgt

Vector with case weights

-
wgtrep

Matrix with replicate weights

-
Nimp

Number of imputed datasets

-
N

Number of observations in a dataset

-
dat1

Last imputed dataset

-
varnames

Vector with variable names

-
fayfac

Fay factor.

-
RR

Number of replicate weights

-
NMI

Logical indicating whether the dataset is nested multiply +

datalistM
+

Stacked list of imputed datasets (if cdata=FALSE)

+ +
wgt
+

Vector with case weights

+ +
wgtrep
+

Matrix with replicate weights

+ +
Nimp
+

Number of imputed datasets

+ +
N
+

Number of observations in a dataset

+ +
dat1
+

Last imputed dataset

+ +
varnames
+

Vector with variable names

+ +
fayfac
+

Fay factor.

+ +
RR
+

Number of replicate weights

+ +
NMI
+

Logical indicating whether the dataset is nested multiply imputed.

-
cdata

Logical indicating whether the BIFIEdata object is in + +

cdata
+

Logical indicating whether the BIFIEdata object is in compact format (cdata=TRUE) or in a non-compact format (cdata=FALSE).

-
Nvars

Number of variables

-
variables

Data frame including some informations about variables. + +

Nvars
+

Number of variables

+ +
variables
+

Data frame including some informations about variables. All transformations are saved in the column source.

-
datalistM_ind

Data frame with response indicators -(if cdata=TRUE)

-
datalistM_imputed

Data frame with imputed values + +

datalistM_ind
+

Data frame with response indicators (if cdata=TRUE)

-

See also

+
datalistM_imputed
+

Data frame with imputed values +(if cdata=TRUE)

-

See BIFIE.data.transform for data transformations on +

+
+

See also

+

See BIFIE.data.transform for data transformations on BIFIEdata objects.

For saving and loading BIFIEdata objects see -save.BIFIEdata.

+save.BIFIEdata.

For converting PIRLS/TIMSS or PISA datasets into BIFIEdata -objects see BIFIE.data.jack.

-

See the BIFIEdata2svrepdesign function for converting +objects see BIFIE.data.jack.

+

See the BIFIEdata2svrepdesign function for converting BIFIEdata objects to objects used in the survey package.

+
-

Examples

-
#############################################################################
-# EXAMPLE 1: Create BIFIEdata object with multiply-imputed TIMSS data
-#############################################################################
-data(data.timss1)
-data(data.timssrep)
-
-bdat <- BIFIEsurvey::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 <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
-            wgtrep=data.timssrep[, -1 ], cdata=TRUE)
-summary(bdat2)
-
-if (FALSE) {
-#############################################################################
-# EXAMPLE 2: Create BIFIEdata object with one dataset
-#############################################################################
-data(data.timss2)
-
-# use first dataset with missing data from data.timss2
-bdat <- BIFIEsurvey::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 <- BIFIEsurvey::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 <- BIFIEsurvey::BIFIE.univar( bdat1, vars="ASMMAT")
-summary(res1)
-# finite sampling correction
-res2 <- BIFIEsurvey::BIFIE.univar( bdat2, vars="ASMMAT")
-summary(res2)
-
-if (FALSE) {
-#############################################################################
-# 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 <- BIFIEsurvey::BIFIE.data( data.list=data.timss4,
-            wgt=data.timss4[[1]][[1]]$TOTWGT, wgtrep=data.timssrep[, -1 ],
-            NMI=TRUE, cdata=TRUE )
-summary(bdat)
-}
+
+

Examples

+
#############################################################################
+# EXAMPLE 1: Create BIFIEdata object with multiply-imputed TIMSS data
+#############################################################################
+data(data.timss1)
+data(data.timssrep)
+
+bdat <- BIFIEsurvey::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 <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
+            wgtrep=data.timssrep[, -1 ], cdata=TRUE)
+summary(bdat2)
+
+if (FALSE) {
+#############################################################################
+# EXAMPLE 2: Create BIFIEdata object with one dataset
+#############################################################################
+data(data.timss2)
+
+# use first dataset with missing data from data.timss2
+bdat <- BIFIEsurvey::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 <- BIFIEsurvey::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 <- BIFIEsurvey::BIFIE.univar( bdat1, vars="ASMMAT")
+summary(res1)
+# finite sampling correction
+res2 <- BIFIEsurvey::BIFIE.univar( bdat2, vars="ASMMAT")
+summary(res2)
+
+if (FALSE) {
+#############################################################################
+# 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 <- BIFIEsurvey::BIFIE.data( data.list=data.timss4,
+            wgt=data.timss4[[1]][[1]]$TOTWGT, wgtrep=data.timssrep[, -1 ],
+            NMI=TRUE, cdata=TRUE )
+summary(bdat)
+}
+
+
-
- +
- - + + diff --git a/docs/reference/BIFIE.data.jack.html b/docs/reference/BIFIE.data.jack.html index ba27898..f689f14 100644 --- a/docs/reference/BIFIE.data.jack.html +++ b/docs/reference/BIFIE.data.jack.html @@ -1,68 +1,13 @@ - - - - - - - -Create <code>BIFIE.data</code> Object with Jackknife Zones — BIFIE.data.jack • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create BIFIE.data Object with Jackknife Zones — BIFIE.data.jack • BIFIEsurvey - - - - + + -
-
- -
- -
+
-
BIFIE.data.jack(data, wgt=NULL, jktype="JK_TIMSS", pv_vars=NULL,
-     jkzone=NULL, jkrep=NULL, jkfac=NULL, fayfac=NULL,
-     wgtrep="W_FSTR", pvpre=paste0("PV",1:5), ngr=100,
-     seed=.Random.seed, cdata=FALSE)
- -

Arguments

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
data

Data frame: Can be a single or a list of multiply-imputed datasets

wgt

A string indicating the label of case weight. +

+
BIFIE.data.jack(data, wgt=NULL, jktype="JK_TIMSS", pv_vars=NULL,
+     jkzone=NULL, jkrep=NULL, jkfac=NULL, fayfac=NULL,
+     wgtrep="W_FSTR", pvpre=paste0("PV",1:5), ngr=100,
+     seed=.Random.seed, cdata=FALSE)
+
+ +
+

Arguments

+
data
+

Data frame: Can be a single or a list of multiply-imputed datasets

+ +
wgt
+

A string indicating the label of case weight. In case of jktype="JK_TIMSS" the weight is specified as - wgt="TOTWGT" as the default.

pv_vars

An optional vector of plausible values which define multiply-imputed datasets.

jktype

Type of jackknife procedure for creating the BIFIE.data object. + wgt="TOTWGT" as the default.

+ +
pv_vars
+

An optional vector of plausible values which define multiply-imputed datasets.

+ +
jktype
+

Type of jackknife procedure for creating the BIFIE.data object. jktype="JK_TIMSS" refers to TIMSS/PIRLS datasets up to 2011 data, jktype="JK_TIMSS2" refers to TIMSS/PIRLS datasets starting from 2015 data. The type "JK_GROUP" creates jackknife weights based on a user defined grouping, the type "JK_RANDOM" creates random groups. The number of random groups can be defined in ngr. The argument jktype="RW_PISA" -converts PISA datasets into objects of class BIFIEdata.

jkzone

Jackknife zones. If jktype="JK_TIMSS", then jkzone="JKZONE".

jkrep

Jackknife replicate factors. If jktype="JK_TIMSS", then jkrep="JKREP".

jkfac

Factor for multiplying jackknife replicate weights. -If jktype="JK_TIMSS", then jkfac=2.

fayfac

Fay factor for statistical inference. The default is set to NULL.

wgtrep

Variables in the dataset which refer to the replicate +converts PISA datasets into objects of class BIFIEdata.

+ +
jkzone
+

Jackknife zones. If jktype="JK_TIMSS", then jkzone="JKZONE".

+ +
jkrep
+

Jackknife replicate factors. If jktype="JK_TIMSS", then jkrep="JKREP".

+ +
jkfac
+

Factor for multiplying jackknife replicate weights. +If jktype="JK_TIMSS", then jkfac=2.

+ +
fayfac
+

Fay factor for statistical inference. The default is set to NULL.

+ +
wgtrep
+

Variables in the dataset which refer to the replicate weights. In case of cdata=TRUE, the replicate weights - are deleted from datalistM.

pvpre

Only applicable for jktype="RW_PISA". The vector contains - the prefixes of the variables containing plausible values.

ngr

Number of randomly created groups in "JK_RANDOM".

seed

The simulation seed if "JK_RANDOM" is chosen. + are deleted from datalistM.

+ +
pvpre
+

Only applicable for jktype="RW_PISA". The vector contains + the prefixes of the variables containing plausible values.

+ +
ngr
+

Number of randomly created groups in "JK_RANDOM".

+ +
seed
+

The simulation seed if "JK_RANDOM" is chosen. If seed=NULL, then the grouping is done according the -order in the dataset.

cdata

An optional logical indicating whether the BIFIEdata -object should be compactly saved. The default is FALSE.

- -

Value

- -

Object of class BIFIEdata

-

See also

- - - -

Examples

-
#############################################################################
-# EXAMPLE 1: Convert TIMSS dataset to BIFIE.data object
-#############################################################################
-
-data(data.timss3)
-
-# define plausible values
-pv_vars <- c("ASMMAT", "ASSSCI" )
-# create BIFIE.data objects -> 5 imputed datasets
-bdat1 <- BIFIEsurvey::BIFIE.data.jack( data=data.timss3,  pv_vars=pv_vars,
-             jktype="JK_TIMSS"  )
-summary(bdat1)
-
-# create BIFIE.data objects -> all PVs are included in one dataset
-bdat2 <- BIFIEsurvey::BIFIE.data.jack( data=data.timss3,  jktype="JK_TIMSS"  )
-summary(bdat2)
-
-#############################################################################
-# EXAMPLE 2: Creation of Jackknife zones and replicate weights for data.test1
-#############################################################################
-
-data(data.test1)
-
-# create jackknife zones based on random group creation
-bdat1 <- BIFIEsurvey::BIFIE.data.jack( data=data.test1,  jktype="JK_RANDOM",
-                    ngr=50 )
-summary(bdat1)
-stat1 <- BIFIEsurvey::BIFIE.univar( bdat1, vars="math",  group="stratum" )
-summary(stat1)
-
-# random creation of groups and inclusion of weights
-bdat2 <- BIFIEsurvey::BIFIE.data.jack( data=data.test1,  jktype="JK_RANDOM",
-                ngr=75, seed=987, wgt="wgtstud")
-summary(bdat2)
-stat2 <- BIFIEsurvey::BIFIE.univar( bdat2, vars="math",  group="stratum" )
-summary(stat2)
-
-# using idclass as jackknife zones
-bdat3 <- BIFIEsurvey::BIFIE.data.jack( data=data.test1,  jktype="JK_GROUP",
-                jkzone="idclass", wgt="wgtstud")
-summary(bdat3)
-stat3 <- BIFIEsurvey::BIFIE.univar( bdat3, vars="math",  group="stratum" )
-summary(stat3)
-
-# create BIFIEdata object with a list of imputed datasets
-dataList <- list( data.test1, data.test1, data.test1 )
-bdat4 <- BIFIEsurvey::BIFIE.data.jack( data=dataList,  jktype="JK_GROUP",
-                jkzone="idclass", wgt="wgtstud")
-summary(bdat4)
-
-if (FALSE) {
-#############################################################################
-# EXAMPLE 3: Converting a PISA dataset into a BIFIEdata object
-#############################################################################
-
-data(data.pisaNLD)
-
-# BIFIEdata with cdata=FALSE
-bifieobj <- BIFIEsurvey::BIFIE.data.jack( data.pisaNLD, jktype="RW_PISA", cdata=FALSE)
-summary(bifieobj)
-# BIFIEdata with cdata=TRUE
-bifieobj1 <- BIFIEsurvey::BIFIE.data.jack( data.pisaNLD, jktype="RW_PISA", cdata=TRUE)
-summary(bifieobj1)
-}
+order in the dataset.

+ +
cdata
+

An optional logical indicating whether the BIFIEdata +object should be compactly saved. The default is FALSE.

+ +
+
+

Value

+ + +

Object of class BIFIEdata

+ + +
+
+

See also

+ +
+ +
+

Examples

+
#############################################################################
+# EXAMPLE 1: Convert TIMSS dataset to BIFIE.data object
+#############################################################################
+
+data(data.timss3)
+
+# define plausible values
+pv_vars <- c("ASMMAT", "ASSSCI" )
+# create BIFIE.data objects -> 5 imputed datasets
+bdat1 <- BIFIEsurvey::BIFIE.data.jack( data=data.timss3,  pv_vars=pv_vars,
+             jktype="JK_TIMSS"  )
+summary(bdat1)
+
+# create BIFIE.data objects -> all PVs are included in one dataset
+bdat2 <- BIFIEsurvey::BIFIE.data.jack( data=data.timss3,  jktype="JK_TIMSS"  )
+summary(bdat2)
+
+#############################################################################
+# EXAMPLE 2: Creation of Jackknife zones and replicate weights for data.test1
+#############################################################################
+
+data(data.test1)
+
+# create jackknife zones based on random group creation
+bdat1 <- BIFIEsurvey::BIFIE.data.jack( data=data.test1,  jktype="JK_RANDOM",
+                    ngr=50 )
+summary(bdat1)
+stat1 <- BIFIEsurvey::BIFIE.univar( bdat1, vars="math",  group="stratum" )
+summary(stat1)
+
+# random creation of groups and inclusion of weights
+bdat2 <- BIFIEsurvey::BIFIE.data.jack( data=data.test1,  jktype="JK_RANDOM",
+                ngr=75, seed=987, wgt="wgtstud")
+summary(bdat2)
+stat2 <- BIFIEsurvey::BIFIE.univar( bdat2, vars="math",  group="stratum" )
+summary(stat2)
+
+# using idclass as jackknife zones
+bdat3 <- BIFIEsurvey::BIFIE.data.jack( data=data.test1,  jktype="JK_GROUP",
+                jkzone="idclass", wgt="wgtstud")
+summary(bdat3)
+stat3 <- BIFIEsurvey::BIFIE.univar( bdat3, vars="math",  group="stratum" )
+summary(stat3)
+
+# create BIFIEdata object with a list of imputed datasets
+dataList <- list( data.test1, data.test1, data.test1 )
+bdat4 <- BIFIEsurvey::BIFIE.data.jack( data=dataList,  jktype="JK_GROUP",
+                jkzone="idclass", wgt="wgtstud")
+summary(bdat4)
+
+if (FALSE) {
+#############################################################################
+# EXAMPLE 3: Converting a PISA dataset into a BIFIEdata object
+#############################################################################
+
+data(data.pisaNLD)
+
+# BIFIEdata with cdata=FALSE
+bifieobj <- BIFIEsurvey::BIFIE.data.jack( data.pisaNLD, jktype="RW_PISA", cdata=FALSE)
+summary(bifieobj)
+# BIFIEdata with cdata=TRUE
+bifieobj1 <- BIFIEsurvey::BIFIE.data.jack( data.pisaNLD, jktype="RW_PISA", cdata=TRUE)
+summary(bifieobj1)
+}
+
+
-
- +
- - + + diff --git a/docs/reference/BIFIE.data.select.html b/docs/reference/BIFIE.data.select.html index 479979b..6446e54 100644 --- a/docs/reference/BIFIE.data.select.html +++ b/docs/reference/BIFIE.data.select.html @@ -1,69 +1,14 @@ - - - - - - - -Selection of Variables and Imputed Datasets for Objects of Class <code>BIFIEdata</code> — BIFIEdata.select • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Selection of Variables and Imputed Datasets for Objects of Class BIFIEdata — BIFIEdata.select • BIFIEsurvey - - - - - - - - - - - - - + + -
-
- -
- -
+
-
BIFIEdata.select(bifieobj, varnames=NULL, impdata.index=NULL)
- -

Arguments

- - - - - - - - - - - - - - -
bifieobj

Object of class BIFIEdata

varnames

Variables chosen for the selection

impdata.index

Selected indices of imputed datasets

- -

Value

- -

An object of class BIFIEdata saved in a non-compact +

+
BIFIEdata.select(bifieobj, varnames=NULL, impdata.index=NULL)
+
+ +
+

Arguments

+
bifieobj
+

Object of class BIFIEdata

+ +
varnames
+

Variables chosen for the selection

+ +
impdata.index
+

Selected indices of imputed datasets

+ +
+
+

Value

+ + +

An object of class BIFIEdata saved in a non-compact or compact way, see value cdata

-

See also

- -

See BIFIE.data for creating BIFIEdata objects.

- -

Examples

-
#############################################################################
-# EXAMPLE 1: Some manipulations of BIFIEdata objects created from data.timss1
-#############################################################################
-data(data.timss1)
-data(data.timssrep)
-
-# create BIFIEdata
-bdat1 <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
-            wgtrep=data.timssrep[, -1 ])
-summary(bdat1)
-
-# create BIFIEcdata object
-bdat2 <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
-            wgtrep=data.timssrep[, -1 ], cdata=TRUE )
-summary(bdat2)
-
-# selection of variables for BIFIEdata object
-bdat1a <- BIFIEsurvey::BIFIEdata.select( bdat1, varnames=bdat1$varnames[ 1:7 ] )
-# selection of variables and 1st, 2nd and 4th imputed datasets of BIFIEcdata object
-bdat2a <- BIFIEsurvey::BIFIEdata.select( bdat2, varnames=bdat2$varnames[ 1:7 ],
-                impdata.index=c(1,2,4) )
-summary(bdat1a)
-summary(bdat2a)
+ + +
+
+

See also

+

See BIFIE.data for creating BIFIEdata objects.

+
+ +
+

Examples

+
#############################################################################
+# EXAMPLE 1: Some manipulations of BIFIEdata objects created from data.timss1
+#############################################################################
+data(data.timss1)
+data(data.timssrep)
+
+# create BIFIEdata
+bdat1 <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
+            wgtrep=data.timssrep[, -1 ])
+summary(bdat1)
+
+# create BIFIEcdata object
+bdat2 <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
+            wgtrep=data.timssrep[, -1 ], cdata=TRUE )
+summary(bdat2)
+
+# selection of variables for BIFIEdata object
+bdat1a <- BIFIEsurvey::BIFIEdata.select( bdat1, varnames=bdat1$varnames[ 1:7 ] )
+# selection of variables and 1st, 2nd and 4th imputed datasets of BIFIEcdata object
+bdat2a <- BIFIEsurvey::BIFIEdata.select( bdat2, varnames=bdat2$varnames[ 1:7 ],
+                impdata.index=c(1,2,4) )
+summary(bdat1a)
+summary(bdat2a)
+
+
-
- +
- - + + diff --git a/docs/reference/BIFIE.data.transform.html b/docs/reference/BIFIE.data.transform.html index 99695fd..a534b34 100644 --- a/docs/reference/BIFIE.data.transform.html +++ b/docs/reference/BIFIE.data.transform.html @@ -1,67 +1,12 @@ - - - - - - - -Data Transformation for <code>BIFIEdata</code> Objects — BIFIE.data.transform • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Data Transformation for BIFIEdata Objects — BIFIE.data.transform • BIFIEsurvey - - - - + + -
-
- -
- -
+
-
BIFIE.data.transform( bifieobj, transform.formula, varnames.new=NULL )
- -

Arguments

- - - - - - - - - - - - - - -
bifieobj

Object of class BIFIEdata

transform.formula

R formula object for data transformation.

varnames.new

Optional vector of names for new defined variables.

- -

Value

- -

An object of class BIFIEdata. Additional values are

-
varnames.added

Added variables in data transformation

-
varsindex.added

Indices of added variables

- - -

Examples

-
library(miceadds)
-
-#############################################################################
-# EXAMPLE 1: Data transformations for TIMSS data
-#############################################################################
-
-data(data.timss2)
-data(data.timssrep)
-# create BIFIEdata object
-bifieobj1 <- BIFIEsurvey::BIFIE.data( data.timss2, wgt=data.timss2[[1]]$TOTWGT,
-            wgtrep=data.timssrep[,-1] )
-# create BIFIEdata object in compact way (cdata=TRUE)
-bifieobj2 <- BIFIEsurvey::BIFIE.data( data.timss2, wgt=data.timss2[[1]]$TOTWGT,
-            wgtrep=data.timssrep[,-1], cdata=TRUE)
-
-#****************************
-#*** Transformation 1: Squared and cubic book variable
-transform.formula <- ~ I( books^2 ) + I( books^3 )
-# as.character(transform.formula)
-bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj1,
-                  transform.formula=transform.formula)
-bifieobj$variables
-# rename added variables
-bifieobj$varnames[ bifieobj$varsindex.added ] <- c("books_sq", "books_cub")
-
-# check descriptive statistics
-res1 <- BIFIEsurvey::BIFIE.univar( bifieobj, vars=c("books_sq", "books_cub" ) )
-summary(res1)
-
-if (FALSE) {
-#****************************
-#*** Transformation 2: Create dummy variables for variable book
-transform.formula <- ~ as.factor(books)
-bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj,
-                    transform.formula=transform.formula )
-##   Included 5 variables: as.factor(books)1 as.factor(books)2 as.factor(books)3
-##        as.factor(books)4 as.factor(books)5
-bifieobj$varnames[ bifieobj$varsindex.added ] <- paste0("books_D", 1:5)
-
-#****************************
-#*** Transformation 3: Discretized mathematics score
-hi3a <- BIFIEsurvey::BIFIE.hist( bifieobj, vars="ASMMAT" )
-plot(hi3a)
-transform.formula <- ~ I( as.numeric(cut( ASMMAT, breaks=seq(200,800,100) )) )
-bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj,
-                 transform.formula=transform.formula, varnames.new="ASMMAT_discret")
-hi3b <- BIFIEsurvey::BIFIE.hist( bifieobj, vars="ASMMAT_discret", breaks=1:7 )
-plot(hi3b)
-# check frequencies
-fr3b <- BIFIEsurvey::BIFIE.freq( bifieobj, vars="ASMMAT_discret", se=FALSE )
-summary(fr3b)
-
-#****************************
-#*** Transformation 4: include standardization variables for book variable
-
-# start with testing the transformation function on a single dataset
-dat1 <- bifieobj$dat1
-stats::weighted.mean( dat1[,"books"], dat1[,"TOTWGT"], na.rm=TRUE)
-sqrt( Hmisc::wtd.var( dat1[,"books"], dat1[,"TOTWGT"], na.rm=TRUE) )
-# z standardization
-transform.formula <- ~ I( ( books - weighted.mean( books, TOTWGT, na.rm=TRUE) )/
-                                sqrt( Hmisc::wtd.var( books, TOTWGT, na.rm=TRUE) ))
-bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj,
-               transform.formula=transform.formula, varnames.new="z_books" )
-# standardize variable books with M=500 and SD=100
-transform.formula <- ~ I(
-        500 + 100*( books - stats::weighted.mean( books, w=TOTWGT, na.rm=TRUE) ) /
-              sqrt( Hmisc::wtd.var( books, weights=TOTWGT, na.rm=TRUE) )  )
-bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj,
-             transform.formula=transform.formula, varnames.new="z500_books" )
-
-# standardize variable books with respect to M and SD of ALL imputed datasets
-res <- BIFIEsurvey::BIFIE.univar( bifieobj, vars="books" )
-summary(res)
-##       var  Nweight Ncases     M M_SE M_fmi M_VarMI M_VarRep    SD SD_SE SD_fmi
-##   1 books 76588.72   4554 2.945 0.04     0       0    0.002 1.146 0.015      0
-M <- round(res$output$mean1,5)
-SD <- round(res$output$sd1,5)
-transform.formula <- paste0( " ~ I( ( books - ",  M, " ) / ", SD, ")"  )
-##   > transform.formula
-##   [1] " ~ I( ( books - 2.94496 ) / 1.14609)"
-bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj,
-                 transform.formula=stats::as.formula(transform.formula),
-                 varnames.new="zall_books" )
-
-# check statistics
-res4 <- BIFIEsurvey::BIFIE.univar( bifieobj,
-              vars=c("z_books", "z500_books", "zall_books") )
-summary(res4)
-
-#****************************
-#*** Transformation 5: include rank transformation for variable ASMMAT
-
-# calculate percentage ranks using wtd.rank function from Hmisc package
-dat1 <- bifieobj$dat1
-100 * Hmisc::wtd.rank( dat1[,"ASMMAT"], w=dat1[,"TOTWGT"] ) / sum( dat1[,"TOTWGT"] )
-# define an auxiliary function for calculating percentage ranks
-wtd.percrank <- function( x, w ){
-    100 * Hmisc::wtd.rank( x, w, na.rm=TRUE ) / sum( w, na.rm=TRUE )
-}
-wtd.percrank( dat1[,"ASMMAT"], dat1[,"TOTWGT"] )
-# define transformation formula
-transform.formula <- ~ I( wtd.percrank( ASMMAT, TOTWGT ) )
-# add ranks to BIFIEdata object
-bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj,
-               transform.formula=transform.formula,  varnames.new="ASMMAT_rk")
-# check statistic
-res5 <- BIFIEsurvey::BIFIE.univar( bifieobj, vars=c("ASMMAT_rk" ) )
-summary(res5)
-
-#****************************
-#*** Transformation 6: recode variable books
-
-library(car)
-# recode variable books according to "1,2=0, 3,4=1, 5=2"
-dat1 <- bifieobj$dat1
-# use Recode function from car package
-car::Recode( dat1[,"books"], "1:2='0'; c(3,4)='1';5='2'")
-# define transformation formula
-transform.formula <- ~ I( car::Recode( books, "1:2='0'; c(3,4)='1';5='2'") )
-bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj,
-               transform.formula=transform.formula,  varnames.new="book_rec" )
-res6 <- BIFIEsurvey::BIFIE.freq( bifieobj, vars=c("book_rec" ) )
-summary(res6)
-
-#****************************
-#*** Transformation 7: include some variables aggregated to the school level
-
-dat1 <- as.data.frame(bifieobj$dat1)
-# at first, create school ID in the dataset by transforming the student ID
-dat1$idschool <- as.numeric(substring( dat1$IDSTUD, 1, 5 ))
-transform.formula <- ~ I( as.numeric( substring( IDSTUD, 1, 5 ) ) )
-bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj,
-               transform.formula=transform.formula, varnames.new="idschool" )
-
-#*** test function for a single dataset bifieobj$dat1
-dat1 <- as.data.frame(bifieobj$dat1)
-gm <- miceadds::GroupMean( data=dat1$ASMMAT, group=dat1$idschool, extend=TRUE)[,2]
-
-# add school mean ASMMAT
-tformula <- ~ I( miceadds::GroupMean( ASMMAT, group=idschool, extend=TRUE)[,2] )
-bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj, transform.formula=tformula,
-                varnames.new="M_ASMMAT" )
-# add within group centered mathematics values of ASMMAT
-bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj,
-                transform.formula=~ 0 + I( ASMMAT - M_ASMMAT ),
-                varnames.new="WC_ASMMAT" )
-
-# add school mean books
-bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj,
-                transform.formula=~ 0 + I( add.groupmean( books, idschool ) ),
-                varnames.new="M_books" )
-
-#****************************
-#*** Transformation 8: include fitted values and residuals from a linear model
-# create new BIFIEdata object
-data(data.timss1)
-bifieobj3 <- BIFIEsurvey::BIFIE.data( data.timss1, wgt=data.timss1[[1]]$TOTWGT,
-            wgtrep=data.timssrep[,-1] )
+    
+
BIFIE.data.transform( bifieobj, transform.formula, varnames.new=NULL )
+
-# specify transformation -transform.formula <- ~ I( fitted( stats::lm( ASMMAT ~ migrant + female ) ) ) + - I( residuals( stats::lm( ASMMAT ~ migrant + female ) ) ) - # Note that lm omits cases in regression by listwise deletion. -# add fitted values and residual to BIFIEdata object -bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj3, - transform.formula=transform.formula ) -bifieobj$varnames[ bifieobj$varsindex.added ] <- c("math_fitted1", "math_resid1") +
+

Arguments

+
bifieobj
+

Object of class BIFIEdata

-#**************************** -#*** Transformation 9: Including principal component scores in BIFIEdata object +
transform.formula
+

R formula object for data transformation.

-# define auxiliary function for extracting PCA scores -BIFIE.princomp <- function( formula, Ncomp ){ - X <- stats::princomp( formula, cor=TRUE) - Xp <- X$scores[, 1:Ncomp ] - return(Xp) -} -# define transformation formula -transform.formula <- ~ I( BIFIE.princomp( ~ migrant + female + books + lang + ASMMAT, 3 )) -# apply transformation -bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj3, - transform.formula=transform.formula ) -bifieobj$varnames[ bifieobj$varsindex.added ] <- c("pca_sc1", "pca_sc2","pca_sc3") -# check descriptive statistics -res9 <- BIFIEsurvey::BIFIE.univar( bifieobj, vars="pca_sc1", se=FALSE) -summary(res9) -res9$output$mean1M +
varnames.new
+

Optional vector of names for new defined variables.

-# The transformation formula can also be conveniently generated by string operations -vars <- c("migrant", "female", "books", "lang" ) -transform.formula2 <- as.formula( paste0( "~ 0 + I ( BIFIE.princomp( ~ ", - paste0( vars, collapse="+" ), ", 3 ) )") ) - ## > transform.formula2 - ## ~ I(BIFIE.princomp(~migrant + female + books + lang, 3)) +
+
+

Value

+ -#**************************** -#*** Transformation 10: Overwriting variables books and migrant -bifieobj4 <- BIFIEsurvey::BIFIE.data.transform( bifieobj3, - transform.formula=~ I( 1*(books >=1 ) ) + I(2*migrant), - varnames.new=c("books","migrant") ) -summary(bifieobj4) -}
+

An object of class BIFIEdata. Additional values are

+
varnames.added
+

Added variables in data transformation

+ +
varsindex.added
+

Indices of added variables

+ +
+ +
+

Examples

+
library(miceadds)
+
+#############################################################################
+# EXAMPLE 1: Data transformations for TIMSS data
+#############################################################################
+
+data(data.timss2)
+data(data.timssrep)
+# create BIFIEdata object
+bifieobj1 <- BIFIEsurvey::BIFIE.data( data.timss2, wgt=data.timss2[[1]]$TOTWGT,
+            wgtrep=data.timssrep[,-1] )
+# create BIFIEdata object in compact way (cdata=TRUE)
+bifieobj2 <- BIFIEsurvey::BIFIE.data( data.timss2, wgt=data.timss2[[1]]$TOTWGT,
+            wgtrep=data.timssrep[,-1], cdata=TRUE)
+
+#****************************
+#*** Transformation 1: Squared and cubic book variable
+transform.formula <- ~ I( books^2 ) + I( books^3 )
+# as.character(transform.formula)
+bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj1,
+                  transform.formula=transform.formula)
+bifieobj$variables
+# rename added variables
+bifieobj$varnames[ bifieobj$varsindex.added ] <- c("books_sq", "books_cub")
+
+# check descriptive statistics
+res1 <- BIFIEsurvey::BIFIE.univar( bifieobj, vars=c("books_sq", "books_cub" ) )
+summary(res1)
+
+if (FALSE) {
+#****************************
+#*** Transformation 2: Create dummy variables for variable book
+transform.formula <- ~ as.factor(books)
+bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj,
+                    transform.formula=transform.formula )
+##   Included 5 variables: as.factor(books)1 as.factor(books)2 as.factor(books)3
+##        as.factor(books)4 as.factor(books)5
+bifieobj$varnames[ bifieobj$varsindex.added ] <- paste0("books_D", 1:5)
+
+#****************************
+#*** Transformation 3: Discretized mathematics score
+hi3a <- BIFIEsurvey::BIFIE.hist( bifieobj, vars="ASMMAT" )
+plot(hi3a)
+transform.formula <- ~ I( as.numeric(cut( ASMMAT, breaks=seq(200,800,100) )) )
+bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj,
+                 transform.formula=transform.formula, varnames.new="ASMMAT_discret")
+hi3b <- BIFIEsurvey::BIFIE.hist( bifieobj, vars="ASMMAT_discret", breaks=1:7 )
+plot(hi3b)
+# check frequencies
+fr3b <- BIFIEsurvey::BIFIE.freq( bifieobj, vars="ASMMAT_discret", se=FALSE )
+summary(fr3b)
+
+#****************************
+#*** Transformation 4: include standardization variables for book variable
+
+# start with testing the transformation function on a single dataset
+dat1 <- bifieobj$dat1
+stats::weighted.mean( dat1[,"books"], dat1[,"TOTWGT"], na.rm=TRUE)
+sqrt( Hmisc::wtd.var( dat1[,"books"], dat1[,"TOTWGT"], na.rm=TRUE) )
+# z standardization
+transform.formula <- ~ I( ( books - weighted.mean( books, TOTWGT, na.rm=TRUE) )/
+                                sqrt( Hmisc::wtd.var( books, TOTWGT, na.rm=TRUE) ))
+bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj,
+               transform.formula=transform.formula, varnames.new="z_books" )
+# standardize variable books with M=500 and SD=100
+transform.formula <- ~ I(
+        500 + 100*( books - stats::weighted.mean( books, w=TOTWGT, na.rm=TRUE) ) /
+              sqrt( Hmisc::wtd.var( books, weights=TOTWGT, na.rm=TRUE) )  )
+bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj,
+             transform.formula=transform.formula, varnames.new="z500_books" )
+
+# standardize variable books with respect to M and SD of ALL imputed datasets
+res <- BIFIEsurvey::BIFIE.univar( bifieobj, vars="books" )
+summary(res)
+##       var  Nweight Ncases     M M_SE M_fmi M_VarMI M_VarRep    SD SD_SE SD_fmi
+##   1 books 76588.72   4554 2.945 0.04     0       0    0.002 1.146 0.015      0
+M <- round(res$output$mean1,5)
+SD <- round(res$output$sd1,5)
+transform.formula <- paste0( " ~ I( ( books - ",  M, " ) / ", SD, ")"  )
+##   > transform.formula
+##   [1] " ~ I( ( books - 2.94496 ) / 1.14609)"
+bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj,
+                 transform.formula=stats::as.formula(transform.formula),
+                 varnames.new="zall_books" )
+
+# check statistics
+res4 <- BIFIEsurvey::BIFIE.univar( bifieobj,
+              vars=c("z_books", "z500_books", "zall_books") )
+summary(res4)
+
+#****************************
+#*** Transformation 5: include rank transformation for variable ASMMAT
+
+# calculate percentage ranks using wtd.rank function from Hmisc package
+dat1 <- bifieobj$dat1
+100 * Hmisc::wtd.rank( dat1[,"ASMMAT"], w=dat1[,"TOTWGT"] ) / sum( dat1[,"TOTWGT"] )
+# define an auxiliary function for calculating percentage ranks
+wtd.percrank <- function( x, w ){
+    100 * Hmisc::wtd.rank( x, w, na.rm=TRUE ) / sum( w, na.rm=TRUE )
+}
+wtd.percrank( dat1[,"ASMMAT"], dat1[,"TOTWGT"] )
+# define transformation formula
+transform.formula <- ~ I( wtd.percrank( ASMMAT, TOTWGT ) )
+# add ranks to BIFIEdata object
+bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj,
+               transform.formula=transform.formula,  varnames.new="ASMMAT_rk")
+# check statistic
+res5 <- BIFIEsurvey::BIFIE.univar( bifieobj, vars=c("ASMMAT_rk" ) )
+summary(res5)
+
+#****************************
+#*** Transformation 6: recode variable books
+
+library(car)
+# recode variable books according to "1,2=0, 3,4=1, 5=2"
+dat1 <- bifieobj$dat1
+# use Recode function from car package
+car::Recode( dat1[,"books"], "1:2='0'; c(3,4)='1';5='2'")
+# define transformation formula
+transform.formula <- ~ I( car::Recode( books, "1:2='0'; c(3,4)='1';5='2'") )
+bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj,
+               transform.formula=transform.formula,  varnames.new="book_rec" )
+res6 <- BIFIEsurvey::BIFIE.freq( bifieobj, vars=c("book_rec" ) )
+summary(res6)
+
+#****************************
+#*** Transformation 7: include some variables aggregated to the school level
+
+dat1 <- as.data.frame(bifieobj$dat1)
+# at first, create school ID in the dataset by transforming the student ID
+dat1$idschool <- as.numeric(substring( dat1$IDSTUD, 1, 5 ))
+transform.formula <- ~ I( as.numeric( substring( IDSTUD, 1, 5 ) ) )
+bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj,
+               transform.formula=transform.formula, varnames.new="idschool" )
+
+#*** test function for a single dataset bifieobj$dat1
+dat1 <- as.data.frame(bifieobj$dat1)
+gm <- miceadds::GroupMean( data=dat1$ASMMAT, group=dat1$idschool, extend=TRUE)[,2]
+
+# add school mean ASMMAT
+tformula <- ~ I( miceadds::GroupMean( ASMMAT, group=idschool, extend=TRUE)[,2] )
+bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj, transform.formula=tformula,
+                varnames.new="M_ASMMAT" )
+# add within group centered mathematics values of ASMMAT
+bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj,
+                transform.formula=~ 0 + I( ASMMAT - M_ASMMAT ),
+                varnames.new="WC_ASMMAT" )
+
+# add school mean books
+bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj,
+                transform.formula=~ 0 + I( add.groupmean( books, idschool ) ),
+                varnames.new="M_books" )
+
+#****************************
+#*** Transformation 8: include fitted values and residuals from a linear model
+# create new BIFIEdata object
+data(data.timss1)
+bifieobj3 <- BIFIEsurvey::BIFIE.data( data.timss1, wgt=data.timss1[[1]]$TOTWGT,
+            wgtrep=data.timssrep[,-1] )
+
+# specify transformation
+transform.formula <- ~ I( fitted( stats::lm( ASMMAT ~ migrant + female ) ) ) +
+                             I( residuals( stats::lm( ASMMAT ~ migrant + female ) ) )
+  # Note that lm omits cases in regression by listwise deletion.
+# add fitted values and residual to BIFIEdata object
+bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj3,
+                  transform.formula=transform.formula )
+bifieobj$varnames[ bifieobj$varsindex.added ] <- c("math_fitted1", "math_resid1")
+
+#****************************
+#*** Transformation 9: Including principal component scores in BIFIEdata object
+
+# define auxiliary function for extracting PCA scores
+BIFIE.princomp <- function( formula, Ncomp ){
+    X <- stats::princomp( formula, cor=TRUE)
+    Xp <- X$scores[, 1:Ncomp ]
+    return(Xp)
+}
+# define transformation formula
+transform.formula <- ~ I( BIFIE.princomp( ~ migrant + female + books + lang + ASMMAT, 3 ))
+# apply transformation
+bifieobj <- BIFIEsurvey::BIFIE.data.transform( bifieobj3,
+                transform.formula=transform.formula )
+bifieobj$varnames[ bifieobj$varsindex.added ] <- c("pca_sc1", "pca_sc2","pca_sc3")
+# check descriptive statistics
+res9 <- BIFIEsurvey::BIFIE.univar( bifieobj, vars="pca_sc1", se=FALSE)
+summary(res9)
+res9$output$mean1M
+
+# The transformation formula can also be conveniently generated by string operations
+vars <- c("migrant", "female", "books", "lang" )
+transform.formula2 <- as.formula( paste0( "~ 0 + I ( BIFIE.princomp( ~ ",
+       paste0( vars, collapse="+" ),  ", 3 ) )") )
+  ##   > transform.formula2
+  ##   ~ I(BIFIE.princomp(~migrant + female + books + lang, 3))
+
+#****************************
+#*** Transformation 10: Overwriting variables books and migrant
+bifieobj4 <-  BIFIEsurvey::BIFIE.data.transform( bifieobj3,
+                  transform.formula=~ I( 1*(books >=1 ) ) + I(2*migrant),
+                  varnames.new=c("books","migrant") )
+summary(bifieobj4)
+}
+
+
-
- +
- - + + diff --git a/docs/reference/BIFIE.derivedParameters.html b/docs/reference/BIFIE.derivedParameters.html index 0f19d9e..f02ccef 100644 --- a/docs/reference/BIFIE.derivedParameters.html +++ b/docs/reference/BIFIE.derivedParameters.html @@ -1,70 +1,15 @@ - - - - - - - -Statistical Inference for Derived Parameters — BIFIE.derivedParameters • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Statistical Inference for Derived Parameters — BIFIE.derivedParameters • BIFIEsurvey - - - - - - - - - - - - - + + -
-
- -
- -
+
+
+

Details

The distribution of derived parameters is derived by the direct calculation using original resampled parameters.

-

Value

- -

A list with following entries

-
stat

Data frame with statistics

-
coef

Estimates of derived parameters

-
vcov

Covariance matrix of derived parameters

-
parnames

Parameter names

-
res_wald

Output of Wald test (global test regarding all parameters)

-
...

More values

+
+
+

Value

+ -

See also

+

A list with following entries

+
stat
+

Data frame with statistics

-

See also BIFIE.waldtest for multi-parameter tests.

-

See car::deltaMethod for the Delta method assuming that the multivariate -distribution of the parameters is -asymptotically normal.

+
coef
+

Estimates of derived parameters

-

Examples

-
#############################################################################
-# EXAMPLE 1: Imputed TIMSS dataset
-#            Inference for correlations and derived parameters
-#############################################################################
+ 
vcov
+

Covariance matrix of derived parameters

-data(data.timss1) -data(data.timssrep) +
parnames
+

Parameter names

-# create BIFIE.dat object -bdat <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT, - wgtrep=data.timssrep[, -1 ] ) +
res_wald
+

Output of Wald test (global test regarding all parameters)

-# compute correlations -res1 <- BIFIEsurvey::BIFIE.correl( bdat, - vars=c("ASSSCI", "ASMMAT", "books", "migrant" ) ) -summary(res1) -res1$parnames - ## [1] "ASSSCI_ASSSCI" "ASSSCI_ASMMAT" "ASSSCI_books" "ASSSCI_migrant" - ## [5] "ASMMAT_ASMMAT" "ASMMAT_books" "ASMMAT_migrant" "books_books" - ## [9] "books_migrant" "migrant_migrant" +
...
+

More values

-# define four derived parameters -derived.parameters <- list( - # squared correlation of science and mathematics - "R2_sci_mat"=~ I( 100* ASSSCI_ASMMAT^2 ), - # partial correlation of science and mathematics controlling for books - "parcorr_sci_mat"=~ I( ( ASSSCI_ASMMAT - ASSSCI_books * ASMMAT_books ) / - sqrt(( 1 - ASSSCI_books^2 ) * ( 1-ASMMAT_books^2 ) ) ), - # original correlation science and mathematics (already contained in res1) - "cor_sci_mat"=~ I(ASSSCI_ASMMAT), - # original correlation books and migrant - "cor_book_migra"=~ I(books_migrant) - ) +
+
+

See also

+

See also BIFIE.waldtest for multi-parameter tests.

+

See car::deltaMethod for the Delta method assuming that the multivariate +distribution of the parameters is +asymptotically normal.

+
-# statistical inference for derived parameters -res2 <- BIFIEsurvey::BIFIE.derivedParameters( res1, derived.parameters ) -summary(res2) +
+

Examples

+
#############################################################################
+# EXAMPLE 1: Imputed TIMSS dataset
+#            Inference for correlations and derived parameters
+#############################################################################
+
+data(data.timss1)
+data(data.timssrep)
+
+# create BIFIE.dat object
+bdat <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
+           wgtrep=data.timssrep[, -1 ] )
+
+# compute correlations
+res1 <- BIFIEsurvey::BIFIE.correl( bdat,
+            vars=c("ASSSCI", "ASMMAT", "books", "migrant" )  )
+summary(res1)
+res1$parnames
+  ##    [1] "ASSSCI_ASSSCI"   "ASSSCI_ASMMAT"   "ASSSCI_books"    "ASSSCI_migrant"
+  ##    [5] "ASMMAT_ASMMAT"   "ASMMAT_books"    "ASMMAT_migrant"  "books_books"
+  ##    [9] "books_migrant"   "migrant_migrant"
+
+# define four derived parameters
+derived.parameters <- list(
+        # squared correlation of science and mathematics
+        "R2_sci_mat"=~ I( 100* ASSSCI_ASMMAT^2  ),
+        # partial correlation of science and mathematics controlling for books
+        "parcorr_sci_mat"=~ I( ( ASSSCI_ASMMAT - ASSSCI_books * ASMMAT_books ) /
+                            sqrt(( 1 - ASSSCI_books^2 ) * ( 1-ASMMAT_books^2 ) ) ),
+        # original correlation science and mathematics (already contained in res1)
+        "cor_sci_mat"=~ I(ASSSCI_ASMMAT),
+        # original correlation books and migrant
+        "cor_book_migra"=~ I(books_migrant)
+        )
+
+# statistical inference for derived parameters
+res2 <- BIFIEsurvey::BIFIE.derivedParameters( res1, derived.parameters )
+summary(res2)
+
+
-
- +
- - + + diff --git a/docs/reference/BIFIE.ecdf.html b/docs/reference/BIFIE.ecdf.html index cc07ef7..8ead2d9 100644 --- a/docs/reference/BIFIE.ecdf.html +++ b/docs/reference/BIFIE.ecdf.html @@ -1,71 +1,16 @@ - - - - - - - -Empirical Distribution Function and Quantiles — BIFIE.ecdf • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Empirical Distribution Function and Quantiles — BIFIE.ecdf • BIFIEsurvey - - - - - - - - - - - - - + + -
-
- -
- -
+
-
BIFIE.ecdf( BIFIEobj, vars, breaks=NULL, quanttype=1, group=NULL, group_values=NULL )
-
-# S3 method for BIFIE.ecdf
-summary(object,digits=4,...)
- -

Arguments

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BIFIEobj

Object of class BIFIEdata

vars

Vector of variables for which statistics should be computed.

breaks

Optional vector of breaks. Otherwise, it will be automatically defined.

quanttype

Type of calculation for quantiles. In case of quanttype=1, +

+
BIFIE.ecdf( BIFIEobj, vars, breaks=NULL, quanttype=1, group=NULL, group_values=NULL )
+
+# S3 method for BIFIE.ecdf
+summary(object,digits=4,...)
+
+ +
+

Arguments

+
BIFIEobj
+

Object of class BIFIEdata

+ +
vars
+

Vector of variables for which statistics should be computed.

+ +
breaks
+

Optional vector of breaks. Otherwise, it will be automatically defined.

+ +
quanttype
+

Type of calculation for quantiles. In case of quanttype=1, a linear interpolation is used (which is type='i/n' in -Hmisc::wtd.quantile), -while for quanttype=2 no interpolation is used.

group

Optional grouping variable

group_values

Optional vector of grouping values. This can be omitted and grouping -values will be determined automatically.

object

Object of class BIFIE.ecdf

digits

Number of digits for rounding output

...

Further arguments to be passed

- -

Value

- -

A list with following entries

-
ecdf

Data frame with probabilities and the empirical +Hmisc::wtd.quantile), +while for quanttype=2 no interpolation is used.

+ +
group
+

Optional grouping variable

+ +
group_values
+

Optional vector of grouping values. This can be omitted and grouping +values will be determined automatically.

+ +
object
+

Object of class BIFIE.ecdf

+ +
digits
+

Number of digits for rounding output

+ +
...
+

Further arguments to be passed

+ +
+
+

Value

+ + +

A list with following entries

+
ecdf
+

Data frame with probabilities and the empirical distribution function (See Examples).

-
stat

Data frame with empirical distribution function stacked with + +

stat
+

Data frame with empirical distribution function stacked with respect to variables, groups and group values

-
output

More extensive output

-
...

More values

- -

See also

- -

Hmisc::wtd.ecdf, -Hmisc::wtd.quantile

- -

Examples

-
#############################################################################
-# EXAMPLE 1: Imputed TIMSS dataset
-#############################################################################
-
-data(data.timss1)
-data(data.timssrep)
-
-# create BIFIE.dat object
-bifieobj <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
-           wgtrep=data.timssrep[, -1 ] )
-
-# ecdf
-vars <- c( "ASMMAT", "books")
-group <- "female" ; group_values <- 0:1
-# quantile type 1
-res1 <- BIFIEsurvey::BIFIE.ecdf( bifieobj,  vars=vars, group=group )
-summary(res1)
-res2 <- BIFIEsurvey::BIFIE.ecdf( bifieobj,  vars=vars, group=group, quanttype=2)
-# plot distribution function
-ecdf1 <- res1$ecdf
-plot( ecdf1$ASMMAT_female0, ecdf1$yval, type="l")
-plot( res2$ecdf$ASMMAT_female0, ecdf1$yval, type="l", lty=2)
-plot( ecdf1$books_female0, ecdf1$yval, type="l", col="blue")
+ +
output
+

More extensive output

+ +
...
+

More values

+ +
+
+

See also

+

Hmisc::wtd.ecdf, +Hmisc::wtd.quantile

+
+ +
+

Examples

+
#############################################################################
+# EXAMPLE 1: Imputed TIMSS dataset
+#############################################################################
+
+data(data.timss1)
+data(data.timssrep)
+
+# create BIFIE.dat object
+bifieobj <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
+           wgtrep=data.timssrep[, -1 ] )
+
+# ecdf
+vars <- c( "ASMMAT", "books")
+group <- "female" ; group_values <- 0:1
+# quantile type 1
+res1 <- BIFIEsurvey::BIFIE.ecdf( bifieobj,  vars=vars, group=group )
+summary(res1)
+res2 <- BIFIEsurvey::BIFIE.ecdf( bifieobj,  vars=vars, group=group, quanttype=2)
+# plot distribution function
+ecdf1 <- res1$ecdf
+plot( ecdf1$ASMMAT_female0, ecdf1$yval, type="l")
+plot( res2$ecdf$ASMMAT_female0, ecdf1$yval, type="l", lty=2)
+plot( ecdf1$books_female0, ecdf1$yval, type="l", col="blue")
+
+
-
- +
- - + + diff --git a/docs/reference/BIFIE.freq.html b/docs/reference/BIFIE.freq.html index a0efb01..f2a7f00 100644 --- a/docs/reference/BIFIE.freq.html +++ b/docs/reference/BIFIE.freq.html @@ -1,67 +1,12 @@ - - - - - - - -Frequency Statistics — BIFIE.freq • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Frequency Statistics — BIFIE.freq • BIFIEsurvey - - - - + + -
-
- -
- -
+
-
BIFIE.freq(BIFIEobj, vars, group=NULL, group_values=NULL, se=TRUE)
-
-# S3 method for BIFIE.freq
-summary(object,digits=3,...)
-
-# S3 method for BIFIE.freq
-coef(object,...)
-
-# S3 method for BIFIE.freq
-vcov(object,...)
- -

Arguments

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BIFIEobj

Object of class BIFIEdata

vars

Vector of variables for which statistics should be computed

group

Optional grouping variable(s)

group_values

Optional vector of grouping values. This can be omitted and grouping -values will be determined automatically.

se

Optional logical indicating whether statistical inference -based on replication should be employed.

object

Object of class BIFIE.freq

digits

Number of digits for rounding output

...

Further arguments to be passed

- -

Value

- -

A list with following entries

-
stat

Data frame with frequency statistics

-
output

Extensive output with all replicated statistics

-
...

More values

- -

See also

- -

survey::svytable, -intsvy::timss.table, -Hmisc::wtd.table

+
+
BIFIE.freq(BIFIEobj, vars, group=NULL, group_values=NULL, se=TRUE)
+
+# S3 method for BIFIE.freq
+summary(object,digits=3,...)
+
+# S3 method for BIFIE.freq
+coef(object,...)
+
+# S3 method for BIFIE.freq
+vcov(object,...)
+
+ +
+

Arguments

+
BIFIEobj
+

Object of class BIFIEdata

+ +
vars
+

Vector of variables for which statistics should be computed

+ +
group
+

Optional grouping variable(s)

-

Examples

-
#############################################################################
-# EXAMPLE 1: Imputed TIMSS dataset
-#############################################################################
+  
group_values
+

Optional vector of grouping values. This can be omitted and grouping +values will be determined automatically.

-data(data.timss1) -data(data.timssrep) +
se
+

Optional logical indicating whether statistical inference +based on replication should be employed.

-# create BIFIE.dat object -bdat <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT, - wgtrep=data.timssrep[, -1 ] ) +
object
+

Object of class BIFIE.freq

-# Frequencies for three variables -res1 <- BIFIEsurvey::BIFIE.freq( bdat, vars=c("lang", "books", "migrant" ) ) -summary(res1) +
digits
+

Number of digits for rounding output

-# Frequencies splitted by gender -res2 <- BIFIEsurvey::BIFIE.freq( bdat, vars=c("lang", "books", "migrant" ), - group="female", group_values=0:1 ) -summary(res2) +
...
+

Further arguments to be passed

-# Frequencies splitted by gender and likesc -res3 <- BIFIEsurvey::BIFIE.freq( bdat, vars=c("lang", "books", "migrant" ), - group=c("likesc","female") ) -summary(res3)
+
+
+

Value

+ + +

A list with following entries

+
stat
+

Data frame with frequency statistics

+ +
output
+

Extensive output with all replicated statistics

+ +
...
+

More values

+ +
+
+

See also

+

survey::svytable, +intsvy::timss.table, +Hmisc::wtd.table

+
+ +
+

Examples

+
#############################################################################
+# EXAMPLE 1: Imputed TIMSS dataset
+#############################################################################
+
+data(data.timss1)
+data(data.timssrep)
+
+# create BIFIE.dat object
+bdat <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
+           wgtrep=data.timssrep[, -1 ] )
+
+# Frequencies for three variables
+res1 <- BIFIEsurvey::BIFIE.freq( bdat, vars=c("lang", "books", "migrant" )  )
+summary(res1)
+
+# Frequencies splitted by gender
+res2 <- BIFIEsurvey::BIFIE.freq( bdat, vars=c("lang", "books", "migrant" ),
+              group="female", group_values=0:1 )
+summary(res2)
+
+# Frequencies splitted by gender and likesc
+res3 <- BIFIEsurvey::BIFIE.freq( bdat, vars=c("lang", "books", "migrant" ),
+              group=c("likesc","female")  )
+summary(res3)
+
+
-
- +
- - + + diff --git a/docs/reference/BIFIE.hist.html b/docs/reference/BIFIE.hist.html index 217cdd2..b08b0ae 100644 --- a/docs/reference/BIFIE.hist.html +++ b/docs/reference/BIFIE.hist.html @@ -1,69 +1,14 @@ - - - - - - - -Histogram — BIFIE.hist • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Histogram — BIFIE.hist • BIFIEsurvey - - - - - - - - - - - - - + + -
-
- -
- -
+
+
-
- +
- - + + diff --git a/docs/reference/BIFIE.lavaan.survey.html b/docs/reference/BIFIE.lavaan.survey.html index 33da0d9..a6937ff 100644 --- a/docs/reference/BIFIE.lavaan.survey.html +++ b/docs/reference/BIFIE.lavaan.survey.html @@ -1,70 +1,15 @@ - - - - - - - -Fitting a Model in <span class="pkg">lavaan</span> or in <span class="pkg">survey</span> — BIFIE.lavaan.survey • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -lavaan or in survey — BIFIE.lavaan.survey" /> -Fitting a Model in lavaan or in survey — BIFIE.lavaan.survey • BIFIEsurvey - - - - - - - - - - - - - + + -
-
- -
- -
+
+
-
- +
- - + + diff --git a/docs/reference/BIFIE.linreg.html b/docs/reference/BIFIE.linreg.html index 7c2ec1e..6a02edb 100644 --- a/docs/reference/BIFIE.linreg.html +++ b/docs/reference/BIFIE.linreg.html @@ -1,67 +1,12 @@ - - - - - - - -Linear Regression — BIFIE.linreg • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Linear Regression — BIFIE.linreg • BIFIEsurvey - - - - + + -
-
- -
- -
+
-
BIFIE.linreg(BIFIEobj, dep=NULL, pre=NULL, formula=NULL,
-    group=NULL, group_values=NULL, se=TRUE)
+    
+
BIFIE.linreg(BIFIEobj, dep=NULL, pre=NULL, formula=NULL,
+    group=NULL, group_values=NULL, se=TRUE)
+
+# S3 method for BIFIE.linreg
+summary(object,digits=4,...)
+
+# S3 method for BIFIE.linreg
+coef(object,...)
+
+# S3 method for BIFIE.linreg
+vcov(object,...)
+
-# S3 method for BIFIE.linreg -summary(object,digits=4,...) +
+

Arguments

+
BIFIEobj
+

Object of class BIFIEdata

-# S3 method for BIFIE.linreg -coef(object,...) +
dep
+

String for the dependent variable in the regression model

-# S3 method for BIFIE.linreg -vcov(object,...)
+
pre
+

Vector of predictor variables. If the intercept should be included, +then use the variable one for specifying it (see Examples).

-

Arguments

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BIFIEobj

Object of class BIFIEdata

dep

String for the dependent variable in the regression model

pre

Vector of predictor variables. If the intercept should be included, -then use the variable one for specifying it (see Examples).

formula

An R formula object which can be applied instead of +

formula
+

An R formula object which can be applied instead of providing dep and pre. Note that there is - additional computation time needed for model matrix creation.

group

Optional grouping variable(s)

group_values

Optional vector of grouping values. This can be omitted and grouping -values will be determined automatically.

se

Optional logical indicating whether statistical inference -based on replication should be employed.

object

Object of class BIFIE.linreg

digits

Number of digits for rounding output

...

Further arguments to be passed

- -

Value

- -

A list with following entries

-
stat

Data frame with unstandardized and standardized regression - coefficients, residual standard deviation and \(R^2\)

-
output

Extensive output with all replicated statistics

-
...

More values

- -

See also

- -

Alternative implementations: survey::svyglm, -intsvy::timss.reg, -intsvy::timss.reg.pv, -stats::lm

-

See BIFIE.logistreg for logistic regression.

- -

Examples

-
#############################################################################
-# EXAMPLE 1: Imputed TIMSS dataset
-#############################################################################
-
-data(data.timss1)
-data(data.timssrep)
-
-# create BIFIE.dat object
-bdat <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
-             wgtrep=data.timssrep[, -1 ] )
-
-#**** Model 1: Linear regression for mathematics score
-mod1 <- BIFIEsurvey::BIFIE.linreg( bdat, dep="ASMMAT", pre=c("one","books","migrant"),
-              group="female" )
-summary(mod1)
-
-if (FALSE) {
-# same model but specified with R formulas
-mod1a <- BIFIEsurvey::BIFIE.linreg( bdat, formula=ASMMAT ~ books + migrant,
-               group="female", group_values=0:1 )
-summary(mod1a)
-
-# compare result with lm function and first imputed dataset
-dat1 <- data.timss1[[1]]
-mod1b <- stats::lm( ASMMAT ~ 0 + as.factor(female) + as.factor(female):books +
-                              as.factor(female):migrant,
-                         data=dat1,  weights=dat1$TOTWGT )
-summary(mod1b)
+   additional computation time needed for model matrix creation.

-#**** Model 2: Like Model 1, but books is now treated as a factor -mod2 <- BIFIEsurvey::BIFIE.linreg( bdat, formula=ASMMAT ~ as.factor(books) + migrant) -summary(mod2) +
group
+

Optional grouping variable(s)

-############################################################################# -# EXAMPLE 2: PISA data | Nonlinear regression models -############################################################################# +
group_values
+

Optional vector of grouping values. This can be omitted and grouping +values will be determined automatically.

-data(data.pisaNLD) -data <- data.pisaNLD +
se
+

Optional logical indicating whether statistical inference +based on replication should be employed.

-#--- Create BIFIEdata object immediately using BIFIE.data.jack function -bdat <- BIFIEsurvey::BIFIE.data.jack( data.pisaNLD, jktype="RW_PISA", cdata=TRUE) -summary(bdat) +
object
+

Object of class BIFIE.linreg

-#**************************************************** -#*** Model 1: linear regression -mod1 <- BIFIEsurvey::BIFIE.linreg( bdat, formula=MATH ~ HISEI ) -summary(mod1) +
digits
+

Number of digits for rounding output

-#**************************************************** -#*** Model 2: Cubic regression -mod2 <- BIFIEsurvey::BIFIE.linreg( bdat, formula=MATH ~ HISEI + I(HISEI^2) + I(HISEI^3) ) -summary(mod2) +
...
+

Further arguments to be passed

-#**************************************************** -#*** Model 3: B-spline regression - -# test with design of HISEI values -dfr <- data.frame("HISEI"=16:90 ) -des <- stats::model.frame( ~ splines::bs( HISEI, df=5 ), dfr ) -des <- des$splines -plot( dfr$HISEI, des[,1], type="l", pch=1, lwd=2, ylim=c(0,1) ) -for (vv in 2:ncol(des) ){ - lines( dfr$HISEI, des[,vv], lty=vv, col=vv, lwd=2) -} - -# apply B-spline regression in BIFIEsurvey::BIFIE.linreg -mod3 <- BIFIEsurvey::BIFIE.linreg( bdat, formula=MATH ~ splines::bs(HISEI,df=5) ) -summary(mod3) - -#*** include transformed HISEI values for B-spline matrix in bdat -bdat2 <- BIFIEsurvey::BIFIE.data.transform( bdat, ~ 0 + splines::bs( HISEI, df=5 )) -bdat2$varnames[ bdat2$varsindex.added ] <- paste0("HISEI_bsdes", - seq( 1, length( bdat2$varsindex.added ) ) ) - -#**************************************************** -#*** Model 4: Nonparametric regression using BIFIE.by - -?BIFIE.by +
+
+

Value

+ -#---- (1) test function with one dataset -dat1 <- bdat$dat1 -vars <- c("MATH", "HISEI") -X <- dat1[,vars] -w <- bdat$wgt -X <- as.data.frame(X) -# estimate model -mod <- stats::loess( MATH ~ HISEI, weights=w, data=X ) +

A list with following entries

+
stat
+

Data frame with unstandardized and standardized regression + coefficients, residual standard deviation and \(R^2\)

-# predict HISEI values -hisei_val <- data.frame( "HISEI"=seq(16,90) ) -y_pred <- stats::predict( mod, hisei_val ) -graphics::plot( hisei_val$HISEI, y_pred, type="l") +
output
+

Extensive output with all replicated statistics

-#--- (2) define loess function -loess_fct <- function(X,w){ - X1 <- data.frame( X, w ) - colnames(X1) <- c( vars, "wgt") - X1 <- stats::na.omit(X1) -# mod <- stats::lm( MATH ~ HISEI, weights=X1$wgt, data=X1 ) - mod <- stats::loess( MATH ~ HISEI, weights=X1$wgt, data=X1 ) - y_pred <- stats::predict( mod, hisei_val ) - return(y_pred) -} +
...
+

More values

-#--- (3) estimate model -mod4 <- BIFIEsurvey::BIFIE.by( bdat, vars, userfct=loess_fct ) -summary(mod4) +
+
+

See also

+

Alternative implementations: survey::svyglm, +intsvy::timss.reg, +intsvy::timss.reg.pv, +stats::lm

+

See BIFIE.logistreg for logistic regression.

+
-# plot linear function pointwise and confidence intervals -graphics::plot( hisei_val$HISEI, mod4$stat$est, type="l", lwd=2, - xlab="HISEI", ylab="PVMATH", ylim=c(430,670) ) -graphics::lines( hisei_val$HISEI, mod4$stat$est - 1.96* mod4$stat$SE, lty=3 ) -graphics::lines( hisei_val$HISEI, mod4$stat$est + 1.96* mod4$stat$SE, lty=3 ) -} +
+

Examples

+
#############################################################################
+# EXAMPLE 1: Imputed TIMSS dataset
+#############################################################################
+
+data(data.timss1)
+data(data.timssrep)
+
+# create BIFIE.dat object
+bdat <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
+             wgtrep=data.timssrep[, -1 ] )
+
+#**** Model 1: Linear regression for mathematics score
+mod1 <- BIFIEsurvey::BIFIE.linreg( bdat, dep="ASMMAT", pre=c("one","books","migrant"),
+              group="female" )
+summary(mod1)
+
+if (FALSE) {
+# same model but specified with R formulas
+mod1a <- BIFIEsurvey::BIFIE.linreg( bdat, formula=ASMMAT ~ books + migrant,
+               group="female", group_values=0:1 )
+summary(mod1a)
+
+# compare result with lm function and first imputed dataset
+dat1 <- data.timss1[[1]]
+mod1b <- stats::lm( ASMMAT ~ 0 + as.factor(female) + as.factor(female):books +
+                              as.factor(female):migrant,
+                         data=dat1,  weights=dat1$TOTWGT )
+summary(mod1b)
+
+#**** Model 2: Like Model 1, but books is now treated as a factor
+mod2 <- BIFIEsurvey::BIFIE.linreg( bdat, formula=ASMMAT ~ as.factor(books) + migrant)
+summary(mod2)
+
+#############################################################################
+# EXAMPLE 2: PISA data | Nonlinear regression models
+#############################################################################
+
+data(data.pisaNLD)
+data <- data.pisaNLD
+
+#--- Create BIFIEdata object immediately using BIFIE.data.jack function
+bdat <- BIFIEsurvey::BIFIE.data.jack( data.pisaNLD, jktype="RW_PISA", cdata=TRUE)
+summary(bdat)
+
+#****************************************************
+#*** Model 1: linear regression
+mod1 <- BIFIEsurvey::BIFIE.linreg( bdat, formula=MATH ~ HISEI )
+summary(mod1)
+
+#****************************************************
+#*** Model 2: Cubic regression
+mod2 <- BIFIEsurvey::BIFIE.linreg( bdat, formula=MATH ~ HISEI + I(HISEI^2) + I(HISEI^3) )
+summary(mod2)
+
+#****************************************************
+#*** Model 3: B-spline regression
+
+# test with design of HISEI values
+dfr <- data.frame("HISEI"=16:90 )
+des <- stats::model.frame( ~ splines::bs( HISEI, df=5 ), dfr )
+des <- des$splines
+plot( dfr$HISEI, des[,1], type="l", pch=1, lwd=2, ylim=c(0,1) )
+for (vv in 2:ncol(des) ){
+    lines( dfr$HISEI, des[,vv], lty=vv, col=vv, lwd=2)
+}
+
+# apply B-spline regression in BIFIEsurvey::BIFIE.linreg
+mod3 <- BIFIEsurvey::BIFIE.linreg( bdat, formula=MATH ~ splines::bs(HISEI,df=5) )
+summary(mod3)
+
+#*** include transformed HISEI values for B-spline matrix in bdat
+bdat2 <- BIFIEsurvey::BIFIE.data.transform( bdat, ~ 0 + splines::bs( HISEI, df=5 ))
+bdat2$varnames[ bdat2$varsindex.added ] <- paste0("HISEI_bsdes",
+            seq( 1, length( bdat2$varsindex.added ) ) )
+
+#****************************************************
+#*** Model 4: Nonparametric regression using BIFIE.by
+
+?BIFIE.by
+
+#---- (1) test function with one dataset
+dat1 <- bdat$dat1
+vars <- c("MATH", "HISEI")
+X <- dat1[,vars]
+w <- bdat$wgt
+X <- as.data.frame(X)
+# estimate model
+mod <- stats::loess( MATH ~ HISEI, weights=w, data=X )
+
+# predict HISEI values
+hisei_val <- data.frame( "HISEI"=seq(16,90) )
+y_pred <- stats::predict( mod, hisei_val )
+graphics::plot( hisei_val$HISEI, y_pred, type="l")
+
+#--- (2) define loess function
+loess_fct <- function(X,w){
+    X1 <- data.frame( X, w )
+    colnames(X1) <- c( vars, "wgt")
+    X1 <- stats::na.omit(X1)
+#    mod <- stats::lm( MATH ~ HISEI, weights=X1$wgt, data=X1 )
+    mod <- stats::loess( MATH ~ HISEI, weights=X1$wgt, data=X1 )
+    y_pred <- stats::predict( mod, hisei_val )
+    return(y_pred)
+}
+
+#--- (3) estimate model
+mod4 <-  BIFIEsurvey::BIFIE.by( bdat, vars, userfct=loess_fct )
+summary(mod4)
+
+# plot linear function pointwise and confidence intervals
+graphics::plot( hisei_val$HISEI, mod4$stat$est, type="l", lwd=2,
+        xlab="HISEI", ylab="PVMATH", ylim=c(430,670) )
+graphics::lines( hisei_val$HISEI, mod4$stat$est - 1.96* mod4$stat$SE, lty=3 )
+graphics::lines( hisei_val$HISEI, mod4$stat$est + 1.96* mod4$stat$SE, lty=3 )
+}
+
+
-
- +
- - + + diff --git a/docs/reference/BIFIE.logistreg.html b/docs/reference/BIFIE.logistreg.html index 1da9a4c..808822c 100644 --- a/docs/reference/BIFIE.logistreg.html +++ b/docs/reference/BIFIE.logistreg.html @@ -1,68 +1,13 @@ - - - - - - - -Logistic Regression — BIFIE.logistreg • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Logistic Regression — BIFIE.logistreg • BIFIEsurvey - - - - + + -
-
- -
- -
+
-
BIFIE.logistreg(BIFIEobj, dep=NULL, pre=NULL, formula=NULL,
-    group=NULL, group_values=NULL, se=TRUE, eps=1E-8, maxiter=100)
-
-# S3 method for BIFIE.logistreg
-summary(object,digits=4,...)
-
-# S3 method for BIFIE.logistreg
-coef(object,...)
-
-# S3 method for BIFIE.logistreg
-vcov(object,...)
- -

Arguments

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BIFIEobj

Object of class BIFIEdata

dep

String for the dependent variable in the regression model

pre

Vector of predictor variables. If the intercept should be included, -then use the variable one for specifying it (see Examples).

formula

An R formula object which can be applied instead of +

+
BIFIE.logistreg(BIFIEobj, dep=NULL, pre=NULL, formula=NULL,
+    group=NULL, group_values=NULL, se=TRUE, eps=1E-8, maxiter=100)
+
+# S3 method for BIFIE.logistreg
+summary(object,digits=4,...)
+
+# S3 method for BIFIE.logistreg
+coef(object,...)
+
+# S3 method for BIFIE.logistreg
+vcov(object,...)
+
+ +
+

Arguments

+
BIFIEobj
+

Object of class BIFIEdata

+ +
dep
+

String for the dependent variable in the regression model

+ +
pre
+

Vector of predictor variables. If the intercept should be included, +then use the variable one for specifying it (see Examples).

+ +
formula
+

An R formula object which can be applied instead of providing dep and pre. Note that there is - additional computation time needed for model matrix creation.

group

Optional grouping variable(s)

group_values

Optional vector of grouping values. This can be omitted and grouping -values will be determined automatically.

se

Optional logical indicating whether statistical inference -based on replication should be employed.

eps

Convergence criterion for parameters

maxiter

Maximum number of iterations

object

Object of class BIFIE.logistreg

digits

Number of digits for rounding output

...

Further arguments to be passed

- -

Value

- -

A list with following entries

-
stat

Data frame with regression coefficients

-
output

Extensive output with all replicated statistics

-
...

More values

- -

See also

- -

survey::svyglm, -stats::glm

-

For linear regressions see BIFIE.linreg.

- -

Examples

-
#############################################################################
-# EXAMPLE 1: TIMSS dataset | Logistic regression
-#############################################################################
-
-data(data.timss2)
-data(data.timssrep)
-
-# create BIFIE.dat object
-bdat <- BIFIEsurvey::BIFIE.data( data.list=data.timss2, wgt=data.timss2[[1]]$TOTWGT,
-                      wgtrep=data.timssrep[, -1 ] )
-
-#**** Model 1: Logistic regression - prediction of migrational background
-res1 <- BIFIEsurvey::BIFIE.logistreg( BIFIEobj=bdat, dep="migrant",
-           pre=c("one","books","lang"), group="female", se=FALSE )
-summary(res1)
-
-if (FALSE) {
-# same model, but with formula specification and standard errors
-res1a <- BIFIEsurvey::BIFIE.logistreg( BIFIEobj=bdat,
-              formula=migrant ~ books + lang, group="female"  )
-summary(res1a)
-
-#############################################################################
-# SIMULATED EXAMPLE 2: Comparison of stats::glm and BIFIEsurvey::BIFIE.logistreg
-#############################################################################
-
-#*** (1) simulate data
-set.seed(987)
-N <- 300
-x1 <- stats::rnorm(N)
-x2 <- stats::runif(N)
-ypred <- -0.75+.2*x1 + 3*x2
-y <- 1*( stats::plogis(ypred) > stats::runif(N) )
-data <- data.frame( "y"=y, "x1"=x1, "x2"=x2 )
-
-#*** (2) estimation logistic regression using glm
-mod1 <- stats::glm( y ~ x1 + x2, family="binomial")
-
-#*** (3) estimation logistic regression using BIFIEdata
-# create BIFIEdata object by defining 30 Jackknife zones
-bifiedata <- BIFIEsurvey::BIFIE.data.jack( data, jktype="JK_RANDOM", ngr=30 )
-summary(bifiedata)
-# estimate logistic regression
-mod2 <- BIFIEsurvey::BIFIE.logistreg( bifiedata, formula=y ~ x1+x2 )
-
-#*** (4) compare results
-summary(mod2)    # BIFIE.logistreg
-summary(mod1)   # glm
-}
+ additional computation time needed for model matrix creation.

+ +
group
+

Optional grouping variable(s)

+ +
group_values
+

Optional vector of grouping values. This can be omitted and grouping +values will be determined automatically.

+ +
se
+

Optional logical indicating whether statistical inference +based on replication should be employed.

+ +
eps
+

Convergence criterion for parameters

+ +
maxiter
+

Maximum number of iterations

+ +
object
+

Object of class BIFIE.logistreg

+ +
digits
+

Number of digits for rounding output

+ +
...
+

Further arguments to be passed

+ +
+
+

Value

+ + +

A list with following entries

+
stat
+

Data frame with regression coefficients

+ +
output
+

Extensive output with all replicated statistics

+ +
...
+

More values

+ +
+
+

See also

+

survey::svyglm, +stats::glm

+

For linear regressions see BIFIE.linreg.

+
+ +
+

Examples

+
#############################################################################
+# EXAMPLE 1: TIMSS dataset | Logistic regression
+#############################################################################
+
+data(data.timss2)
+data(data.timssrep)
+
+# create BIFIE.dat object
+bdat <- BIFIEsurvey::BIFIE.data( data.list=data.timss2, wgt=data.timss2[[1]]$TOTWGT,
+                      wgtrep=data.timssrep[, -1 ] )
+
+#**** Model 1: Logistic regression - prediction of migrational background
+res1 <- BIFIEsurvey::BIFIE.logistreg( BIFIEobj=bdat, dep="migrant",
+           pre=c("one","books","lang"), group="female", se=FALSE )
+summary(res1)
+
+if (FALSE) {
+# same model, but with formula specification and standard errors
+res1a <- BIFIEsurvey::BIFIE.logistreg( BIFIEobj=bdat,
+              formula=migrant ~ books + lang, group="female"  )
+summary(res1a)
+
+#############################################################################
+# SIMULATED EXAMPLE 2: Comparison of stats::glm and BIFIEsurvey::BIFIE.logistreg
+#############################################################################
+
+#*** (1) simulate data
+set.seed(987)
+N <- 300
+x1 <- stats::rnorm(N)
+x2 <- stats::runif(N)
+ypred <- -0.75+.2*x1 + 3*x2
+y <- 1*( stats::plogis(ypred) > stats::runif(N) )
+data <- data.frame( "y"=y, "x1"=x1, "x2"=x2 )
+
+#*** (2) estimation logistic regression using glm
+mod1 <- stats::glm( y ~ x1 + x2, family="binomial")
+
+#*** (3) estimation logistic regression using BIFIEdata
+# create BIFIEdata object by defining 30 Jackknife zones
+bifiedata <- BIFIEsurvey::BIFIE.data.jack( data, jktype="JK_RANDOM", ngr=30 )
+summary(bifiedata)
+# estimate logistic regression
+mod2 <- BIFIEsurvey::BIFIE.logistreg( bifiedata, formula=y ~ x1+x2 )
+
+#*** (4) compare results
+summary(mod2)    # BIFIE.logistreg
+summary(mod1)   # glm
+}
+
+
-
- +
- - + + diff --git a/docs/reference/BIFIE.mva.html b/docs/reference/BIFIE.mva.html index 6dc1619..a6db559 100644 --- a/docs/reference/BIFIE.mva.html +++ b/docs/reference/BIFIE.mva.html @@ -1,67 +1,12 @@ - - - - - - - -Missing Value Analysis — BIFIE.mva • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Missing Value Analysis — BIFIE.mva • BIFIEsurvey - - - - + + -
-
- -
- -
+
-
BIFIE.mva( BIFIEobj, missvars, covariates=NULL, se=TRUE )
-
-# S3 method for BIFIE.mva
-summary(object,digits=4,...)
- -

Arguments

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BIFIEobj

Object of class BIFIEdata

missvars

Vector of variables for which missing value statistics should be computed

covariates

Vector of variables which work as covariates

se

Optional logical indicating whether statistical inference -based on replication should be employed.

object

Object of class BIFIE.correl

digits

Number of digits for rounding output

...

Further arguments to be passed

- -

Value

- -

A list with following entries

-
stat.mva

Data frame with missing value statistics

-
res_list

List with extensive output split - according to each variable in missvars

-
...

More values

+
+
BIFIE.mva( BIFIEobj, missvars, covariates=NULL, se=TRUE )
+
+# S3 method for BIFIE.mva
+summary(object,digits=4,...)
+
+
+

Arguments

+
BIFIEobj
+

Object of class BIFIEdata

-

Examples

-
#############################################################################
-# EXAMPLE 1: Imputed TIMSS dataset
-#############################################################################
+  
missvars
+

Vector of variables for which missing value statistics should be computed

-data(data.timss1) -data(data.timssrep) +
covariates
+

Vector of variables which work as covariates

-# create BIFIE.dat object -BIFIEdata <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, - wgt=data.timss1[[1]]$TOTWGT, wgtrep=data.timssrep[, -1 ] ) +
se
+

Optional logical indicating whether statistical inference +based on replication should be employed.

-# missing value analysis for "scsci" and "books" and three covariates -res1 <- BIFIEsurvey::BIFIE.mva( BIFIEdata, missvars=c("scsci", "books" ), - covariates=c("ASMMAT", "female", "ASSSCI") ) -summary(res1) +
object
+

Object of class BIFIE.correl

-# missing value analysis without statistical inference and without covariates -res2 <- BIFIEsurvey::BIFIE.mva( BIFIEdata, missvars=c("scsci", "books"), se=FALSE) -summary(res2)
+
digits
+

Number of digits for rounding output

+ +
...
+

Further arguments to be passed

+ +
+
+

Value

+ + +

A list with following entries

+
stat.mva
+

Data frame with missing value statistics

+ +
res_list
+

List with extensive output split + according to each variable in missvars

+ +
...
+

More values

+ +
+ +
+

Examples

+
#############################################################################
+# EXAMPLE 1: Imputed TIMSS dataset
+#############################################################################
+
+data(data.timss1)
+data(data.timssrep)
+
+# create BIFIE.dat object
+BIFIEdata <- BIFIEsurvey::BIFIE.data( data.list=data.timss1,
+                wgt=data.timss1[[1]]$TOTWGT, wgtrep=data.timssrep[, -1 ] )
+
+# missing value analysis for "scsci" and "books" and three covariates
+res1 <- BIFIEsurvey::BIFIE.mva( BIFIEdata, missvars=c("scsci", "books" ),
+             covariates=c("ASMMAT", "female", "ASSSCI") )
+summary(res1)
+
+# missing value analysis without statistical inference and without covariates
+res2 <- BIFIEsurvey::BIFIE.mva( BIFIEdata, missvars=c("scsci", "books"), se=FALSE)
+summary(res2)
+
+
-
- +
- - + + diff --git a/docs/reference/BIFIE.pathmodel.html b/docs/reference/BIFIE.pathmodel.html index c80c056..26eb4b8 100644 --- a/docs/reference/BIFIE.pathmodel.html +++ b/docs/reference/BIFIE.pathmodel.html @@ -1,74 +1,19 @@ - - - - - - - -Path Model Estimation — BIFIE.pathmodel • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Path Model Estimation — BIFIE.pathmodel • BIFIEsurvey - - - - - - - - - - - - - + + -
-
- -
- -
+
-
BIFIE.pathmodel( BIFIEobj, lavaan.model, reliability=NULL, group=NULL,
-        group_values=NULL, se=TRUE )
-
-# S3 method for BIFIE.pathmodel
-summary(object,digits=4,...)
-
-# S3 method for BIFIE.pathmodel
-coef(object,...)
+    
+
BIFIE.pathmodel( BIFIEobj, lavaan.model, reliability=NULL, group=NULL,
+        group_values=NULL, se=TRUE )
+
+# S3 method for BIFIE.pathmodel
+summary(object,digits=4,...)
+
+# S3 method for BIFIE.pathmodel
+coef(object,...)
+
+# S3 method for BIFIE.pathmodel
+vcov(object,...)
+
-# S3 method for BIFIE.pathmodel -vcov(object,...)
+
+

Arguments

+
BIFIEobj
+

Object of class BIFIEdata

-

Arguments

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BIFIEobj

Object of class BIFIEdata

lavaan.model

String including the model specification in +

lavaan.model
+

String including the model specification in lavaan syntax. lavaan.model also allows the extended functionality in the - TAM::lavaanify.IRT function.

reliability

Optional vector containing the reliabilities of each variable. -This vector can also include only a subset of all variables.

group

Optional grouping variable(s)

group_values

Optional vector of grouping values. This can be omitted and grouping -values will be determined automatically.

se

Optional logical indicating whether statistical inference -based on replication should be employed.

object

Object of class BIFIE.pathmodel

digits

Number of digits for rounding output

...

Further arguments to be passed

+ TAM::lavaanify.IRT function.

+ +
reliability
+

Optional vector containing the reliabilities of each variable. +This vector can also include only a subset of all variables.

+ +
group
+

Optional grouping variable(s)

-

Details

+
group_values
+

Optional vector of grouping values. This can be omitted and grouping +values will be determined automatically.

+
se
+

Optional logical indicating whether statistical inference +based on replication should be employed.

+ +
object
+

Object of class BIFIE.pathmodel

+ +
digits
+

Number of digits for rounding output

+ +
...
+

Further arguments to be passed

+ +
+
+

Details

The following conventions are used as parameter labels in the output.

Y~X is the regression coefficient of the regression from \(Y\) on \(X\).

@@ -201,95 +124,104 @@

Details

X-~>Y denotes the sum of all indirect effects from \(X\) to \(Y\).

The parameter suffix _stand refers to parameters for which all variables are standardized.

-

Value

+
+
+

Value

+ -

A list with following entries

-
stat

Data frame with unstandardized and standardized regression +

A list with following entries

+
stat
+

Data frame with unstandardized and standardized regression coefficients, path coefficients, total and indirect effects, residual variances, and \(R^2\)

-
output

Extensive output with all replicated statistics

-
...

More values

-

References

+
output
+

Extensive output with all replicated statistics

+
...
+

More values

+ +
+
+

References

Buonaccorsi, J. P. (2010). Measurement error: Models, methods, and applications. CRC Press.

-

See also

- -

See the lavaan and lavaan.survey package.

+
+
+

See also

+

See the lavaan and lavaan.survey package.

For the lavaan syntax, see -lavaan::lavaanify and -TAM::lavaanify.IRT

- -

Examples

-
if (FALSE) {
-#############################################################################
-# EXAMPLE 1: Path model data.bifie01
-#############################################################################
-
-data(data.bifie01)
-dat <- data.bifie01
-# create dataset with replicate weights and plausible values
-bifieobj <- BIFIEsurvey::BIFIE.data.jack( data=dat,  jktype="JK_TIMSS",
-                jkzone="JKCZONE", jkrep="JKCREP", wgt="TOTWGT",
-                pv_vars=c("ASMMAT","ASSSCI") )
-
-#**************************************************************
-#*** Model 1: Path model
-lavmodel1 <- "
-     ASMMAT ~ ASBG07A + ASBG07B  + ASBM03 + ASBM02A + ASBM02E
-     # define latent variable with 2nd and 3rd item in reversed scoring
-     ASBM03=~ 1*ASBM03A + (-1)*ASBM03B + (-1)*ASBM03C + 1*ASBM03D
-     ASBG07A ~ ASBM02E
-     ASBG07A ~~ .2*ASBG07A    # measurement error variance of .20
-     ASBM02E ~~ .45*ASBM02E     # measurement error variance of .45
-     ASBM02E ~ ASBM02A + ASBM02B
-        "
-#--- Model 1a: model calculated by gender
-mod1a <- BIFIEsurvey::BIFIE.pathmodel( bifieobj, lavmodel1, group="female" )
-summary(mod1a)
-
-#--- Model 1b: Input of some known reliabilities
-reliability <- c( "ASBM02B"=.6, "ASBM02A"=.8 )
-mod1b <- BIFIEsurvey::BIFIE.pathmodel( bifieobj, lavmodel1, reliability=reliability)
-summary(mod1b)
-
-#**************************************************************
-#*** Model 2: Linear regression with errors in predictors
+lavaan::lavaanify and
+TAM::lavaanify.IRT

+
-# specify lavaan model -lavmodel2 <- " - ASMMAT ~ ASBG07A + ASBG07B + ASBM03A - ASBG07A ~~ .2*ASBG07A - " -mod2 <- BIFIEsurvey::BIFIE.pathmodel( bifieobj, lavmodel2 ) -summary(mod2) -} +
+

Examples

+
if (FALSE) {
+#############################################################################
+# EXAMPLE 1: Path model data.bifie01
+#############################################################################
+
+data(data.bifie01)
+dat <- data.bifie01
+# create dataset with replicate weights and plausible values
+bifieobj <- BIFIEsurvey::BIFIE.data.jack( data=dat,  jktype="JK_TIMSS",
+                jkzone="JKCZONE", jkrep="JKCREP", wgt="TOTWGT",
+                pv_vars=c("ASMMAT","ASSSCI") )
+
+#**************************************************************
+#*** Model 1: Path model
+lavmodel1 <- "
+     ASMMAT ~ ASBG07A + ASBG07B  + ASBM03 + ASBM02A + ASBM02E
+     # define latent variable with 2nd and 3rd item in reversed scoring
+     ASBM03=~ 1*ASBM03A + (-1)*ASBM03B + (-1)*ASBM03C + 1*ASBM03D
+     ASBG07A ~ ASBM02E
+     ASBG07A ~~ .2*ASBG07A    # measurement error variance of .20
+     ASBM02E ~~ .45*ASBM02E     # measurement error variance of .45
+     ASBM02E ~ ASBM02A + ASBM02B
+        "
+#--- Model 1a: model calculated by gender
+mod1a <- BIFIEsurvey::BIFIE.pathmodel( bifieobj, lavmodel1, group="female" )
+summary(mod1a)
+
+#--- Model 1b: Input of some known reliabilities
+reliability <- c( "ASBM02B"=.6, "ASBM02A"=.8 )
+mod1b <- BIFIEsurvey::BIFIE.pathmodel( bifieobj, lavmodel1, reliability=reliability)
+summary(mod1b)
+
+#**************************************************************
+#*** Model 2: Linear regression with errors in predictors
+
+# specify lavaan model
+lavmodel2 <- "
+     ASMMAT ~ ASBG07A + ASBG07B + ASBM03A
+     ASBG07A ~~ .2*ASBG07A
+        "
+mod2 <- BIFIEsurvey::BIFIE.pathmodel( bifieobj, lavmodel2  )
+summary(mod2)
+}
+
+
-
- +
- - + + diff --git a/docs/reference/BIFIE.twolevelreg.html b/docs/reference/BIFIE.twolevelreg.html index db40cf1..2a1ed27 100644 --- a/docs/reference/BIFIE.twolevelreg.html +++ b/docs/reference/BIFIE.twolevelreg.html @@ -1,70 +1,15 @@ - - - - - - - -Two Level Regression — BIFIE.twolevelreg • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Two Level Regression — BIFIE.twolevelreg • BIFIEsurvey - - - - - - - - - - - - - + + -
-
- -
- -
+
-
BIFIE.twolevelreg( BIFIEobj, dep, formula.fixed, formula.random, idcluster,
-   wgtlevel2=NULL, wgtlevel1=NULL, group=NULL, group_values=NULL,
-   recov_constraint=NULL, se=TRUE, globconv=1E-6, maxiter=1000 )
-
-# S3 method for BIFIE.twolevelreg
-summary(object,digits=4,...)
-
-# S3 method for BIFIE.twolevelreg
-coef(object,...)
-
-# S3 method for BIFIE.twolevelreg
-vcov(object,...)
- -

Arguments

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BIFIEobj

Object of class BIFIEdata

dep

String for the dependent variable in the regression model

formula.fixed

An R formula for fixed effects

formula.random

An R formula for random effects

idcluster

Cluster identifier. The cluster identifiers must be -sorted in the BIFIE.data object.

wgtlevel2

Name of Level 2 weight variable

wgtlevel1

Name of Level 1 weight variable. This is optional. +

+
BIFIE.twolevelreg( BIFIEobj, dep, formula.fixed, formula.random, idcluster,
+   wgtlevel2=NULL, wgtlevel1=NULL, group=NULL, group_values=NULL,
+   recov_constraint=NULL, se=TRUE, globconv=1E-6, maxiter=1000 )
+
+# S3 method for BIFIE.twolevelreg
+summary(object,digits=4,...)
+
+# S3 method for BIFIE.twolevelreg
+coef(object,...)
+
+# S3 method for BIFIE.twolevelreg
+vcov(object,...)
+
+ +
+

Arguments

+
BIFIEobj
+

Object of class BIFIEdata

+ +
dep
+

String for the dependent variable in the regression model

+ +
formula.fixed
+

An R formula for fixed effects

+ +
formula.random
+

An R formula for random effects

+ +
idcluster
+

Cluster identifier. The cluster identifiers must be +sorted in the BIFIE.data object.

+ +
wgtlevel2
+

Name of Level 2 weight variable

+ +
wgtlevel1
+

Name of Level 1 weight variable. This is optional. If it is not provided, wgtlevel is calculated from - the total weight and wgtlevel2.

group

Optional grouping variable

group_values

Optional vector of grouping values. This can be omitted and grouping -values will be determined automatically.

recov_constraint

Matrix for constraints of random effects covariance + the total weight and wgtlevel2.

+ +
group
+

Optional grouping variable

+ +
group_values
+

Optional vector of grouping values. This can be omitted and grouping +values will be determined automatically.

+ +
recov_constraint
+

Matrix for constraints of random effects covariance matrix. The random effects are numbered according to the order in the specification in formula.random. The first column in recov_constraint contains the row index in the covariance matrix, the second column the column index and the third column -the value to be fixed.

se

Optional logical indicating whether statistical inference +the value to be fixed.

+ +
se
+

Optional logical indicating whether statistical inference based on replication should be employed. In case of se=FALSE, standard errors are computed as maximum likelihood estimates under -the assumption of random sampling of level 2 clusters.

globconv

Convergence criterion for maximum parameter change

maxiter

Maximum number of iterations

object

Object of class BIFIE.twolevelreg

digits

Number of digits for rounding output

...

Further arguments to be passed

- -

Details

+the assumption of random sampling of level 2 clusters.

+ +
globconv
+

Convergence criterion for maximum parameter change

+ +
maxiter
+

Maximum number of iterations

+
object
+

Object of class BIFIE.twolevelreg

+ +
digits
+

Number of digits for rounding output

+ +
...
+

Further arguments to be passed

+ +
+
+

Details

The implemented random slope model can be written as $$y_{ij}=\bold{X}_{ij} \bold{\gamma} + \bold{Z}_{ij} \bold{u}_j + \varepsilon_{ij}$$ @@ -234,56 +150,65 @@

Details \( \bold{X}_{ij}=\bold{X}_j^B + \bold{X}_{ij}^W\). The different sources of variance are computed by formulas as proposed in Snijders and Bosker (2012, Ch. 7).

-

Value

+
+
+

Value

+ -

A list with following entries

-
stat

Data frame with coefficients and different sources +

A list with following entries

+
stat
+

Data frame with coefficients and different sources of variance.

-
output

Extensive output with all replicated statistics

-
...

More values

-

References

+
output
+

Extensive output with all replicated statistics

+ +
...
+

More values

+
+
+

References

Raudenbush, S. W., & Bryk, A. S. (2002). Hierarchical linear models: Applications and data analysis methods. Thousand Oaks: Sage.

Snijders, T. A. B., & Bosker, R. J. (2012). Multilevel analysis: An introduction to basic and advanced multilevel modeling. Thousand Oaks: Sage.

-

See also

- -

The lme4::lmer function in the lme4 package allows only +

+
+

See also

+

The lme4::lmer function in the lme4 package allows only weights at the first level.

See the WeMix package (and the function WeMix::mix) for estimation of mixed effects models with weights at different levels.

+
-

Examples

-

+    
+

Examples

+ +
+
-
- +
- - + + diff --git a/docs/reference/BIFIE.univar.html b/docs/reference/BIFIE.univar.html index a47d9ae..3e7637f 100644 --- a/docs/reference/BIFIE.univar.html +++ b/docs/reference/BIFIE.univar.html @@ -1,68 +1,13 @@ - - - - - - - -Univariate Descriptive Statistics (Means and Standard Deviations) — BIFIE.univar • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Univariate Descriptive Statistics (Means and Standard Deviations) — BIFIE.univar • BIFIEsurvey - - - - + + -
-
- -
- -
+
-
BIFIE.univar(BIFIEobj, vars, group=NULL, group_values=NULL, se=TRUE)
-
-# S3 method for BIFIE.univar
-summary(object,digits=3,...)
-
-# S3 method for BIFIE.univar
-coef(object,...)
+    
+
BIFIE.univar(BIFIEobj, vars, group=NULL, group_values=NULL, se=TRUE)
+
+# S3 method for BIFIE.univar
+summary(object,digits=3,...)
+
+# S3 method for BIFIE.univar
+coef(object,...)
+
+# S3 method for BIFIE.univar
+vcov(object,...)
+
-# S3 method for BIFIE.univar -vcov(object,...)
+
+

Arguments

+
BIFIEobj
+

Object of class BIFIEdata

-

Arguments

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BIFIEobj

Object of class BIFIEdata

vars

Vector of variables for which statistics should be computed

group

Optional grouping variable(s)

group_values

Optional vector of grouping values. This can be omitted and grouping -values will be determined automatically.

se

Optional logical indicating whether statistical inference -based on replication should be employed.

object

Object of class BIFIE.univar

digits

Number of digits for rounding output

...

Further arguments to be passed

+
vars
+

Vector of variables for which statistics should be computed

-

Value

+
group
+

Optional grouping variable(s)

-

A list with following entries

-
stat

Data frame with univariate statistics

-
stat_M

Data frame with means

-
stat_SD

Data frame with standard deviations

-
output

Extensive output with all replicated statistics

-
...

More values

+
group_values
+

Optional vector of grouping values. This can be omitted and grouping +values will be determined automatically.

-

See also

+
se
+

Optional logical indicating whether statistical inference +based on replication should be employed.

-

See BIFIE.univar.test for a test of equal means and -effect sizes \(\eta\) and \(d\).

-

Descriptive statistics without statistical inference can be -estimated by the collection of -miceadds::ma.wtd.statNA -functions from the miceadds package.

-

Further descriptive functions:

-

survey::svymean, -intsvy::timss.mean, -intsvy::timss.mean.pv, -stats::weighted.mean, -Hmisc::wtd.mean, -miceadds::ma.wtd.meanNA

-

survey::svyvar, -Hmisc::wtd.var, -miceadds::ma.wtd.sdNA, -miceadds::ma.wtd.covNA

+
object
+

Object of class BIFIE.univar

-

Examples

-
#############################################################################
-# EXAMPLE 1: Imputed TIMSS dataset
-#############################################################################
+
digits
+

Number of digits for rounding output

-data(data.timss1) -data(data.timssrep) +
...
+

Further arguments to be passed

-# create BIFIE.dat object -bdat <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT, - wgtrep=data.timssrep[, -1 ] ) +
+
+

Value

+ -# compute descriptives for plausible values -res1 <- BIFIEsurvey::BIFIE.univar( bdat, vars=c("ASMMAT","ASSSCI","books") ) -summary(res1) +

A list with following entries

+
stat
+

Data frame with univariate statistics

-# split descriptives by number of books -res2 <- BIFIEsurvey::BIFIE.univar( bdat, vars=c("ASMMAT","ASSSCI"), group="books", - group_values=1:5) -summary(res2) +
stat_M
+

Data frame with means

-############################################################################# -# EXAMPLE 2: TIMSS dataset with missings -############################################################################# +
stat_SD
+

Data frame with standard deviations

-data(data.timss2) -data(data.timssrep) +
output
+

Extensive output with all replicated statistics

-# use first dataset with missing data from data.timss2 -bdat1 <- BIFIEsurvey::BIFIE.data( data.list=data.timss2[[1]], wgt=data.timss2[[1]]$TOTWGT, - wgtrep=data.timssrep[, -1 ]) +
...
+

More values

-# some descriptive statistics without statistical inference -res1a <- BIFIEsurvey::BIFIE.univar( bdat1, vars=c("ASMMAT","ASSSCI","books"), se=FALSE) -# descriptive statistics with statistical inference -res1b <- BIFIEsurvey::BIFIE.univar( bdat1, vars=c("ASMMAT","ASSSCI","books") ) -summary(res1a) -summary(res1b) +
+
+

See also

+

See BIFIE.univar.test for a test of equal means and +effect sizes \(\eta\) and \(d\).

+

Descriptive statistics without statistical inference can be +estimated by the collection of +miceadds::ma.wtd.statNA +functions from the miceadds package.

+

Further descriptive functions:

+

survey::svymean, +intsvy::timss.mean, +intsvy::timss.mean.pv, +stats::weighted.mean, +Hmisc::wtd.mean, +miceadds::ma.wtd.meanNA

+

survey::svyvar, +Hmisc::wtd.var, +miceadds::ma.wtd.sdNA, +miceadds::ma.wtd.covNA

+
-# split descriptives by number of books -res2 <- BIFIEsurvey::BIFIE.univar( bdat1, vars=c("ASMMAT","ASSSCI"), group="books") -# Note that if group_values is not specified as an argument it will be -# automatically determined by the observed frequencies in the dataset -summary(res2) +
+

Examples

+
#############################################################################
+# EXAMPLE 1: Imputed TIMSS dataset
+#############################################################################
+
+data(data.timss1)
+data(data.timssrep)
+
+# create BIFIE.dat object
+bdat <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
+           wgtrep=data.timssrep[, -1 ] )
+
+# compute descriptives for plausible values
+res1 <- BIFIEsurvey::BIFIE.univar( bdat, vars=c("ASMMAT","ASSSCI","books") )
+summary(res1)
+
+# split descriptives by number of books
+res2 <- BIFIEsurvey::BIFIE.univar( bdat, vars=c("ASMMAT","ASSSCI"), group="books",
+            group_values=1:5)
+summary(res2)
+
+#############################################################################
+# EXAMPLE 2: TIMSS dataset with missings
+#############################################################################
+
+data(data.timss2)
+data(data.timssrep)
+
+# use first dataset with missing data from data.timss2
+bdat1 <- BIFIEsurvey::BIFIE.data( data.list=data.timss2[[1]], wgt=data.timss2[[1]]$TOTWGT,
+               wgtrep=data.timssrep[, -1 ])
+
+# some descriptive statistics without statistical inference
+res1a <- BIFIEsurvey::BIFIE.univar( bdat1, vars=c("ASMMAT","ASSSCI","books"), se=FALSE)
+# descriptive statistics with statistical inference
+res1b <- BIFIEsurvey::BIFIE.univar( bdat1, vars=c("ASMMAT","ASSSCI","books") )
+summary(res1a)
+summary(res1b)
+
+# split descriptives by number of books
+res2 <- BIFIEsurvey::BIFIE.univar( bdat1, vars=c("ASMMAT","ASSSCI"), group="books")
+# Note that if group_values is not specified as an argument it will be
+# automatically determined by the observed frequencies in the dataset
+summary(res2)
+
+
-
- +
- - + + diff --git a/docs/reference/BIFIE.univar.test.html b/docs/reference/BIFIE.univar.test.html index 05191db..1882106 100644 --- a/docs/reference/BIFIE.univar.test.html +++ b/docs/reference/BIFIE.univar.test.html @@ -1,69 +1,14 @@ - - - - - - - -Analysis of Variance and Effect Sizes for Univariate Statistics — BIFIE.univar.test • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Analysis of Variance and Effect Sizes for Univariate Statistics — BIFIE.univar.test • BIFIEsurvey - - - - - - - - - - - - - + + -
-
- -
- -
+
-
BIFIE.univar.test(BIFIE.method, wald_test=TRUE)
-
-# S3 method for BIFIE.univar.test
-summary(object,digits=4,...)
- -

Arguments

- - - - - - - - - - - - - - - - - - - - - - -
BIFIE.method

Object of class BIFIE.univar

wald_test

Optional logical indicating whether a Wald test should - be performed.

object

Object of class BIFIE.univar.test

digits

Number of digits for rounding output

...

Further arguments to be passed

- -

Value

- -

A list with following entries

-
stat.F

Data frame with \(F\) statistic for Wald test

-
stat.eta

Data frame with \(\eta\) effect size and its inference

-
stat.dstat

Data frame with Cohen's \(d\) effect size and its inference

-
...

More values

- -

See also

- - - -

Examples

-
#############################################################################
-# EXAMPLE 1: Imputed TIMSS dataset - One grouping variable
-#############################################################################
+    
+
BIFIE.univar.test(BIFIE.method, wald_test=TRUE)
+
+# S3 method for BIFIE.univar.test
+summary(object,digits=4,...)
+
-data(data.timss1) -data(data.timssrep) +
+

Arguments

+
BIFIE.method
+

Object of class BIFIE.univar

-# create BIFIE.dat object -bdat <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT, - wgtrep=data.timssrep[, -1 ] ) +
wald_test
+

Optional logical indicating whether a Wald test should + be performed.

-#**** Model 1: 3 variables splitted by book -res1 <- BIFIEsurvey::BIFIE.univar( bdat, vars=c("ASMMAT", "ASSSCI","scsci"), - group="books") -summary(res1) -# analysis of variance -tres1 <- BIFIEsurvey::BIFIE.univar.test(res1) -summary(tres1) +
object
+

Object of class BIFIE.univar.test

-#**** Model 2: One variable splitted by gender -res2 <- BIFIEsurvey::BIFIE.univar( bdat, vars=c("ASMMAT"), group="female" ) -summary(res2) -# analysis of variance -tres2 <- BIFIEsurvey::BIFIE.univar.test(res2) -summary(tres2) +
digits
+

Number of digits for rounding output

-if (FALSE) { -#**** Model 3: Univariate statistic: math -res3 <- BIFIEsurvey::BIFIE.univar( bdat, vars=c("ASMMAT") ) -summary(res3) -tres3 <- BIFIEsurvey::BIFIE.univar.test(res3) +
...
+

Further arguments to be passed

-############################################################################# -# EXAMPLE 2: Imputed TIMSS dataset - Two grouping variables -############################################################################# +
+
+

Value

+ -data(data.timss1) -data(data.timssrep) +

A list with following entries

+
stat.F
+

Data frame with \(F\) statistic for Wald test

-# create BIFIE.dat object -bdat <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT, - wgtrep=data.timssrep[, -1 ] ) +
stat.eta
+

Data frame with \(\eta\) effect size and its inference

-#**** Model 1: 3 variables splitted by book and female -res1 <- BIFIEsurvey::BIFIE.univar(bdat, vars=c("ASMMAT", "ASSSCI","scsci"), - group=c("books","female")) -summary(res1) +
stat.dstat
+

Data frame with Cohen's \(d\) effect size and its inference

-# analysis of variance -tres1 <- BIFIEsurvey::BIFIE.univar.test(res1) -summary(tres1) +
...
+

More values

-# extract data frame with Cohens d statistic -dstat <- tres1$stat.dstat +
+
+

See also

+ +
-# extract d values for gender comparisons with same value of books -# -> 'books' refers to the first variable -ind <- which( - unlist( lapply( strsplit( dstat$groupval1, "#"), FUN=function(vv){vv[1]}) )== - unlist( lapply( strsplit( dstat$groupval2, "#"), FUN=function(vv){vv[1]}) ) - ) -dstat[ ind, ] -}
+
+

Examples

+
#############################################################################
+# EXAMPLE 1: Imputed TIMSS dataset - One grouping variable
+#############################################################################
+
+data(data.timss1)
+data(data.timssrep)
+
+# create BIFIE.dat object
+bdat <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
+           wgtrep=data.timssrep[, -1 ] )
+
+#**** Model 1: 3 variables splitted by book
+res1 <- BIFIEsurvey::BIFIE.univar( bdat, vars=c("ASMMAT", "ASSSCI","scsci"),
+                    group="books")
+summary(res1)
+# analysis of variance
+tres1 <- BIFIEsurvey::BIFIE.univar.test(res1)
+summary(tres1)
+
+#**** Model 2: One variable splitted by gender
+res2 <- BIFIEsurvey::BIFIE.univar( bdat, vars=c("ASMMAT"), group="female" )
+summary(res2)
+# analysis of variance
+tres2 <- BIFIEsurvey::BIFIE.univar.test(res2)
+summary(tres2)
+
+if (FALSE) {
+#**** Model 3: Univariate statistic: math
+res3 <- BIFIEsurvey::BIFIE.univar( bdat, vars=c("ASMMAT") )
+summary(res3)
+tres3 <- BIFIEsurvey::BIFIE.univar.test(res3)
+
+#############################################################################
+# EXAMPLE 2: Imputed TIMSS dataset - Two grouping variables
+#############################################################################
+
+data(data.timss1)
+data(data.timssrep)
+
+# create BIFIE.dat object
+bdat <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
+                  wgtrep=data.timssrep[, -1 ] )
+
+#**** Model 1: 3 variables splitted by book and female
+res1 <- BIFIEsurvey::BIFIE.univar(bdat, vars=c("ASMMAT", "ASSSCI","scsci"),
+                  group=c("books","female"))
+summary(res1)
+
+# analysis of variance
+tres1 <- BIFIEsurvey::BIFIE.univar.test(res1)
+summary(tres1)
+
+# extract data frame with Cohens d statistic
+dstat <- tres1$stat.dstat
+
+# extract d values for gender comparisons with same value of books
+# -> 'books' refers to the first variable
+ind <- which(
+  unlist( lapply( strsplit( dstat$groupval1, "#"), FUN=function(vv){vv[1]}) )==
+  unlist( lapply( strsplit( dstat$groupval2, "#"), FUN=function(vv){vv[1]}) )
+        )
+dstat[ ind, ]
+}
+
+
-
- +
- - + + diff --git a/docs/reference/BIFIE.waldtest.html b/docs/reference/BIFIE.waldtest.html index fea37f1..6fed627 100644 --- a/docs/reference/BIFIE.waldtest.html +++ b/docs/reference/BIFIE.waldtest.html @@ -1,70 +1,15 @@ - - - - - - - -Wald Tests for BIFIE Methods — BIFIE.waldtest • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Wald Tests for BIFIE Methods — BIFIE.waldtest • BIFIEsurvey - - - - - - - - - - - - - + + -
-
- -
- -
+
+
+

Details

The Wald test is conducted for a parameter vector \(\bold{\theta}\), specifying the hypothesis \(C \bold{\theta}=r\). Statistical inference is performed by using the \(D_1\) and the \(D_2\) statistic (Enders, 2010, Ch. 8).

For objects of class bifie.univar, only hypotheses with respect to means are implemented.

-

Value

+
+
+

Value

+ -

A list with following entries

-
stat.D

Data frame with \(D_1\) and \(D_2\) statistic, degrees of freedom +

A list with following entries

+
stat.D
+

Data frame with \(D_1\) and \(D_2\) statistic, degrees of freedom and p value

-
...

More values

-

References

+
...
+

More values

+
+
+

References

Enders, C. K. (2010). Applied missing data analysis. Guilford Press.

-

See also

- - - -

Examples

-
#############################################################################
-# EXAMPLE 1: Imputed TIMSS dataset
-#############################################################################
-
-data(data.timss1)
-data(data.timssrep)
-
-# create BIFIE.dat object
-bdat <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
-           wgtrep=data.timssrep[, -1 ] )
-
-#******************
-#*** Model 1: Linear regression
-res1 <- BIFIEsurvey::BIFIE.linreg( bdat, dep="ASMMAT", pre=c("one","books","migrant"),
-         group="female" )
-summary(res1)
-
-#*** Wald test which tests whether sigma and R^2 values are the same
-res1$parnames    # parameter names
-pn <- res1$parnames ; PN <- length(pn)
-Cdes <- matrix(0,nrow=2, ncol=PN)
-colnames(Cdes) <- pn
-# equality of R^2  ( R^2(female0) - R^2(female1)=0 )
-Cdes[ 1, c("R^2_NA_female_0", "R^2_NA_female_1" ) ] <- c(1,-1)
-# equality of sigma ( sigma(female0) - sigma(female1)=0)
-Cdes[ 2, c("sigma_NA_female_0", "sigma_NA_female_1" ) ] <- c(1,-1)
-# design vector
-rdes <- rep(0,2)
-# perform Wald test
-wmod1 <- BIFIEsurvey::BIFIE.waldtest( BIFIE.method=res1, Cdes=Cdes, rdes=rdes )
-summary(wmod1)
-
-if (FALSE) {
-#******************
-#*** Model 2: Correlations
-
-# compute some correlations
-res2a <- BIFIEsurvey::BIFIE.correl( bdat, vars=c("ASMMAT","ASSSCI","migrant","books"))
-summary(res2a)
-
-# test whether r(MAT,migr)=r(SCI,migr) and r(MAT,books)=r(SCI,books)
-pn <- res2a$parnames; PN <- length(pn)
-Cdes <- matrix( 0, nrow=2, ncol=PN )
-colnames(Cdes) <- pn
-Cdes[ 1, c("ASMMAT_migrant", "ASSSCI_migrant") ] <- c(1,-1)
-Cdes[ 2, c("ASMMAT_books", "ASSSCI_books") ] <- c(1,-1)
-rdes <- rep(0,2)
-# perform Wald test
-wres2a <- BIFIEsurvey::BIFIE.waldtest( res2a, Cdes, rdes )
-summary(wres2a)
-
-#******************
-#*** Model 3: Frequencies
-
-# Number of books splitted by gender
-res3a <- BIFIEsurvey::BIFIE.freq( bdat, vars=c("books"), group="female" )
-summary(res3a)
-
-# test whether book(cat4,female0)+book(cat5,female0)=book(cat4,female1)+book(cat5,female5)
-pn <- res3a$parnames
-PN <- length(pn)
-Cdes <- matrix( 0, nrow=1, ncol=PN )
-colnames(Cdes) <- pn
-Cdes[ 1, c("books_4_female_0", "books_5_female_0",
-    "books_4_female_1", "books_5_female_1" ) ] <- c(1,1,-1,-1)
-rdes <- c(0)
-# Wald test
-wres3a <- BIFIEsurvey::BIFIE.waldtest( res3a, Cdes, rdes )
-summary(wres3a)
-
-#******************
-#*** Model 4: Means
-
-# math and science score splitted by gender
-res4a <- BIFIEsurvey::BIFIE.univar( bdat, vars=c("ASMMAT","ASSSCI"), group="female")
-summary(res4a)
+    
+
+

See also

+

survey::regTermTest, +survey::anova.svyglm, +car::linearHypothesis

+
-# test whether there are significant gender differences in math and science -#=> multivariate ANOVA -pn <- res4a$parnames -PN <- length(pn) -Cdes <- matrix( 0, nrow=2, ncol=PN ) -colnames(Cdes) <- pn -Cdes[ 1, c("ASMMAT_female_0", "ASMMAT_female_1" ) ] <- c(1,-1) -Cdes[ 2, c("ASSSCI_female_0", "ASSSCI_female_1" ) ] <- c(1,-1) -rdes <- rep(0,2) -# Wald test -wres4a <- BIFIEsurvey::BIFIE.waldtest( res4a, Cdes, rdes ) -summary(wres4a) -} +
+

Examples

+
#############################################################################
+# EXAMPLE 1: Imputed TIMSS dataset
+#############################################################################
+
+data(data.timss1)
+data(data.timssrep)
+
+# create BIFIE.dat object
+bdat <- BIFIEsurvey::BIFIE.data( data.list=data.timss1, wgt=data.timss1[[1]]$TOTWGT,
+           wgtrep=data.timssrep[, -1 ] )
+
+#******************
+#*** Model 1: Linear regression
+res1 <- BIFIEsurvey::BIFIE.linreg( bdat, dep="ASMMAT", pre=c("one","books","migrant"),
+         group="female" )
+summary(res1)
+
+#*** Wald test which tests whether sigma and R^2 values are the same
+res1$parnames    # parameter names
+pn <- res1$parnames ; PN <- length(pn)
+Cdes <- matrix(0,nrow=2, ncol=PN)
+colnames(Cdes) <- pn
+# equality of R^2  ( R^2(female0) - R^2(female1)=0 )
+Cdes[ 1, c("R^2_NA_female_0", "R^2_NA_female_1" ) ] <- c(1,-1)
+# equality of sigma ( sigma(female0) - sigma(female1)=0)
+Cdes[ 2, c("sigma_NA_female_0", "sigma_NA_female_1" ) ] <- c(1,-1)
+# design vector
+rdes <- rep(0,2)
+# perform Wald test
+wmod1 <- BIFIEsurvey::BIFIE.waldtest( BIFIE.method=res1, Cdes=Cdes, rdes=rdes )
+summary(wmod1)
+
+if (FALSE) {
+#******************
+#*** Model 2: Correlations
+
+# compute some correlations
+res2a <- BIFIEsurvey::BIFIE.correl( bdat, vars=c("ASMMAT","ASSSCI","migrant","books"))
+summary(res2a)
+
+# test whether r(MAT,migr)=r(SCI,migr) and r(MAT,books)=r(SCI,books)
+pn <- res2a$parnames; PN <- length(pn)
+Cdes <- matrix( 0, nrow=2, ncol=PN )
+colnames(Cdes) <- pn
+Cdes[ 1, c("ASMMAT_migrant", "ASSSCI_migrant") ] <- c(1,-1)
+Cdes[ 2, c("ASMMAT_books", "ASSSCI_books") ] <- c(1,-1)
+rdes <- rep(0,2)
+# perform Wald test
+wres2a <- BIFIEsurvey::BIFIE.waldtest( res2a, Cdes, rdes )
+summary(wres2a)
+
+#******************
+#*** Model 3: Frequencies
+
+# Number of books splitted by gender
+res3a <- BIFIEsurvey::BIFIE.freq( bdat, vars=c("books"), group="female" )
+summary(res3a)
+
+# test whether book(cat4,female0)+book(cat5,female0)=book(cat4,female1)+book(cat5,female5)
+pn <- res3a$parnames
+PN <- length(pn)
+Cdes <- matrix( 0, nrow=1, ncol=PN )
+colnames(Cdes) <- pn
+Cdes[ 1, c("books_4_female_0", "books_5_female_0",
+    "books_4_female_1", "books_5_female_1" ) ] <- c(1,1,-1,-1)
+rdes <- c(0)
+# Wald test
+wres3a <- BIFIEsurvey::BIFIE.waldtest( res3a, Cdes, rdes )
+summary(wres3a)
+
+#******************
+#*** Model 4: Means
+
+# math and science score splitted by gender
+res4a <- BIFIEsurvey::BIFIE.univar( bdat, vars=c("ASMMAT","ASSSCI"), group="female")
+summary(res4a)
+
+# test whether there are significant gender differences in math and science
+#=> multivariate ANOVA
+pn <- res4a$parnames
+PN <- length(pn)
+Cdes <- matrix( 0, nrow=2, ncol=PN )
+colnames(Cdes) <- pn
+Cdes[ 1, c("ASMMAT_female_0", "ASMMAT_female_1"  ) ] <- c(1,-1)
+Cdes[ 2, c("ASSSCI_female_0", "ASSSCI_female_1"  ) ] <- c(1,-1)
+rdes <- rep(0,2)
+# Wald test
+wres4a <- BIFIEsurvey::BIFIE.waldtest( res4a, Cdes, rdes )
+summary(wres4a)
+}
+
+
-
- +
- - + + diff --git a/docs/reference/BIFIEdata2svrepdesign.html b/docs/reference/BIFIEdata2svrepdesign.html index 0bf5dd8..ddf04ef 100644 --- a/docs/reference/BIFIEdata2svrepdesign.html +++ b/docs/reference/BIFIEdata2svrepdesign.html @@ -1,72 +1,17 @@ - - - - - - - -Conversion of a <code>BIFIEdata</code> Object into a <code>svyrep</code> Object in the -<span class="pkg">survey</span> Package (and the other way around) — BIFIEdata2svrepdesign • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -survey Package (and the other way around) — BIFIEdata2svrepdesign" /> -Conversion of a BIFIEdata Object into a svyrep Object in the +survey Package (and the other way around) — BIFIEdata2svrepdesign • BIFIEsurvey - - - - - - - - - - - - - + + -
-
- -
- -
+
-
BIFIEdata2svrepdesign(bifieobj, varnames=NULL, impdata.index=NULL)
-
-svrepdesign2BIFIEdata(svrepdesign, varnames=NULL, cdata=FALSE)
- -

Arguments

- - - - - - - - - - - - - - - - - - - - - - -
bifieobj

Object of class BIFIEdata

varnames

Optional vector with variable names

impdata.index

Selected indices of imputed datasets

svrepdesign

Object of class svyrep.design or svyimputationList

cdata

Logical inducating whether BIFIEdata object should be -saved in compact format

- -

Value

- -

Function BIFIEdata2svrepdesign: -Object of class svyrep.design or svyimputationList

-

Function svrepdesign2BIFIEdata: Object of class BIFIEdata

-

See also

- -

See the BIFIE.data function for creating objects of class -BIFIEdata in BIFIEsurvey.

-

See the survey::svrepdesign function in -the survey package.

- -

Examples

-
if (FALSE) {
-#############################################################################
-# EXAMPLE 1: One dataset, TIMSS replication design
-#############################################################################
-
-data(data.timss3)
-data(data.timssrep)
-
-#--- create BIFIEdata object
-bdat3 <- BIFIEsurvey::BIFIE.data.jack(data.timss3, jktype="JK_TIMSS")
-summary(bdat3)
+    
+
BIFIEdata2svrepdesign(bifieobj, varnames=NULL, impdata.index=NULL)
+
+svrepdesign2BIFIEdata(svrepdesign, varnames=NULL, cdata=FALSE)
+
-#--- create survey object directly in survey package -dat3a <- as.data.frame( cbind( data.timss3, data.timssrep ) ) -RR <- ncol(data.timssrep) - 1 # number of jackknife zones -svydes3a <- survey::svrepdesign(data=dat3a, weights=~TOTWGT,type="JKn", - repweights='w_fstr[0-9]', scale=1, rscales=rep(1,RR), mse=TRUE ) -print(svydes3a) +
+

Arguments

+
bifieobj
+

Object of class BIFIEdata

-#--- create survey object by converting the BIFIEdata object to survey -svydes3b <- BIFIEsurvey::BIFIEdata2svrepdesign(bdat3) +
varnames
+

Optional vector with variable names

-#--- convert survey object into BIFIEdata object -bdat3e <- BIFIEsurvey::svrepdesign2BIFIEdata(svrepdesign=svydes3b) +
impdata.index
+

Selected indices of imputed datasets

-#*** compare results for the mean in Mathematics scores -mod1a <- BIFIEsurvey::BIFIE.univar( bdat3, vars="ASMMAT1") -mod1b <- survey::svymean( ~ ASMMAT1, design=svydes3a ) -mod1c <- survey::svymean( ~ ASMMAT1, design=svydes3b ) -lavmodel <- "ASMMAT1 ~ 1" -mod1d <- BIFIEsurvey::BIFIE.lavaan.survey(lavmodel, svyrepdes=svydes3b) +
svrepdesign
+

Object of class svyrep.design or svyimputationList

-#- coefficients -coef(mod1a); coef(mod1b); coef(mod1c); coef(mod1d)[1] -#- standard errors -survey::SE(mod1a); survey::SE(mod1b); survey::SE(mod1c); sqrt(vcov(mod1d)[1,1]) +
cdata
+

Logical inducating whether BIFIEdata object should be +saved in compact format

-############################################################################# -# EXAMPLE 2: Multiply imputed datasets, TIMSS replication design -############################################################################# +
+
+

Value

+ -data(data.timss2) -data(data.timssrep) +

Function BIFIEdata2svrepdesign: +Object of class svyrep.design or svyimputationList

+

+


-#--- create BIFIEdata object -bdat4 <- BIFIEsurvey::BIFIE.data( data=data.timss2, wgt="TOTWGT", - wgtrep=data.timssrep[,-1], fayfac=1) -print(bdat4) -#--- create object with imputed datasets in survey -datL <- mitools::imputationList( data.timss2 ) -RR <- ncol(data.timssrep) - 1 -weights <- data.timss2[[1]]$TOTWGT -repweights <- data.timssrep[,-1] -svydes4a <- survey::svrepdesign(data=datL, weights=weights, type="other", - repweights=repweights, scale=1, rscales=rep(1,RR), mse=TRUE) -print(svydes4a) -#--- create BIFIEdata object with conversion function -svydes4b <- BIFIEsurvey::BIFIEdata2svrepdesign(bdat4) +

Function svrepdesign2BIFIEdata: Object of class BIFIEdata

-#--- reconvert survey object into BIFIEdata object -bdat4c <- BIFIEsurvey::svrepdesign2BIFIEdata(svrepdesign=svydes4b) -#*** compare results for a mean -mod1a <- BIFIEsurvey::BIFIE.univar(bdat4, vars="ASMMAT") -mod1b <- mitools::MIcombine( with(svydes4a, survey::svymean( ~ ASMMAT, design=svydes4a ))) -mod1c <- mitools::MIcombine( with(svydes4b, survey::svymean( ~ ASMMAT, design=svydes4b ))) +
+
+

See also

+

See the BIFIE.data function for creating objects of class +BIFIEdata in BIFIEsurvey.

+

See the survey::svrepdesign function in +the survey package.

+
-# results -coef(mod1a); coef(mod1b); coef(mod1c) -survey::SE(mod1a); survey::SE(mod1b); survey::SE(mod1c) -}
+
+

Examples

+
if (FALSE) {
+#############################################################################
+# EXAMPLE 1: One dataset, TIMSS replication design
+#############################################################################
+
+data(data.timss3)
+data(data.timssrep)
+
+#--- create BIFIEdata object
+bdat3 <- BIFIEsurvey::BIFIE.data.jack(data.timss3, jktype="JK_TIMSS")
+summary(bdat3)
+
+#--- create survey object directly in survey package
+dat3a <- as.data.frame( cbind( data.timss3, data.timssrep ) )
+RR <- ncol(data.timssrep) - 1       # number of jackknife zones
+svydes3a <- survey::svrepdesign(data=dat3a, weights=~TOTWGT,type="JKn",
+                 repweights='w_fstr[0-9]', scale=1,  rscales=rep(1,RR), mse=TRUE )
+print(svydes3a)
+
+#--- create survey object by converting the BIFIEdata object to survey
+svydes3b <- BIFIEsurvey::BIFIEdata2svrepdesign(bdat3)
+
+#--- convert survey object into BIFIEdata object
+bdat3e <- BIFIEsurvey::svrepdesign2BIFIEdata(svrepdesign=svydes3b)
+
+#*** compare results for the mean in Mathematics scores
+mod1a <- BIFIEsurvey::BIFIE.univar( bdat3, vars="ASMMAT1")
+mod1b <- survey::svymean( ~ ASMMAT1, design=svydes3a )
+mod1c <- survey::svymean( ~ ASMMAT1, design=svydes3b )
+lavmodel <- "ASMMAT1 ~ 1"
+mod1d <- BIFIEsurvey::BIFIE.lavaan.survey(lavmodel, svyrepdes=svydes3b)
+
+#- coefficients
+coef(mod1a); coef(mod1b); coef(mod1c); coef(mod1d)[1]
+#- standard errors
+survey::SE(mod1a); survey::SE(mod1b); survey::SE(mod1c); sqrt(vcov(mod1d)[1,1])
+
+#############################################################################
+# EXAMPLE 2: Multiply imputed datasets, TIMSS replication design
+#############################################################################
+
+data(data.timss2)
+data(data.timssrep)
+
+#--- create BIFIEdata object
+bdat4 <- BIFIEsurvey::BIFIE.data( data=data.timss2, wgt="TOTWGT",
+              wgtrep=data.timssrep[,-1], fayfac=1)
+print(bdat4)
+
+#--- create object with imputed datasets in survey
+datL <- mitools::imputationList( data.timss2 )
+RR <- ncol(data.timssrep) - 1
+weights <- data.timss2[[1]]$TOTWGT
+repweights <-  data.timssrep[,-1]
+svydes4a <- survey::svrepdesign(data=datL, weights=weights, type="other",
+               repweights=repweights, scale=1,  rscales=rep(1,RR), mse=TRUE)
+print(svydes4a)
+
+#--- create BIFIEdata object with conversion function
+svydes4b <- BIFIEsurvey::BIFIEdata2svrepdesign(bdat4)
+
+#--- reconvert survey object into BIFIEdata object
+bdat4c <- BIFIEsurvey::svrepdesign2BIFIEdata(svrepdesign=svydes4b)
+
+#*** compare results for a mean
+mod1a <- BIFIEsurvey::BIFIE.univar(bdat4, vars="ASMMAT")
+mod1b <- mitools::MIcombine( with(svydes4a, survey::svymean( ~ ASMMAT, design=svydes4a )))
+mod1c <- mitools::MIcombine( with(svydes4b, survey::svymean( ~ ASMMAT, design=svydes4b )))
+
+# results
+coef(mod1a); coef(mod1b); coef(mod1c)
+survey::SE(mod1a); survey::SE(mod1b); survey::SE(mod1c)
+}
+
+
-
- +
- - + + diff --git a/docs/reference/BIFIEsurvey-package.html b/docs/reference/BIFIEsurvey-package.html index b093257..7165a8c 100644 --- a/docs/reference/BIFIEsurvey-package.html +++ b/docs/reference/BIFIEsurvey-package.html @@ -1,46 +1,5 @@ - - - - - - - -Tools for Survey Statistics in Educational Assessment — BIFIEsurvey-package • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Tools for Survey Statistics in Educational Assessment — BIFIEsurvey-package • BIFIEsurvey - - - - - - - - - - - - - + + -
-
- -
- -
+
- -

Details

- +
+

Author

+

BIFIE [aut], Alexander Robitzsch [aut, cre], + Konrad Oberwimmer [aut]

+

Maintainer: Alexander Robitzsch <robitzsch@ipn.uni-kiel.de>

+
+
+

Details

The BIFIEsurvey package include basic descriptive functions for large scale assessment data @@ -160,25 +97,22 @@

Details functions in this package were written in Rcpp.

The features of BIFIEsurvey include for designs with replicate weights (which includes Jackknife and Bootstrap as general approaches):

-

+
+

References

Bruneforth, M., Oberwimmer, K., & Robitzsch, A. (2016). Reporting und Analysen. In S. Breit & C. Schreiner (Hrsg.). Large-Scale Assessment mit R: Methodische Grundlagen der oesterreichischen Bildungsstandardueberpruefung (S. 333-362). Wien: facultas.

@@ -196,72 +130,71 @@

R Grundlagen der oesterreichischen Bildungsstandardueberpruefung (S. 259-293). Wien: facultas.

Shao, J. (1996). Invited discussion paper: Resampling methods in sample surveys. Statistics, 27(3-4), 203-237.

-

See also

- -

See also the survey, intsvy, EdSurvey, -lavaan.survey, EVER and +

+
+

See also

+

See also the survey, intsvy, EdSurvey, +lavaan.survey, EVER and the eatRep packages.

+
-

Examples

-
##   |-----------------------------------------------------------------
-##   | BIFIEsurvey 0.1-21 (2014-06-21)
-##   | Maintainer: Alexander Robitzsch <a.robitzsch at bifie.at >
-##   | http://www.bifie.at
-##   |-----------------------------------------------------------------
-
-##   .........................*,::;              :,:;       * .;*;. .,:
-##   :::::::::::::::::::::::::.  ##+@              ##+#       .@####+ ;+# *
-##   :::::::::::::::::::::::::.  ###@              ####       @@;   :*;##**
-##   :::::::::::::::::::::::::.  ###@              ##+#     *##.      .,,
-##   :::::::::::::::::::::::::.  ###@              ::,:    * ##
-##   :::::::::::::::::::::::::.  ###@                 *      @@
-##   :::::::::::::::::::::::::.  ###@                      * #@
-##   :::::::::::::::::::::::::.  ###@                        #@                   *
-##   :::::::::::::::::::::::::.  ##@#,@###@       @@## * @@@+##@@@@   #@     *.@#####
-##   :::::::::::::::::::::::::.  ####*@#####@.**   ####   @@#@@@####   #@     ;##+**#+@*
-##   :::::::::::::::::::::::::.  ##@@##,,#+##@     ####      @@        #@    .#@*  * *##
-##   ::::,::::::::::::::::::::.  ##+@@    ####,    ####      #@        #@    ##,      #+*
-##   ::::**.::::::::::::::::::.  ##+@, **,###@    ####      #@        #@    @@       ;@;
-##   :::::*  .::::::::::::::::.  ##*       ####    ####      #@        #@   .##@@@@@@@#+#
-##   :::::::*   *,,:::::::::::.     :      ###@    ####      #@        #@   ;##@@@@@@@@@@
-##   :::::::::.      **....*    ,@#      ####    ####      #@        #@   *@**
-##   ::::::::::::.*              ####      @###*   ####      #@        #@  *+#*
-##   ::::::::::::::::,,,,,,,::.  ####      ####    ####      #@        #@  **#*
-##   :::::::::::::::::::::::::.  ####      @###    ####      #@        #@ ,##
-##   :::::::::::::::::::::::::.  ###@   *  @##+    ####      #@        #@   *#@
-##   :::::::::::::::::::::::::*  @@##   ,#@##    ####      #@        #@    @#
-##   :::::::::::::::::::::::::*  @+##,    @###*    ####      #@        #@   *+#@
-##   ::::::::::::::::::::::::.    ###@:  *###@     ####      #@        #@     #@+
-##   :::::::::::::::::::::::.   **;@#@#@####@.     ####      #@        #@     *@#@:*   *
-##   ::::::::::::::::::::::.     ,@######@.      ####*     ##        @+      *#####@##
-##   ::::::::::::::::::::.*        * .*##*. *        ***     *.        **         ;##+;.
-
-
+
+

Examples

+
##   |-----------------------------------------------------------------
+##   | BIFIEsurvey 0.1-21 (2014-06-21)
+##   | Maintainer: Alexander Robitzsch <a.robitzsch at bifie.at >
+##   | http://www.bifie.at
+##   |-----------------------------------------------------------------
+
+##   .........................*,::;              :,:;       * .;*;. .,:
+##   :::::::::::::::::::::::::.  ##+@              ##+#       .@####+ ;+# *
+##   :::::::::::::::::::::::::.  ###@              ####       @@;   :*;##**
+##   :::::::::::::::::::::::::.  ###@              ##+#     *##.      .,,
+##   :::::::::::::::::::::::::.  ###@              ::,:    * ##
+##   :::::::::::::::::::::::::.  ###@                 *      @@
+##   :::::::::::::::::::::::::.  ###@                      * #@
+##   :::::::::::::::::::::::::.  ###@                        #@                   *
+##   :::::::::::::::::::::::::.  ##@#,@###@       @@## * @@@+##@@@@   #@     *.@#####
+##   :::::::::::::::::::::::::.  ####*@#####@.**   ####   @@#@@@####   #@     ;##+**#+@*
+##   :::::::::::::::::::::::::.  ##@@##,,#+##@     ####      @@        #@    .#@*  * *##
+##   ::::,::::::::::::::::::::.  ##+@@    ####,    ####      #@        #@    ##,      #+*
+##   ::::**.::::::::::::::::::.  ##+@, **,###@    ####      #@        #@    @@       ;@;
+##   :::::*  .::::::::::::::::.  ##*       ####    ####      #@        #@   .##@@@@@@@#+#
+##   :::::::*   *,,:::::::::::.     :      ###@    ####      #@        #@   ;##@@@@@@@@@@
+##   :::::::::.      **....*    ,@#      ####    ####      #@        #@   *@**
+##   ::::::::::::.*              ####      @###*   ####      #@        #@  *+#*
+##   ::::::::::::::::,,,,,,,::.  ####      ####    ####      #@        #@  **#*
+##   :::::::::::::::::::::::::.  ####      @###    ####      #@        #@ ,##
+##   :::::::::::::::::::::::::.  ###@   *  @##+    ####      #@        #@   *#@
+##   :::::::::::::::::::::::::*  @@##   ,#@##    ####      #@        #@    @#
+##   :::::::::::::::::::::::::*  @+##,    @###*    ####      #@        #@   *+#@
+##   ::::::::::::::::::::::::.    ###@:  *###@     ####      #@        #@     #@+
+##   :::::::::::::::::::::::.   **;@#@#@####@.     ####      #@        #@     *@#@:*   *
+##   ::::::::::::::::::::::.     ,@######@.      ####*     ##        @+      *#####@##
+##   ::::::::::::::::::::.*        * .*##*. *        ***     *.        **         ;##+;.
+
+
+
-
- +
- - + + diff --git a/docs/reference/BIFIEsurvey-utilities.html b/docs/reference/BIFIEsurvey-utilities.html index e107bab..a4035e4 100644 --- a/docs/reference/BIFIEsurvey-utilities.html +++ b/docs/reference/BIFIEsurvey-utilities.html @@ -1,67 +1,12 @@ - - - - - - - -Utility Functions in <span class="pkg">BIFIEsurvey</span> — BIFIEsurvey-utilities • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -BIFIEsurvey — BIFIEsurvey-utilities" /> - - - - - - - - - -Utility Functions in BIFIEsurvey — BIFIEsurvey-utilities • BIFIEsurvey - - - - + + -
-
- -
- -
+
-
## Rubin rules for combining multiple imputation estimates
-bifiesurvey_rcpp_rubin_rules(estimates, variances)
-
-## computation of replication variance
-bifiesurvey_rcpp_replication_variance(pars, pars_repl, fay_factor)
-
-## statistical inference for nested multiple imputation
-BIFIE_NMI_inference_parameters( parsM, parsrepM, fayfac, RR, Nimp, Nimp_NMI,
-      comp_cov=FALSE)
- -

Arguments

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
estimates

Vector

variances

Vector

pars

Matrix

pars_repl

Matrix

fay_factor

Vector

parsM

Matrix

parsrepM

Matrix

fayfac

Vector

RR

Numeric

Nimp

Integer

Nimp_NMI

Integer

comp_cov

Logical

+
+
## Rubin rules for combining multiple imputation estimates
+bifiesurvey_rcpp_rubin_rules(estimates, variances)
+
+## computation of replication variance
+bifiesurvey_rcpp_replication_variance(pars, pars_repl, fay_factor)
+
+## statistical inference for nested multiple imputation
+BIFIE_NMI_inference_parameters( parsM, parsrepM, fayfac, RR, Nimp, Nimp_NMI,
+      comp_cov=FALSE)
+
+ +
+

Arguments

+
estimates
+

Vector

+ +
variances
+

Vector

+ +
pars
+

Matrix

+ +
pars_repl
+

Matrix

+
fay_factor
+

Vector

+ +
parsM
+

Matrix

+ +
parsrepM
+

Matrix

+ +
fayfac
+

Vector

+ +
RR
+

Numeric

+ +
Nimp
+

Integer

+ +
Nimp_NMI
+

Integer

+ +
comp_cov
+

Logical

+ +
+
-
- +
- - + + diff --git a/docs/reference/bifietable.html b/docs/reference/bifietable.html index b7608be..03e65ac 100644 --- a/docs/reference/bifietable.html +++ b/docs/reference/bifietable.html @@ -1,68 +1,13 @@ - - - - - - - -An <span class="pkg">Rcpp</span> Based Version of the <code>table</code> Function — bifietable • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Rcpp Based Version of the table Function — bifietable" /> - - - - - - - - - -An Rcpp Based Version of the table Function — bifietable • BIFIEsurvey - - - - + + -
-
- -
- -
+
+
-
- +
- - + + diff --git a/docs/reference/data.bifie.html b/docs/reference/data.bifie.html index d55aa43..ee37a81 100644 --- a/docs/reference/data.bifie.html +++ b/docs/reference/data.bifie.html @@ -1,67 +1,12 @@ - - - - - - - -Example Datasets for the <span class="pkg">BIFIEsurvey</span> Package — data.bifie • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -BIFIEsurvey Package — data.bifie" /> - - - - - - - - - -Example Datasets for the BIFIEsurvey Package — data.bifie • BIFIEsurvey - - - - + + -
-
- -
- -
+
-
data(data.bifie01)
- - -

Format

+
+
data(data.bifie01)
+
+
+

Format

-
    -
  • The dataset data.bifie01 contains data of 4th Grade Austrian +

    • The dataset data.bifie01 contains data of 4th Grade Austrian students from the TIMSS 2011 study.

    • -
    - +
+
-
- +
- - + + diff --git a/docs/reference/data.pisaNLD.html b/docs/reference/data.pisaNLD.html index db9899b..eeb62e9 100644 --- a/docs/reference/data.pisaNLD.html +++ b/docs/reference/data.pisaNLD.html @@ -1,67 +1,12 @@ - - - - - - - -Some PISA Datasets — data.pisaNLD • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Some PISA Datasets — data.pisaNLD • BIFIEsurvey - - - - + + -
-
- -
- -
+
-
data(data.pisaNLD)
- - -

Format

+
+
data(data.pisaNLD)
+
+
+

Format

The dataset data.pisaNLD is a data frame with 3992 observations on 405 variables which is a part of the Dutch PISA 2006 data.

-

Source

- -

Downloaded from doi: 10.18637/jss.v020.i05 +

+
+

Source

+

Downloaded from doi:10.18637/jss.v020.i05 (Fox, 2007).

-

References

- +
+
+

References

Fox, J.-P. (2007). Multilevel IRT Modeling in practice with the package mlirt. -Journal of Statistical Software, 20(5), 1-16. doi: 10.18637/jss.v020.i05

- -

Examples

-
if (FALSE) {
-library(mitools)
-library(survey)
-library(intsvy)
-
-#############################################################################
-# EXAMPLE 1: Dutch PISA 2006 dataset
-#############################################################################
-
-data(data.pisaNLD)
-data <- data.pisaNLD
-
-#--- Create object of class BIFIEdata
-
-# list variables with plausible values: These must be named
-# as pv1math, pv2math, ..., pv5math, ...
-pv_vars <- toupper( c("math", "math1", "math2", "math3", "math4",
-             "read", "scie", "prob") )
-# create 5 datasets including different sets of plausible values
-dfr <- NULL
-VV <- length(pv_vars)
-Nimp <- 5           # number of plausible values
-for (vv in 1:VV){
-      vv1 <- pv_vars[vv]
-      ind.vv1 <- which( colnames(data) %in% paste0("PV", 1:Nimp, vv1) )
-      dfr2 <- data.frame( "variable"=paste0("PV", vv1), "var_index"=vv,
-          "data_index"=ind.vv1, "impdata_index"=1:Nimp )
-      dfr <- rbind( dfr, dfr2 )
-}
-
-sel_ind <- setdiff( 1:( ncol(data) ), dfr$data_index )
-data0 <- data[, sel_ind ]
-V0 <- ncol(data0)
-newvars <- seq( V0+1, V0+VV )
-datalist <- as.list( 1:Nimp )
-for (ii in 1:Nimp ){
-    dat1 <- data.frame( data0, data[, dfr[ dfr$impdata_index==ii, "data_index" ]])
-    colnames(dat1)[ newvars ] <- paste0("PV",pv_vars)
-    datalist[[ii]] <- dat1
-}
-
-# dataset with replicate weights
-datarep <- data[, grep( "W_FSTR", colnames(data) ) ]
-RR <- ncol(datarep)     # number of replicate weights
-
-# create BIFIE object
-bifieobj <- BIFIEsurvey::BIFIE.data( datalist, wgt=data[, "W_FSTUWT"],
-                 wgtrep=datarep, fayfac=1 / RR / ( 1 - .5 )^2 )
-# For PISA: RR=80 and therefore fayfac=1/20=.05
-summary(bifieobj)
-
-#--- Create BIFIEdata object immediately using BIFIE.data.jack function
-bifieobj1 <- BIFIEsurvey::BIFIE.data.jack( data.pisaNLD, jktype="RW_PISA", cdata=TRUE)
-summary(bifieobj1)
-
-#--- Create object in survey package
-datL <- mitools::imputationList(list( datalist[[1]],datalist[[2]],
-                  datalist[[3]],datalist[[4]],datalist[[5]]) )
-pisades <- survey::svrepdesign(ids=~ 1, weights=~W_FSTUWT, data=datL,
-                    repweights="W_FSTR[0-9]+", type="Fay", rho=0.5, mse=TRUE)
-print(pisades)
-
-#++++++++++++++ some comparisons with other packages +++++++++++++++++++++++++++++++
-
-#**** Model 1: Means for mathematics and reading
-# BIFIEsurvey package
-mod1a <- BIFIEsurvey::BIFIE.univar( bifieobj, vars=c("PVMATH", "PVREAD") )
-summary(mod1a)
-
-# intsvy package
-mod1b <- intsvy::pisa.mean.pv(pvlabel="MATH", data=data.pisaNLD )
-mod1b
-
-# survey package
-mod1c <- with( pisades, survey::svymean(PVMATH~1, design=pisades) )
-res1c <- mitools::MIcombine(mod1c)
-summary(res1c)
-
-#**** Model 2: Linear regression
-# BIFIEsurvey package
-mod2a <- BIFIEsurvey::BIFIE.linreg( bifieobj, dep="PVMATH",
-              pre=c("one","ANXMAT","HISEI"))
-summary(mod2a)
-
-# intsvy package
-mod2b <- intsvy::pisa.reg.pv(pvlabel="MATH", x=c("ANXMAT","HISEI"), data=data.pisaNLD)
-mod2b
+Journal of Statistical Software, 20(5), 1-16. doi:10.18637/jss.v020.i05

+
-# survey package -mod2c <- with( pisades, survey::svyglm(PVMATH~ANXMAT+HISEI, design=pisades) ) -res2c <- mitools::MIcombine(mod2c) -summary(res2c) -} +
+

Examples

+
if (FALSE) {
+library(mitools)
+library(survey)
+library(intsvy)
+
+#############################################################################
+# EXAMPLE 1: Dutch PISA 2006 dataset
+#############################################################################
+
+data(data.pisaNLD)
+data <- data.pisaNLD
+
+#--- Create object of class BIFIEdata
+
+# list variables with plausible values: These must be named
+# as pv1math, pv2math, ..., pv5math, ...
+pv_vars <- toupper( c("math", "math1", "math2", "math3", "math4",
+             "read", "scie", "prob") )
+# create 5 datasets including different sets of plausible values
+dfr <- NULL
+VV <- length(pv_vars)
+Nimp <- 5           # number of plausible values
+for (vv in 1:VV){
+      vv1 <- pv_vars[vv]
+      ind.vv1 <- which( colnames(data) %in% paste0("PV", 1:Nimp, vv1) )
+      dfr2 <- data.frame( "variable"=paste0("PV", vv1), "var_index"=vv,
+          "data_index"=ind.vv1, "impdata_index"=1:Nimp )
+      dfr <- rbind( dfr, dfr2 )
+}
+
+sel_ind <- setdiff( 1:( ncol(data) ), dfr$data_index )
+data0 <- data[, sel_ind ]
+V0 <- ncol(data0)
+newvars <- seq( V0+1, V0+VV )
+datalist <- as.list( 1:Nimp )
+for (ii in 1:Nimp ){
+    dat1 <- data.frame( data0, data[, dfr[ dfr$impdata_index==ii, "data_index" ]])
+    colnames(dat1)[ newvars ] <- paste0("PV",pv_vars)
+    datalist[[ii]] <- dat1
+}
+
+# dataset with replicate weights
+datarep <- data[, grep( "W_FSTR", colnames(data) ) ]
+RR <- ncol(datarep)     # number of replicate weights
+
+# create BIFIE object
+bifieobj <- BIFIEsurvey::BIFIE.data( datalist, wgt=data[, "W_FSTUWT"],
+                 wgtrep=datarep, fayfac=1 / RR / ( 1 - .5 )^2 )
+# For PISA: RR=80 and therefore fayfac=1/20=.05
+summary(bifieobj)
+
+#--- Create BIFIEdata object immediately using BIFIE.data.jack function
+bifieobj1 <- BIFIEsurvey::BIFIE.data.jack( data.pisaNLD, jktype="RW_PISA", cdata=TRUE)
+summary(bifieobj1)
+
+#--- Create object in survey package
+datL <- mitools::imputationList(list( datalist[[1]],datalist[[2]],
+                  datalist[[3]],datalist[[4]],datalist[[5]]) )
+pisades <- survey::svrepdesign(ids=~ 1, weights=~W_FSTUWT, data=datL,
+                    repweights="W_FSTR[0-9]+", type="Fay", rho=0.5, mse=TRUE)
+print(pisades)
+
+#++++++++++++++ some comparisons with other packages +++++++++++++++++++++++++++++++
+
+#**** Model 1: Means for mathematics and reading
+# BIFIEsurvey package
+mod1a <- BIFIEsurvey::BIFIE.univar( bifieobj, vars=c("PVMATH", "PVREAD") )
+summary(mod1a)
+
+# intsvy package
+mod1b <- intsvy::pisa.mean.pv(pvlabel="MATH", data=data.pisaNLD )
+mod1b
+
+# survey package
+mod1c <- with( pisades, survey::svymean(PVMATH~1, design=pisades) )
+res1c <- mitools::MIcombine(mod1c)
+summary(res1c)
+
+#**** Model 2: Linear regression
+# BIFIEsurvey package
+mod2a <- BIFIEsurvey::BIFIE.linreg( bifieobj, dep="PVMATH",
+              pre=c("one","ANXMAT","HISEI"))
+summary(mod2a)
+
+# intsvy package
+mod2b <- intsvy::pisa.reg.pv(pvlabel="MATH", x=c("ANXMAT","HISEI"), data=data.pisaNLD)
+mod2b
+
+# survey package
+mod2c <- with( pisades, survey::svyglm(PVMATH~ANXMAT+HISEI, design=pisades) )
+res2c <- mitools::MIcombine(mod2c)
+summary(res2c)
+}
+
+
-
- +
- - + + diff --git a/docs/reference/data.test1.html b/docs/reference/data.test1.html index 8ae065a..e17a5e3 100644 --- a/docs/reference/data.test1.html +++ b/docs/reference/data.test1.html @@ -1,67 +1,12 @@ - - - - - - - -Some Datasets for Testing Purposes — data.test1 • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Some Datasets for Testing Purposes — data.test1 • BIFIEsurvey - - - - + + -
-
- -
- -
+
-
data(data.test1)
- - -

Format

+
+
data(data.test1)
+
+
+

Format

The dataset data.test1 is a dataset with a stratified clustered sample of 2101 students nested within 89 classes and 4 strata. The format is

-

'data.frame': 2101 obs. of 16 variables:
- $ idstud : num 10101 10102 10103 10104 10105 ...
- $ idclass: num 101 101 101 101 101 101 101 101 101 101 ...
- $ math : num 108 107 101 91 157 ...
- $ engl : num 95.2 133.3 94.9 97.6 142.3 ...
- $ germ : num 125 150 107 113 139 ...
- $ stratum: num 1 1 1 1 1 1 1 1 1 1 ...
- $ female : int 1 1 1 1 0 0 0 0 0 0 ...
- $ age : num 14.6 14.3 14.8 14.6 14.5 ...
- $ hisei : int 43 43 43 67 51 30 30 51 68 70 ...
- $ paredu : int 2 2 1 4 5 2 1 5 7 7 ...
- $ books : int 4 2 3 3 5 3 2 4 3 5 ...
- $ satisf : int 5 4 6 7 6 5 7 3 6 6 ...
- $ migrant: int 1 0 0 1 0 0 0 0 0 0 ...
- $ wgtstud: num 20.9 20.9 20.9 20.9 20.9 ...
- $ jkzone : num 101 101 101 101 101 101 101 101 101 101 ...
- $ jkrep : num 0 0 0 0 0 0 0 0 0 0 ...

+

'data.frame': 2101 obs. of 16 variables:
$ idstud : num 10101 10102 10103 10104 10105 ...
$ idclass: num 101 101 101 101 101 101 101 101 101 101 ...
$ math : num 108 107 101 91 157 ...
$ engl : num 95.2 133.3 94.9 97.6 142.3 ...
$ germ : num 125 150 107 113 139 ...
$ stratum: num 1 1 1 1 1 1 1 1 1 1 ...
$ female : int 1 1 1 1 0 0 0 0 0 0 ...
$ age : num 14.6 14.3 14.8 14.6 14.5 ...
$ hisei : int 43 43 43 67 51 30 30 51 68 70 ...
$ paredu : int 2 2 1 4 5 2 1 5 7 7 ...
$ books : int 4 2 3 3 5 3 2 4 3 5 ...
$ satisf : int 5 4 6 7 6 5 7 3 6 6 ...
$ migrant: int 1 0 0 1 0 0 0 0 0 0 ...
$ wgtstud: num 20.9 20.9 20.9 20.9 20.9 ...
$ jkzone : num 101 101 101 101 101 101 101 101 101 101 ...
$ jkrep : num 0 0 0 0 0 0 0 0 0 0 ...

+
+
-
- +
- - + + diff --git a/docs/reference/data.timss1.html b/docs/reference/data.timss1.html index 7ef2bd8..b8f35b1 100644 --- a/docs/reference/data.timss1.html +++ b/docs/reference/data.timss1.html @@ -1,67 +1,12 @@ - - - - - - - -Dataset TIMSS 2011 — data.timss • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Dataset TIMSS 2011 — data.timss • BIFIEsurvey - - - - + + -
-
- -
- -
+
-
data(data.timss1)
-data(data.timss1.ind)
-data(data.timss2)
-data(data.timssrep)
-data(data.timss3)
-data(data.timss4)
- - -

Format

+
+
data(data.timss1)
+data(data.timss1.ind)
+data(data.timss2)
+data(data.timssrep)
+data(data.timss3)
+data(data.timss4)
+
+
+

Format

The dataset data.timss1 is a list containing 5 imputed datasets. The dataset data.timss1.ind contains response indicators of these 5 imputed datasets in data.timss1.

@@ -137,201 +70,200 @@

Format

The dataset data.timss4 is a list containing nested multiply imputed datasets, with 5 between-nest and 4 within-nest imputations.

+

-

Examples

-
if (FALSE) {
-library(survey)
-library(lavaan.survey)
-library(intsvy)
-library(mitools)
-
-#############################################################################
-# EXAMPLE 1: TIMSS dataset data.timss3 (one dataset including all PVs)
-#############################################################################
-
-data(data.timss2)
-data(data.timss3)
-data(data.timssrep)
-
-# Analysis based on official 'single' datasets (data.timss3)
-# There are 5 plausible values, but student covariates are not imputed.
-
-#--- create object of class BIFIE data
-bdat3 <- BIFIEsurvey::BIFIE.data(data.timss3, wgt=data.timss3$TOTWGT,
-              wgtrep=data.timssrep[,-1], fayfac=1)
-summary(bdat3)
-# This BIFIEdata object contains one dataset in which all
-# plausible values are included. This object can be used
-# in analysis without plausible values.
-# Equivalently, one can define bdat3 much simpler by
-bdat3 <- BIFIEsurvey::BIFIE.data.jack(data.timss3, jktype="JK_TIMSS")
-summary(bdat3)
-
-#--- In the following, the object bdat4 is defined with 5 datasets
-# referring to 5 plausible values.
-bdat4 <- BIFIEsurvey::BIFIE.data.jack(data.timss3, pv_vars=c("ASMMAT","ASSSCI"),
-               jktype="JK_TIMSS")
-summary(bdat4)
-
-#--- create object in survey package
-dat3a <- as.data.frame( cbind( data.timss2[[1]], data.timssrep ) )
-RR <- ncol(data.timssrep) - 1       # number of jackknife zones
-svydes3 <- survey::svrepdesign(data=dat3a, weights=~TOTWGT, type="JKn",
-                 repweights='w_fstr[0-9]', scale=1,  rscales=rep(1,RR), mse=TRUE)
-summary(svydes3)
-
-#--- create object with imputed datasets in survey
-datL <- data.timss2
-# include replicate weights in each dataset
-for (ii in 1:5){
-    dat1 <- datL[[ii]]
-    dat1 <- cbind(  dat1, data.timssrep[,-1] )
-    datL[[ii]] <- dat1
-}
-datL <- mitools::imputationList(list( datL[[1]],datL[[2]],datL[[3]],datL[[4]],datL[[5]]))
-svydes4 <- survey::svrepdesign(data=datL, weights=~TOTWGT, type="JKn",
-                   repweights='w_fstr[0-9]', scale=1,  rscales=rep(1,RR), mse=TRUE)
-summary(svydes4)
-
-#--- reconstruct data.timss3 for intsvy package. Plausible values must be labeled
-# as PV01, PV02, ... and NOT PV1, PV2, ...
-data.timss3a <- data.timss3
-colnames(data.timss3a) <- gsub( "ASMMAT", "ASMMAT0", colnames(data.timss3a) )
-colnames(data.timss3a) <- gsub( "ASSSCI", "ASSSCI0", colnames(data.timss3a) )
-
-#***************************
-# Model 1: Linear regression (no grouping variable)
-
-#--- linear regression in survey
-mod1a <-  survey::svyglm( scsci ~ migrant + books, design=svydes3)
-summary(mod1a)
-
-#--- regression with pirls.reg (intsvy)
-mod1b <- intsvy::pirls.reg( y="scsci", x=c("migrant", "books" ), data=data.timss3)
-mod1b
-
-#---- regression with BIFIEsurvey
-mod1c <- BIFIEsurvey::BIFIE.linreg( bdat3, dep="scsci", pre=c("one","migrant","books"))
-summary(mod1c)
-
-#--- regression with lavaan.survey package
-lavmodel <- "
-    scsci ~ migrant + books
-    scsci ~ 1
-    scsci ~~ scsci
-        "
-# fit in lavaan
-lavaan.fit <- lavaan::lavaan( lavmodel, data=data.timss3, estimator="MLM")
-summary(lavaan.fit)
-# using all replicated weights
-mod1d <- lavaan.survey::lavaan.survey(lavaan.fit=lavaan.fit, survey.design=svydes3 )
-summary(mod1d)
-
-#***************************
-# Model 2: Linear regression (grouped by female)
-
-#--- linear regression in survey
-mod2a <- survey::svyglm( scsci ~ 0 + as.factor(female) + as.factor(female):migrant
-               + as.factor(female):books, design=svydes3)
-summary(mod2a)
-
-#--- regression with pirls.reg (intsvy)
-mod2b <- intsvy::pirls.reg( y="scsci", x=c("migrant", "books" ),
-                 by="female", data=data.timss3)
-mod2b[["0"]]   # regression coefficients female=0
-mod2b[["1"]]   # regression coefficients female=1
-
-#--- regression with BIFIEsurvey
-mod2c <- BIFIEsurvey::BIFIE.linreg( bdat3, dep="scsci",
-               pre=c("one","migrant","books"), group="female")
-summary(mod2c)
-
-#--- regression with lavaan.survey package
-lavmodel <- "
-    scsci ~ migrant + books
-    scsci ~ 1
-    scsci ~~ scsci
-        "
-# fit in lavaan
-lavaan.fit <- lavaan::lavaan( lavmodel, data=data.timss3, group="female", estimator="MLM")
-summary(lavaan.fit)
-mod2d <- lavaan.survey::lavaan.survey(lavaan.fit=lavaan.fit, survey.design=svydes3 )
-summary(mod2d)
-
-#***************************
-# Model 3: Linear regression with mathematics PVs
-library(mitools)
-
-#--- linear regression in survey
-mod3a <- with(svydes4,  survey::svyglm( ASMMAT ~ migrant + books, design=svydes4 ) )
-res3a <- mitools::MIcombine(mod3a)
-summary(res3a)
-
-#--- regression with pirls.reg.pv (intsvy)
-mod3b <- intsvy::pirls.reg.pv( pvlabel="ASMMAT", x=c("migrant", "books" ),
-             data=data.timss3a)
-
-#--- regression with BIFIEsurvey
-mod3c <- BIFIEsurvey::BIFIE.linreg( bdat4, dep="ASMMAT", pre=c("one","migrant","books"))
-summary(mod3c)
-
-#--- regression with lavaan.survey package
-lavmodel <- "
-    ASMMAT ~ migrant + books
-    ASMMAT ~ 1
-    ASMMAT ~~ ASMMAT
-        "
-# fit in lavaan
-lavaan.fit <- lavaan::lavaan( lavmodel, data=data.timss3a, group="female", estimator="MLM")
-summary(lavaan.fit)
-mod3d <- lavaan.survey::lavaan.survey(lavaan.fit=lavaan.fit, survey.design=svydes4 )
-summary(mod3d)
-
-#############################################################################
-# EXAMPLE 2: TIMSS dataset data.timss4 | Nested multiply imputed dataset
-#############################################################################
-
-data(data.timss4)
-data(data.timssrep)
-
-#**** create BIFIEdata object
-bdat <- BIFIEsurvey::BIFIE.data( data.list=data.timss4, wgt=data.timss4[[1]][[1]]$TOTWGT,
-               wgtrep=data.timssrep[, -1 ], NMI=TRUE, cdata=TRUE )
-summary(bdat)
-
-#**** Model 1: Linear regression for mathematics score
-mod1 <- BIFIEsurvey::BIFIE.linreg( bdat, dep="ASMMAT", pre=c("one","books","migrant"))
-summary(mod1)
-
-#*** Model 2: Univariate statistics ?BIFIEsurvey::BIFIE.univar
-mod2 <- BIFIEsurvey::BIFIE.univar( bdat, vars=c("ASMMAT","ASSSCI","books") )
-summary(mod2)
-}
+
+

Examples

+
if (FALSE) {
+library(survey)
+library(lavaan.survey)
+library(intsvy)
+library(mitools)
+
+#############################################################################
+# EXAMPLE 1: TIMSS dataset data.timss3 (one dataset including all PVs)
+#############################################################################
+
+data(data.timss2)
+data(data.timss3)
+data(data.timssrep)
+
+# Analysis based on official 'single' datasets (data.timss3)
+# There are 5 plausible values, but student covariates are not imputed.
+
+#--- create object of class BIFIE data
+bdat3 <- BIFIEsurvey::BIFIE.data(data.timss3, wgt=data.timss3$TOTWGT,
+              wgtrep=data.timssrep[,-1], fayfac=1)
+summary(bdat3)
+# This BIFIEdata object contains one dataset in which all
+# plausible values are included. This object can be used
+# in analysis without plausible values.
+# Equivalently, one can define bdat3 much simpler by
+bdat3 <- BIFIEsurvey::BIFIE.data.jack(data.timss3, jktype="JK_TIMSS")
+summary(bdat3)
+
+#--- In the following, the object bdat4 is defined with 5 datasets
+# referring to 5 plausible values.
+bdat4 <- BIFIEsurvey::BIFIE.data.jack(data.timss3, pv_vars=c("ASMMAT","ASSSCI"),
+               jktype="JK_TIMSS")
+summary(bdat4)
+
+#--- create object in survey package
+dat3a <- as.data.frame( cbind( data.timss2[[1]], data.timssrep ) )
+RR <- ncol(data.timssrep) - 1       # number of jackknife zones
+svydes3 <- survey::svrepdesign(data=dat3a, weights=~TOTWGT, type="JKn",
+                 repweights='w_fstr[0-9]', scale=1,  rscales=rep(1,RR), mse=TRUE)
+summary(svydes3)
+
+#--- create object with imputed datasets in survey
+datL <- data.timss2
+# include replicate weights in each dataset
+for (ii in 1:5){
+    dat1 <- datL[[ii]]
+    dat1 <- cbind(  dat1, data.timssrep[,-1] )
+    datL[[ii]] <- dat1
+}
+datL <- mitools::imputationList(list( datL[[1]],datL[[2]],datL[[3]],datL[[4]],datL[[5]]))
+svydes4 <- survey::svrepdesign(data=datL, weights=~TOTWGT, type="JKn",
+                   repweights='w_fstr[0-9]', scale=1,  rscales=rep(1,RR), mse=TRUE)
+summary(svydes4)
+
+#--- reconstruct data.timss3 for intsvy package. Plausible values must be labeled
+# as PV01, PV02, ... and NOT PV1, PV2, ...
+data.timss3a <- data.timss3
+colnames(data.timss3a) <- gsub( "ASMMAT", "ASMMAT0", colnames(data.timss3a) )
+colnames(data.timss3a) <- gsub( "ASSSCI", "ASSSCI0", colnames(data.timss3a) )
+
+#***************************
+# Model 1: Linear regression (no grouping variable)
+
+#--- linear regression in survey
+mod1a <-  survey::svyglm( scsci ~ migrant + books, design=svydes3)
+summary(mod1a)
+
+#--- regression with pirls.reg (intsvy)
+mod1b <- intsvy::pirls.reg( y="scsci", x=c("migrant", "books" ), data=data.timss3)
+mod1b
+
+#---- regression with BIFIEsurvey
+mod1c <- BIFIEsurvey::BIFIE.linreg( bdat3, dep="scsci", pre=c("one","migrant","books"))
+summary(mod1c)
+
+#--- regression with lavaan.survey package
+lavmodel <- "
+    scsci ~ migrant + books
+    scsci ~ 1
+    scsci ~~ scsci
+        "
+# fit in lavaan
+lavaan.fit <- lavaan::lavaan( lavmodel, data=data.timss3, estimator="MLM")
+summary(lavaan.fit)
+# using all replicated weights
+mod1d <- lavaan.survey::lavaan.survey(lavaan.fit=lavaan.fit, survey.design=svydes3 )
+summary(mod1d)
+
+#***************************
+# Model 2: Linear regression (grouped by female)
+
+#--- linear regression in survey
+mod2a <- survey::svyglm( scsci ~ 0 + as.factor(female) + as.factor(female):migrant
+               + as.factor(female):books, design=svydes3)
+summary(mod2a)
+
+#--- regression with pirls.reg (intsvy)
+mod2b <- intsvy::pirls.reg( y="scsci", x=c("migrant", "books" ),
+                 by="female", data=data.timss3)
+mod2b[["0"]]   # regression coefficients female=0
+mod2b[["1"]]   # regression coefficients female=1
+
+#--- regression with BIFIEsurvey
+mod2c <- BIFIEsurvey::BIFIE.linreg( bdat3, dep="scsci",
+               pre=c("one","migrant","books"), group="female")
+summary(mod2c)
+
+#--- regression with lavaan.survey package
+lavmodel <- "
+    scsci ~ migrant + books
+    scsci ~ 1
+    scsci ~~ scsci
+        "
+# fit in lavaan
+lavaan.fit <- lavaan::lavaan( lavmodel, data=data.timss3, group="female", estimator="MLM")
+summary(lavaan.fit)
+mod2d <- lavaan.survey::lavaan.survey(lavaan.fit=lavaan.fit, survey.design=svydes3 )
+summary(mod2d)
+
+#***************************
+# Model 3: Linear regression with mathematics PVs
+library(mitools)
+
+#--- linear regression in survey
+mod3a <- with(svydes4,  survey::svyglm( ASMMAT ~ migrant + books, design=svydes4 ) )
+res3a <- mitools::MIcombine(mod3a)
+summary(res3a)
+
+#--- regression with pirls.reg.pv (intsvy)
+mod3b <- intsvy::pirls.reg.pv( pvlabel="ASMMAT", x=c("migrant", "books" ),
+             data=data.timss3a)
+
+#--- regression with BIFIEsurvey
+mod3c <- BIFIEsurvey::BIFIE.linreg( bdat4, dep="ASMMAT", pre=c("one","migrant","books"))
+summary(mod3c)
+
+#--- regression with lavaan.survey package
+lavmodel <- "
+    ASMMAT ~ migrant + books
+    ASMMAT ~ 1
+    ASMMAT ~~ ASMMAT
+        "
+# fit in lavaan
+lavaan.fit <- lavaan::lavaan( lavmodel, data=data.timss3a, group="female", estimator="MLM")
+summary(lavaan.fit)
+mod3d <- lavaan.survey::lavaan.survey(lavaan.fit=lavaan.fit, survey.design=svydes4 )
+summary(mod3d)
+
+#############################################################################
+# EXAMPLE 2: TIMSS dataset data.timss4 | Nested multiply imputed dataset
+#############################################################################
+
+data(data.timss4)
+data(data.timssrep)
+
+#**** create BIFIEdata object
+bdat <- BIFIEsurvey::BIFIE.data( data.list=data.timss4, wgt=data.timss4[[1]][[1]]$TOTWGT,
+               wgtrep=data.timssrep[, -1 ], NMI=TRUE, cdata=TRUE )
+summary(bdat)
+
+#**** Model 1: Linear regression for mathematics score
+mod1 <- BIFIEsurvey::BIFIE.linreg( bdat, dep="ASMMAT", pre=c("one","books","migrant"))
+summary(mod1)
+
+#*** Model 2: Univariate statistics ?BIFIEsurvey::BIFIE.univar
+mod2 <- BIFIEsurvey::BIFIE.univar( bdat, vars=c("ASMMAT","ASSSCI","books") )
+summary(mod2)
+}
+
+
-
- +
- - + + diff --git a/docs/reference/index.html b/docs/reference/index.html index 687171b..ab7c526 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -1,66 +1,12 @@ - - - - - - - -Function reference • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Function reference • BIFIEsurvey - - + + - - -
-
- -
- -
+
- - - - - - - - - - -
-

All functions

+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+

All functions

+

BIFIE.BIFIEdata2BIFIEcdata() BIFIE.BIFIEcdata2BIFIEdata() BIFIE.BIFIEdata2datalist()

Conversion and Selection of BIFIEdata Objects

+

BIFIE.by() summary(<BIFIE.by>) coef(<BIFIE.by>) vcov(<BIFIE.by>)

Statistics for User Defined Functions

+

BIFIE.correl() summary(<BIFIE.correl>) coef(<BIFIE.correl>) vcov(<BIFIE.correl>)

Correlations and Covariances

+

BIFIE.crosstab() summary(<BIFIE.crosstab>) coef(<BIFIE.crosstab>) vcov(<BIFIE.crosstab>)

Cross Tabulation

+

BIFIE.data.boot()

Create BIFIE.data Object based on Bootstrap

+

BIFIE.data.jack()

Create BIFIE.data Object with Jackknife Zones

+

BIFIE.data() summary(<BIFIEdata>) print(<BIFIEdata>)

Creates an Object of Class BIFIEdata

+

BIFIEdata.select()

Selection of Variables and Imputed Datasets for Objects of Class BIFIEdata

+

BIFIE.data.transform()

Data Transformation for BIFIEdata Objects

+

BIFIE.derivedParameters() summary(<BIFIE.derivedParameters>) coef(<BIFIE.derivedParameters>) vcov(<BIFIE.derivedParameters>)

Statistical Inference for Derived Parameters

+

BIFIE.ecdf() summary(<BIFIE.ecdf>)

Empirical Distribution Function and Quantiles

+

BIFIE.freq() summary(<BIFIE.freq>) coef(<BIFIE.freq>) vcov(<BIFIE.freq>)

Frequency Statistics

+

BIFIE.hist() summary(<BIFIE.hist>) plot(<BIFIE.hist>)

Histogram

+

BIFIE.lavaan.survey() summary(<BIFIE.lavaan.survey>) coef(<BIFIE.lavaan.survey>) vcov(<BIFIE.lavaan.survey>) BIFIE.survey() summary(<BIFIE.survey>) coef(<BIFIE.survey>) vcov(<BIFIE.survey>)

Fitting a Model in lavaan or in survey

+

BIFIE.linreg() summary(<BIFIE.linreg>) coef(<BIFIE.linreg>) vcov(<BIFIE.linreg>)

Linear Regression

+

BIFIE.logistreg() summary(<BIFIE.logistreg>) coef(<BIFIE.logistreg>) vcov(<BIFIE.logistreg>)

Logistic Regression

+

BIFIE.mva() summary(<BIFIE.mva>)

Missing Value Analysis

+

BIFIE.pathmodel() summary(<BIFIE.pathmodel>) coef(<BIFIE.pathmodel>) vcov(<BIFIE.pathmodel>)

Path Model Estimation

+

BIFIE.twolevelreg() summary(<BIFIE.twolevelreg>) coef(<BIFIE.twolevelreg>) vcov(<BIFIE.twolevelreg>)

Two Level Regression

+

BIFIE.univar() summary(<BIFIE.univar>) coef(<BIFIE.univar>) vcov(<BIFIE.univar>)

Univariate Descriptive Statistics (Means and Standard Deviations)

+

BIFIE.univar.test() summary(<BIFIE.univar.test>)

Analysis of Variance and Effect Sizes for Univariate Statistics

+

BIFIE.waldtest() summary(<BIFIE.waldtest>)

Wald Tests for BIFIE Methods

+

BIFIEdata2svrepdesign() svrepdesign2BIFIEdata()

Conversion of a BIFIEdata Object into a svyrep Object in the survey Package (and the other way around)

-

BIFIEsurvey-package

+
+

BIFIEsurvey-package BIFIEsurvey

Tools for Survey Statistics in Educational Assessment

+

bifiesurvey_rcpp_rubin_rules() bifiesurvey_rcpp_replication_variance() BIFIE_NMI_inference_parameters()

Utility Functions in BIFIEsurvey

+

bifietable()

An Rcpp Based Version of the table Function

+

data.bifie01

Example Datasets for the BIFIEsurvey Package

+

data.pisaNLD

Some PISA Datasets

+

data.test1

Some Datasets for Testing Purposes

+

data.timss1 data.timss1.ind data.timss2 data.timssrep data.timss3 data.timss4

Dataset TIMSS 2011

+

save.BIFIEdata() write.BIFIEdata() load.BIFIEdata() load.BIFIEdata.files()

Saving, Writing and Loading BIFIEdata Objects

+

se()

Standard Errors of Estimated Parameters

- +
+
-
- +
- - + + diff --git a/docs/reference/save.BIFIEdata.html b/docs/reference/save.BIFIEdata.html index fab09c3..6a5474c 100644 --- a/docs/reference/save.BIFIEdata.html +++ b/docs/reference/save.BIFIEdata.html @@ -1,71 +1,16 @@ - - - - - - - -Saving, Writing and Loading <code>BIFIEdata</code> Objects — save.BIFIEdata • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Saving, Writing and Loading BIFIEdata Objects — save.BIFIEdata • BIFIEsurvey - - - - - - - - - - - - - + + -
-
- -
- -
+
-
save.BIFIEdata(BIFIEdata, name.BIFIEdata, cdata=TRUE, varnames=NULL)
-
-write.BIFIEdata( BIFIEdata, name.BIFIEdata, dir=getwd(), varnames=NULL,
-    impdata.index=NULL, type="Rdata", ... )
-
-load.BIFIEdata(filename, dir=getwd() )
-
-load.BIFIEdata.files( files.imp, wgt, file.wgtrep, file.ind=NULL,
-    type="Rdata",varnames=NULL, cdata=TRUE, dir=getwd(), ... )
- -

Arguments

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BIFIEdata

Object of class BIFIEdata

name.BIFIEdata

Name of BIFIEdata set to be saved

cdata

An optional logical indicating whether the dataset should be -saved in a 'compact way'

varnames

Vector of variable names which should be saved. The default - is to use all variables.

dir

Directory in which data files should be saved. The default -is the working directory.

impdata.index

Vector of indices for selecting imputed datasets

type

Type of saved data. Options are Rdata (function - base::save, - csv (function utils::write.csv), - csv2 (function utils::write.csv2), - table (function utils::write.table), - sav (function foreign::read.spss +

+
save.BIFIEdata(BIFIEdata, name.BIFIEdata, cdata=TRUE, varnames=NULL)
+
+write.BIFIEdata( BIFIEdata, name.BIFIEdata, dir=getwd(), varnames=NULL,
+    impdata.index=NULL, type="Rdata", ... )
+
+load.BIFIEdata(filename, dir=getwd() )
+
+load.BIFIEdata.files( files.imp, wgt, file.wgtrep, file.ind=NULL,
+    type="Rdata",varnames=NULL, cdata=TRUE, dir=getwd(), ... )
+
+ +
+

Arguments

+
BIFIEdata
+

Object of class BIFIEdata

+ +
name.BIFIEdata
+

Name of BIFIEdata set to be saved

+ +
cdata
+

An optional logical indicating whether the dataset should be +saved in a 'compact way'

+ +
varnames
+

Vector of variable names which should be saved. The default + is to use all variables.

+ +
dir
+

Directory in which data files should be saved. The default +is the working directory.

+ +
impdata.index
+

Vector of indices for selecting imputed datasets

+ +
type
+

Type of saved data. Options are Rdata (function + base::save, + csv (function utils::write.csv), + csv2 (function utils::write.csv2), + table (function utils::write.table), + sav (function foreign::read.spss for reading sav files and function - sjlabelled::write_spss for writing sav files).

...

Additional arguments to be passed to - base::save, - utils::write.csv, - utils::write.csv2, - utils::write.table, - foreign::read.spss, - sjlabelled::write_spss

filename

File name of BIFIEdata object

files.imp

Vector of file names of imputed datasets

wgt

Variable name of case weight

file.wgtrep

File name for dataset with replicate weights

file.ind

Optional. File name for dataset with response data indicators

- -

Value

- -

Saved R object and a summary in working directory or a loaded R object.

-

See also

- -

For creating objects of class BIFIEdata see BIFIE.data.

-

base::save, base::load

- -

Examples

-

+    sjlabelled::write_spss for writing sav files).

+ +
...
+

Additional arguments to be passed to + base::save, + utils::write.csv, + utils::write.csv2, + utils::write.table, + foreign::read.spss, + sjlabelled::write_spss

+ +
filename
+

File name of BIFIEdata object

+ +
files.imp
+

Vector of file names of imputed datasets

+ +
wgt
+

Variable name of case weight

+ +
file.wgtrep
+

File name for dataset with replicate weights

+ +
file.ind
+

Optional. File name for dataset with response data indicators

+ +
+
+

Value

+ + +

Saved R object and a summary in working directory or a loaded R object.

+
+
+

See also

+

For creating objects of class BIFIEdata see BIFIE.data.

+

base::save, base::load

+
+ +
+

Examples

+ +
+
-
- +
- - + + diff --git a/docs/reference/se.html b/docs/reference/se.html index 53c0945..b10ad4a 100644 --- a/docs/reference/se.html +++ b/docs/reference/se.html @@ -1,67 +1,12 @@ - - - - - - - -Standard Errors of Estimated Parameters — se • BIFIEsurvey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Standard Errors of Estimated Parameters — se • BIFIEsurvey - - - - + + -
-
- -
- -
+
-
se(object)
- -

Arguments

- - - - - - -
object

Object for which S3 method vcov can be applied

- -

Value

- -

Vector

-

See also

- - - -

Examples

-
#############################################################################
-# EXAMPLE 1: Toy example with lm function
-#############################################################################
-
-set.seed(906)
-N <- 100
-x <- seq(0,1,length=N)
-y <- .6*x + stats::rnorm(N, sd=1)
-mod <- stats::lm( y ~ x )
-coef(mod)
-vcov(mod)
-se(mod)
-summary(mod)
+
+
se(object)
+
+ +
+

Arguments

+
object
+

Object for which S3 method vcov can be applied

+ +
+
+

Value

+ + +

Vector

+
+
+

See also

+

survey::SE

+
+ +
+

Examples

+
#############################################################################
+# EXAMPLE 1: Toy example with lm function
+#############################################################################
+
+set.seed(906)
+N <- 100
+x <- seq(0,1,length=N)
+y <- .6*x + stats::rnorm(N, sd=1)
+mod <- stats::lm( y ~ x )
+coef(mod)
+vcov(mod)
+se(mod)
+summary(mod)
+
+
-
- +
- - + + diff --git a/docs/sitemap.xml b/docs/sitemap.xml new file mode 100644 index 0000000..5038739 --- /dev/null +++ b/docs/sitemap.xml @@ -0,0 +1,111 @@ + + + + /404.html + + + /authors.html + + + /index.html + + + /reference/BIFIE.BIFIEdata2BIFIEcdata.html + + + /reference/BIFIE.by.html + + + /reference/BIFIE.correl.html + + + /reference/BIFIE.crosstab.html + + + /reference/BIFIE.data.boot.html + + + /reference/BIFIE.data.html + + + /reference/BIFIE.data.jack.html + + + /reference/BIFIE.data.select.html + + + /reference/BIFIE.data.transform.html + + + /reference/BIFIE.derivedParameters.html + + + /reference/BIFIE.ecdf.html + + + /reference/BIFIE.freq.html + + + /reference/BIFIE.hist.html + + + /reference/BIFIE.lavaan.survey.html + + + /reference/BIFIE.linreg.html + + + /reference/BIFIE.logistreg.html + + + /reference/BIFIE.mva.html + + + /reference/BIFIE.pathmodel.html + + + /reference/BIFIE.twolevelreg.html + + + /reference/BIFIE.univar.html + + + /reference/BIFIE.univar.test.html + + + /reference/BIFIE.waldtest.html + + + /reference/BIFIEdata2svrepdesign.html + + + /reference/BIFIEsurvey-package.html + + + /reference/BIFIEsurvey-utilities.html + + + /reference/bifietable.html + + + /reference/data.bifie.html + + + /reference/data.pisaNLD.html + + + /reference/data.test1.html + + + /reference/data.timss1.html + + + /reference/index.html + + + /reference/save.BIFIEdata.html + + + /reference/se.html + + diff --git a/inst/NEWS b/inst/NEWS index 383b2ea..5371ccd 100644 --- a/inst/NEWS +++ b/inst/NEWS @@ -51,8 +51,10 @@ CHANGELOG BIFIEsurvey + + -------------------------------------------------------------------------- -VERSIONS BIFIEsurvey 3.6 | 2024-02-18 | Last: BIFIEsurvey 3.6-2 +VERSIONS BIFIEsurvey 3.7 | 2024-04-26 | Last: BIFIEsurvey 3.7-1 -------------------------------------------------------------------------- xxx * --- @@ -62,6 +64,16 @@ DATA * --- EXAMP * --- + +-------------------------------------------------------------------------- +VERSIONS BIFIEsurvey 3.6 | 2024-04-25 | Last: BIFIEsurvey 3.6-6 +-------------------------------------------------------------------------- + +FIXED * fixed a bug in pseudo-R^2 computation in BIFIE.logistreg() + +DATA * --- +EXAMP * --- + -------------------------------------------------------------------------- VERSIONS BIFIEsurvey 3.5 | 2024-02-18 | Last: BIFIEsurvey 3.5-19 -------------------------------------------------------------------------- diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index d8508aa..ccc0f31 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -1,5 +1,5 @@ //// File Name: RcppExports.cpp -//// File Version: 3.006002 +//// File Version: 3.007001 // Generated by using Rcpp::compileAttributes() -> do not edit by hand // Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 diff --git a/src/bifiesurvey_rcpp_logistreg.cpp b/src/bifiesurvey_rcpp_logistreg.cpp index 77ba483..2844315 100644 --- a/src/bifiesurvey_rcpp_logistreg.cpp +++ b/src/bifiesurvey_rcpp_logistreg.cpp @@ -1,5 +1,5 @@ //// File Name: bifiesurvey_rcpp_logistreg.cpp -//// File Version: 0.29 +//// File Version: 0.303 #include @@ -212,7 +212,8 @@ Rcpp::List bifiesurvey_rcpp_logistreg( Rcpp::NumericMatrix datalist, Rcpp::Numer tempcoef = res1["beta"]; Rcpp::NumericVector tempparm = res1["parm"]; for (int vv=0;vv