Skip to content

Latest commit

 

History

History
83 lines (70 loc) · 8.91 KB

SimData-Syn.md

File metadata and controls

83 lines (70 loc) · 8.91 KB

Simulated HDS dataset

##########Create Correlation matrix############

###Load lavaan for low2cor function####
library(lavaan)

###Lower Half of 42 x 42 HDS Item correlation matrix - Bold (n = 14), Mischievious (n = 14), and Skeptical (n =14) Items######
HDS.cor.v <- c(1.00, 
             0.133, 1.00,
             0.190, 0.177, 1.00,
             0.125, 0.082, 0.146, 1.00,
             0.043, 0.115, 0.094, 0.073, 1.000,
             0.075, 0.153, 0.102, 0.098, 0.225, 1.000,
             0.028, 0.138, 0.102, 0.044, 0.402, 0.295, 1.000,
             0.026, 0.098, 0.060, 0.021, 0.090, 0.098, 0.128, 1.000,
             0.111, 0.077, 0.130, 0.123, 0.073, 0.098, 0.053, 0.013, 1.000,
             0.126, 0.193, 0.168, 0.095, 0.148, 0.215, 0.168, 0.113, 0.095, 1.000,
             0.078, 0.186, 0.071, 0.031, 0.095, 0.111, 0.134, 0.110, 0.022, 0.138, 1.000,
             0.060, 0.112, 0.079, 0.049, 0.123, 0.136, 0.144, 0.131, 0.031, 0.191, 0.125, 1.000,
             0.033, 0.075, 0.058, 0.019, 0.130, 0.127, 0.192, 0.155, -0.006, 0.222, 0.122, 0.213, 1.000,
             0.039, 0.181, 0.106, 0.081, 0.131, 0.204, 0.146, 0.110, 0.080, 0.194, 0.088, 0.141, 0.142, 1.000,
             0.021, 0.030, 0.024, 0.009, 0.027, 0.044, 0.032, 0.072, 0.043, 0.092, 0.027, 0.067, 0.068, 0.050, 1.000,
             -0.053, 0.007, 0.045, 0.035, 0.126, 0.049, 0.109, 0.019, 0.014, 0.028, -0.003, 0.054, 0.059, 0.047, -0.033, 1.000,
             -0.076, 0.026, 0.013, 0.044, 0.111, 0.071, 0.093, 0.029, 0.038, 0.066, 0.033, 0.061, 0.064, 0.082, 0.025, 0.223, 1.000,
             0.019, 0.050, 0.035, 0.030, 0.064, 0.086, 0.075, 0.133, 0.033, 0.164, 0.060, 0.148, 0.192, 0.135, 0.254, 0.027, 0.081, 1.000,
             0.010, 0.066, 0.016, 0.024, 0.054, 0.078, 0.072, 0.059, 0.029, 0.087, 0.026, 0.071, 0.075, 0.116, 0.120, 0.005, 0.034, 0.195, 1.000,
             -0.044, 0.060, -0.032, 0.009, 0.077, 0.121, 0.077, 0.056, 0.027, 0.077, 0.026, 0.067, 0.073, 0.186, 0.094, -0.008, 0.057, 0.177, 0.298, 1.000,
             0.083, 0.036, 0.033, 0.079, 0.046, 0.087, 0.011, 0.068, 0.136, 0.120, 0.046, 0.096, 0.069, 0.098, 0.192, -0.039, 0.051, 0.309, 0.130, 0.125, 1.000,
             0.070, 0.050, 0.048, 0.068, 0.009, 0.078, -0.023, 0.034, 0.105, 0.082, 0.033, 0.049, -0.016, 0.083, 0.129, -0.067, 0.008, 0.122, 0.088, 0.076, 0.237, 1.000,
             0.056, 0.066, 0.074, 0.047, 0.086, 0.130, 0.082, 0.097, 0.074, 0.176, 0.056, 0.130, 0.130, 0.134, 0.112, 0.005, 0.029, 0.129, 0.062, 0.095, 0.096, 0.082, 1.000,
             -0.031, 0.054, 0.043, 0.015, 0.070, 0.127, 0.071, 0.080, 0.043, 0.100, 0.037, 0.106, 0.051, 0.124, 0.101, -0.012, 0.018, 0.112, 0.110, 0.146, 0.089, 0.112, 0.290, 1.000,
             0.037, 0.117, 0.104, 0.056, 0.136, 0.116, 0.152, 0.112, 0.041, 0.187, 0.103, 0.385, 0.205, 0.141, 0.073, 0.060, 0.066, 0.146, 0.076, 0.059, 0.092, 0.043, 0.119, 0.103,  1.000,
             0.034, 0.079, 0.075, 0.072, 0.048, 0.111, 0.037, 0.023, 0.082, 0.086, 0.040, 0.066, 0.023, 0.085, 0.058, -0.005, 0.008, 0.068, 0.058, 0.081, 0.063, 0.123, 0.097, 0.126, 0.063, 1.000,
             0.118, 0.123, 0.124, 0.096, 0.120, 0.150, 0.114, 0.102, 0.092, 0.225, 0.099, 0.225, 0.165, 0.151, 0.127, -0.001, 0.018, 0.157, 0.115, 0.081, 0.147, 0.132, 0.235, 0.205, 0.232, 0.129, 1.000,
             0.067, 0.091, 0.078, 0.061, 0.023, 0.100, 0.000, 0.002, 0.116, 0.078, 0.049, 0.039, -0.030, 0.055, 0.075, -0.104, -0.041, 0.011, 0.037, 0.040, 0.090, 0.142, 0.069, 0.100, 0.058, 0.121, 0.122, 1.000,
             0.030, 0.061, 0.073, 0.073, 0.040, 0.098, 0.014, 0.000, 0.112, 0.053, 0.003, 0.026, -0.021, 0.075, 0.021, -0.028, -0.010, 0.011, 0.043, 0.063, 0.060, 0.102, 0.071, 0.112, 0.043, 0.128, 0.085, 0.206, 1.000,
             0.033, 0.088, 0.130, 0.073, 0.060, 0.093, 0.019, -0.006, 0.128, 0.065, 0.011, 0.018, -0.033, 0.072, 0.016, -0.029, -0.003, -0.002, 0.047, 0.031, 0.047, 0.114, 0.068, 0.105, 0.054, 0.122, 0.094, 0.282, 0.239, 1.000,
            -0.017, 0.000, 0.067, 0.037, -0.010, 0.042, -0.042, -0.001, 0.071, 0.030, -0.023, 0.011, -0.026, 0.024, 0.011, -0.010, -0.026, 0.002, 0.015, 0.005, 0.035, 0.065, 0.061, 0.105, 0.030, 0.092, 0.067, 0.183, 0.202, 0.349, 1.000,
             0.045, 0.100, 0.071, 0.054, 0.048, 0.085, 0.039, 0.007, 0.095, 0.057, 0.051, 0.039, -0.004, 0.054, 0.064, -0.057, -0.018, 0.009, 0.040, 0.022, 0.084, 0.125, 0.034, 0.067, 0.058, 0.081, 0.092, 0.222, 0.095, 0.188, 0.098, 1.000,
             0.062, 0.078, 0.083, 0.075, 0.039, 0.094, 0.021, 0.012, 0.108, 0.070, 0.024, 0.038, -0.012, 0.077, 0.019, -0.039, -0.018, 0.019, 0.046, 0.048, 0.061, 0.099, 0.077, 0.103, 0.035, 0.135, 0.096, 0.201, 0.452, 0.219, 0.160, 0.098, 1.000,
             0.029, 0.067, 0.085, 0.061, 0.046, 0.083, 0.021, 0.004, 0.100, 0.068, 0.011, 0.029, -0.016, 0.074, 0.028, -0.006, 0.018, 0.019, 0.032, 0.041, 0.041, 0.097, 0.079, 0.092, 0.034, 0.127, 0.069, 0.172, 0.292, 0.198, 0.151, 0.075, 0.299, 1.000,
             0.061, 0.119, 0.125, 0.059, 0.056, 0.090, 0.045, 0.059, 0.099, 0.100, 0.072, 0.081, 0.033, 0.142, 0.050, -0.040, 0.002, 0.085, 0.071, 0.089, 0.135, 0.112, 0.087, 0.102, 0.086, 0.085, 0.133, 0.139, 0.087, 0.133, 0.070, 0.139, 0.104, 0.060, 1.000,
             0.015, 0.108, 0.172, 0.117, 0.135, 0.115, 0.131, 0.056, 0.100, 0.108, 0.055, 0.126, 0.099, 0.143, 0.008, 0.099, 0.099, 0.078, 0.079, 0.077, 0.079, 0.042, 0.045, 0.071, 0.162, 0.059, 0.130, 0.061, 0.076, 0.117, 0.063, 0.099, 0.061, 0.040, 0.134, 1.000,
             0.030, 0.106, 0.184, 0.090, 0.088, 0.095, 0.084, 0.054, 0.083, 0.098, 0.039, 0.058, 0.043, 0.144, 0.026, 0.060, 0.055, 0.046, 0.074, 0.072, 0.018, 0.033, 0.096, 0.115, 0.079, 0.098, 0.111, 0.061, 0.092, 0.123, 0.072, 0.053, 0.090, 0.098, 0.142, 0.146, 1.000,
             0.080, 0.134, 0.151, 0.100, 0.054, 0.098, 0.024, 0.006, 0.168, 0.078, 0.039, 0.031, -0.050, 0.091, 0.048, -0.037, -0.009, -0.002, 0.033, 0.028, 0.075, 0.148, 0.071, 0.103, 0.053, 0.155, 0.112, 0.264, 0.218, 0.278, 0.161, 0.179, 0.223, 0.201, 0.156, 0.070, 0.143, 1.000,
             0.084, 0.000, 0.047, 0.041, -0.060, 0.013, -0.061, -0.032, 0.053, 0.005, -0.032, -0.046, -0.066, -0.027, 0.012, -0.122, -0.141, -0.038, -0.002, 0.002, 0.035, 0.098, 0.018, 0.049, -0.035, 0.061, 0.047, 0.128, 0.111, 0.117, 0.131, 0.074, 0.084, 0.050, 0.047, 0.009, 0.015, 0.109, 1.000,
             0.067, 0.048, 0.047, 0.045, -0.008, 0.048, -0.022, 0.000, 0.076, 0.090, 0.015, 0.013, 0.003, 0.051, 0.042, -0.075, -0.025, 0.049, 0.035, 0.045, 0.073, 0.105, 0.055, 0.043, 0.005, 0.066, 0.042, 0.108, 0.105, 0.105, 0.089, 0.051, 0.095, 0.108, 0.057, -0.012, 0.042, 0.116, 0.111, 1.000,
             0.063, 0.037, 0.082, 0.076, -0.010, 0.052, -0.018, -0.007, 0.092, 0.045, -0.011, 0.006, -0.028, 0.040, 0.026, -0.089, -0.060, 0.002, 0.027, 0.027, 0.064, 0.112, 0.039, 0.045, 0.019, 0.081, 0.058, 0.143, 0.130, 0.161, 0.124, 0.085, 0.111, 0.092, 0.088, 0.069, 0.073, 0.135, 0.297, 0.143, 1.000,
             0.053, 0.128, 0.131, 0.088, 0.090, 0.120, 0.104, 0.058, 0.093, 0.157, 0.081, 0.168, 0.080, 0.128, 0.043, 0.003, 0.024, 0.080, 0.072, 0.066, 0.088, 0.091, 0.096, 0.120, 0.189, 0.103, 0.180, 0.115, 0.106, 0.130, 0.093, 0.089, 0.105, 0.083, 0.130, 0.170, 0.111, 0.125, 0.070, 0.128, 0.125, 1.000)
              
