IALSA / IALSA-2015-Portland

Hub to accompany IALSA 2015 workshop at Portland, OR, Feb 22-25, 2015
GNU General Public License v2.0
2 stars 0 forks source link

IP-SC #171

Open ampiccinin opened 7 years ago

ampiccinin commented 7 years ago

@andkov - at the risk of taking you off track, is there a quick way for me to view the IP-SC (and IC-SP) correlations? thanks!!

andkov commented 7 years ago

@ampiccinin , yes there is.

source("http://www.statmodel.com/mplus-R/mplus.R") # load

path_gh5 <- "./studies/eas/physical-cognitive/without-errors/gait-2016-11-30/b1_female_aehplus_walking_fluency_gait_bostonnaming.gh5"
testit::assert("File does not exist",file.exists(path_gh5))
# view options: https://www.statmodel.com/mplus-R/GH5_R.shtml

mplus.list.variables(path_gh5) # variables in the gh5 file
mplus.view.plots(path_gh5)  # available graphs for this type of gh5 file
# histograms
mplus.plot.histogram(path_gh5, "SP") # slope of process A
mplus.plot.histogram(path_gh5, "SC") # slope of process B
# scatterplots
mplus.plot.scatterplot(path_gh5, "IP", "IC") # intercepts
mplus.plot.scatterplot(path_gh5, "SP", "SC") # slopes
mplus.plot.scatterplot(path_gh5, "IP", "SP") # physical
mplus.plot.scatterplot(path_gh5, "IC", "SC") # cognitive

fscrores <- mplus.get.data(path_gh5, "SC")
summary(fscrores)

gives you a basic view of the data and factor score scatter plots. Is that what you need? Or you meant to view the value of the estimated parameter?

andkov commented 7 years ago

@ampiccinin , to view the table of the estimated parameters use the MplusAutomation package:

library(MplusAutomation)
library(tidyverse)
path_out <- "./studies/eas/physical-cognitive/without-errors/gait-2016-11-30/b1_female_aehplus_walking_fluency_gait_bostonnaming.out"
model_result <- MplusAutomation::readModels(path_out)
# print all estimated parameters
model_result$parameters$unstandardized 
# print selected paramter
model_result$parameters$unstandardized %>% 
  dplyr::filter(
    paramHeader == "IP.WITH",
    param       == "IC"
  )
ampiccinin commented 7 years ago

@andkov - Can I not see them in the Dynamic summary table? I just can't seem to find it...

andkov commented 7 years ago

Oh, I see.

No, these are not in this dynamic table. Each model is represented by ~230 indices, so we had to make cuts to keep it manageable. We used to have a table that contained EVERYTHING, but it was my impression it wasn't very popular, because it contained too much. Perhaps, this is a good time to think of a more elegant, yet thorough display that would allow for explorations you've described. I have something in mind.

In the meanwhile, you can access the raw catalog either as a csv or running the following script after loading the Portland repo project into your Rstudio:

rm(list=ls(all=TRUE)) #Clear the memory of variables from previous run. This is not called by knitr, because it's above the first chunk.
# input groups of column names for
source("./scripts/mplus/model-components.R") # organizes variable names
library(tidyverse) # load packages
path_input <- "./data/shared/pc-2-catalog-augmented.csv" # point to the catalog
catalog <- readr::read_csv(path_input) # import catalog
print(model_components) # view groups of variables available
# subset columns
ds <- catalog %>% 
  dplyr::filter(
    study_name   %in% c("map")
  , model_number %in% c("b1")
  , subgroup     %in% c("female","male")
  , model_type   %in% c("a","aehplus")
  , process_a    %in% c("fev")
  , process_b    %in% c("bnt")
  ) %>% 
  dplyr::select_(
    .dots = c(model_components[["id"]],"ab_tau_11_est","ab_tau_00_est")
  )