na.descript | R Documentation |
This function computes descriptive statistics for missing data in single-level, two-level, and three-level data, e.g. number of incomplete cases, number of missing values, and summary statistics for the number of missing values across all variables.
na.descript(..., data = NULL, cluster = NULL, table = FALSE, digits = 2,
as.na = NULL, write = NULL, append = TRUE, check = TRUE,
output = TRUE)
... |
a matrix or data frame with incomplete data, where missing
values are coded as |
data |
a data frame when specifying one or more variables in the
argument |
cluster |
a character string indicating the name of the cluster
variable in |
table |
logical: if |
digits |
an integer value indicating the number of decimal places to be used for displaying percentages. |
as.na |
a numeric vector indicating user-defined missing values,
i.e. these values are converted to |
write |
a character string naming a file for writing the output into
either a text file with file extension |
append |
logical: if |
check |
logical: if |
output |
logical: if |
Returns an object of class misty.object
, which is a list with following
entries:
call |
function call |
type |
type of analysis |
data |
data frame used for the current analysis |
args |
specification of function arguments |
result |
list with results |
Takuya Yanagida takuya.yanagida@univie.ac.at
Enders, C. K. (2010). Applied missing data analysis. Guilford Press.
Graham, J. W. (2009). Missing data analysis: Making it work in the real world. Annual Review of Psychology, 60, 549-576. https://doi.org/10.1146/annurev.psych.58.110405.085530
van Buuren, S. (2018). Flexible imputation of missing data (2nd ed.). Chapman & Hall.
write.result
, as.na
, na.as
,
na.auxiliary
, na.coverage
, na.indicator
,
na.pattern
, na.prop
, na.test
#----------------------------------------------------------------------------
# Single-Level Data
# Example 1a: Descriptive statistics for missing data
na.descript(airquality)
# Example 1b: Alternative specification using the 'data' argument
na.descript(., data = airquality)
# Example 2: Descriptive statistics for missing data, print results with 3 digits
na.descript(airquality, digits = 3)
# Example 3: Descriptive statistics for missing data with frequency table
na.descript(airquality, table = TRUE)
#----------------------------------------------------------------------------
# Two-Level Data
# Load data set "Demo.twolevel" in the lavaan package
data("Demo.twolevel", package = "lavaan")
# Example 4: escriptive statistics for missing data
na.descript(Demo.twolevel, cluster = "cluster")
#----------------------------------------------------------------------------
# Three-Level Data
# Create arbitrary three-level data
Demo.threelevel <- data.frame(Demo.twolevel, cluster2 = Demo.twolevel$cluster,
cluster3 = rep(1:10, each = 250))
# Example 5: Descriptive statistics for missing data
na.descript(Demo.threelevel, cluster = c("cluster3", "cluster2"))
#----------------------------------------------------------------------------
# Write Results
## Not run:
# Example 6a: Write Results into a text file
na.descript(airquality, table = TRUE, write = "NA_Descriptives.txt")
# Example 6b: Write Results into a Excel file
na.descript(airquality, table = TRUE, write = "NA_Descriptives.xlsx")
result <- na.descript(airquality, table = TRUE, output = FALSE)
write.result(result, "NA_Descriptives.xlsx")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.