###Create full correlation matrix###

HDS.cor <- lav_matrix_lower2full(HDS.cor.v)

###Name rows and columns###

rownames(HDS.cor) <- colnames(HDS.cor) <- c("bol1", "bol2", "bol3", "bol4", "bol5", "bol6", "bol7", "bol8", "bol9", "bol10", "bol11", "bol12", "bol13", "bol14", 
                                            "mis1", "mis2", "mis3", "mis4", "mis5", "mis6", "mis7", "mis8", "mis9", "mis10", "mis11", "mis12", "mis13", "mis14", 
                                            "ske1", "ske2", "ske3", "ske4", "ske5", "ske6", "ske7", "ske8", "ske9", "ske10", "ske11", "ske12", "ske13", "ske14")

###Item Means - marginal probability estimates####

p <- c(0.621, 0.630, 0.368, 0.138, 0.603, 0.285, 0.621, 0.921, 0.196, 0.407, 0.864, 0.812, 0.828, 0.378, 0.507, 0.329, 0.304, 0.709, 
       0.623, 0.337, 0.487, 0.309, 0.300, 0.248, 0.791, 0.172, 0.605, 0.493, 0.093, 0.347, 0.155, 0.698, 0.167, 0.060, 0.789, 0.573, 
       0.195, 0.276, 0.260, 0.073, 0.179, 0.444)

