# C7C9DB3B - "collab_server"contents Title Stats Methods...

• 2

This preview shows page 1 - 2 out of 2 pages.

{ "collab_server" : "", "contents" : "### Title: Stats & Methods Lab 1 Demonstration Script 2\n### Author: Kyle M. Lang\n### Created: 2018-09-10\n### Modified: 2020-09- 04\n\n## Clear the workspace:\nrm(list = ls(all = TRUE))\n\n## Set your working directory to the \"code\" directory:\nsetwd(\"\")\n\n## Install the 'mice' function:\ninstall.packages(\"mice\", repos = \"- project.org\")\n\n## Load packages:\nlibrary(mice) # For missing data descriptives\nlibrary(MASS) # For robust stats\n\n## Define the data directory:\ndataDir <- \"../data/\"\n\n###---------------------------------------------------------- ----------------###\n\n### Missing Data Descriptives ###\n\nbfi <- readRDS(paste0(dataDir, \"bfiANC.rds\"))\n\n## Compute variable-wise counts/percents missing/observed:\ncm <- colSums(is.na(bfi))\ncm\npm <- colMeans(is.na(bfi))\npm\n\nco <- colSums(!is.na(bfi))\nco\npo <- colMeans(! is.na(bfi))\npo\n\nnrow(bfi) - cm\n1 - pm\n\nnrow(bfi) - co\n1 - po\n\n## Summarize PM:\nrange(pm)\nmean(pm)\nmedian(pm)\n\n## Find variables with PM greater than 10%:\npm[pm > 0.1]\n\n## Find missing data patterns:\nmissPat <- md.pattern(bfi)\nmissPat\n\n## Extract the variablewise missing