###Item SD - creating a covariance matrix###

sd <- c(0.486, 0.482, 0.482, 0.344, 0.489, 0.452, 0.485, 0.269, 0.396, 0.491, 0.342, 0.390, 0.377, 0.485, 0.500, 0.470, 0.460, 0.455, 
        0.484, 0.473, 0.500, 0.462, 0.459, 0.433, 0.406, 0.379, 0.489, 0.500, 0.292, 0.476, 0.362, 0.459, 0.374, 0.237, 0.408, 0.495, 
        0.397, 0.447, 0.439, 0.259, 0.383, 0.497)
        
###Simulate HDS Dataset###

library(bindata)
HDS.Sim <- rmvbin(1000000, margprob = p, bincorr = HDS.cor)
HDS.Sim <- as.data.frame(HDS.Sim)
colnames(HDS.Sim) <- c("bol1", "bol2", "bol3", "bol4", "bol5", "bol6", "bol7", "bol8", "bol9", "bol10", "bol11", "bol12", "bol13", "bol14", 
                       "mis1", "mis2", "mis3", "mis4", "mis5", "mis6", "mis7", "mis8", "mis9", "mis10", "mis11", "mis12", "mis13", "mis14", 
                       "ske1", "ske2", "ske3", "ske4", "ske5", "ske6", "ske7", "ske8", "ske9", "ske10", "ske11", "ske12", "ske13", "ske14")