R Under development (unstable) (2024-09-09 r87107 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library("psychomix") Loading required package: flexmix Loading required package: lattice Loading required package: psychotools > suppressWarnings(RNGversion("3.5.0")) > set.seed(1) > > ### Rost > r <- simRaschmix(design = "rost2", extremes = FALSE) > re <- simRaschmix(design = "rost2", extremes = TRUE) > > mr <- raschmix(r, k = 2, nrep = 1, scores = "saturated") 2 : * > mrs <- raschmix(r, k = 1:2, nrep = 1, scores = "saturated") 1 : * 2 : * > mre <- raschmix(data = re, k = 2, nrep = 1, scores = "saturated") 2 : * > mres <- raschmix(data = re, k = 1:3, nrep = 1, scores = "saturated") 1 : * 2 : * 3 : * > > mr Call: raschmix(formula = r, k = 2, scores = "saturated", nrep = 1) Cluster sizes: 1 2 830 819 convergence after 8 iterations > mrs Call: raschmix(formula = r, k = 1:2, scores = "saturated", nrep = 1) iter converged k k0 logLik AIC BIC ICL 1 2 TRUE 1 1 -10484.227 21002.45 21094.39 21094.39 2 10 TRUE 2 2 -8829.039 17728.08 17917.35 17987.33 > mre Call: raschmix(data = re, k = 2, scores = "saturated", nrep = 1) Cluster sizes: 1 2 798 824 convergence after 9 iterations > mres Call: raschmix(data = re, k = 1:3, scores = "saturated", nrep = 1) iter converged k k0 logLik AIC BIC ICL 1 2 TRUE 1 1 -11069.086 22176.17 22278.61 21208.96 2 9 TRUE 2 2 -9413.509 18901.02 19100.50 18101.17 3 67 TRUE 3 3 -9397.043 18904.09 19200.61 18314.56 > > options(digits = 4) > parameters(mr) Comp.1 Comp.2 item.Item01 NA NA item.Item02 -0.502341 0.440684 item.Item03 -1.245896 0.874500 item.Item04 -1.773345 1.516747 item.Item05 -2.313591 2.322729 item.Item06 -2.920368 2.820232 item.Item07 -3.496550 3.502710 item.Item08 -4.072865 4.098091 item.Item09 -4.680364 4.614149 item.Item10 -5.262647 5.275194 score.1 NA NA score.2 0.230504 0.006782 score.3 0.049722 0.081736 score.4 -0.106396 -0.064024 score.5 0.086188 -0.197729 score.6 0.202391 -0.085467 score.7 -0.008855 0.050351 score.8 0.172875 0.036870 score.9 0.256703 0.141052 > > ## mrrefit <- refit(mr) > ## summary(mrrefit) > > ## ------------------------------------------------- > > ## ### DIFSim > ## data("DIFSim", package = "psychotree") > ## #data("DIFSim", package = "psychotools") > ## DIFSim.na <- DIFSim > ## DIFSim.na$resp[1,1] <- NA > ## DIFSim.na$resp[2,] <- NA > ## DIFSim.na$age[3] <- NA > ## #m2 <- raschmix(DIFSim$resp, k = 2, nrep = 1, type = "rost") > ## m1 <- raschmix(DIFSim$resp, k = 2, nrep = 1, scores = "saturated", > ## control = list(iter.max = 20)) > ## m2 <- raschmix(resp ~ 1, DIFSim.na, k = 1, nrep = 1, scores = "saturated") > ## ## concomitant > ## m3 <- raschmix(resp ~ age + gender, data = DIFSim, k = 2, nrep = 1, > ## scores = "saturated") > ## m3mv <- raschmix(resp ~ age + gender, data = DIFSim, k = 2, nrep = 1, > ## scores = "meanvar") > ## #m4 <- raschmix(resp ~ age + gender, data = DIFSim[-(1:10),], k = 2:3, nrep = 1, > ## # scores = "saturated") > > ## ## print and summary > ## m3 > ## summary(m3) > ## ## m4 > ## ## m4.1 <- getModel(m4, which = 1) > ## ## m4.1 > ## ## summary(m4.1) > > ## ## logLik > ## logLik(m3) > > ## ## parameters > ## parameters(m3, which = "concomitant", component = 2:1) > ## parameters(m3, which = "score") > ## score.probs(m3mv) > > ## ## weights > ## ## weights(m3) > ## ## ## flexmix requires integer weights > ## ## w <- sample(1:nrow(DIFSim), nrow(DIFSim)) > ## ## m3w <- raschmix(resp ~ age + gender, data = DIFSim, k = 2, nrep = 1, > ## ## scores = "saturated", weights = w) > ## ## weights(m3w) > > ## ## refit > > ## ## plot > ## ## plot(m3) > ## ## histogram(m3) > ## ## m.nident <- raschmix(data = cbind(0,DIFSim$resp[,1:5],1,1,DIFSim$resp[,-(1:5)]), > ## ## scores = "saturated", k = 3, nrep = 1) > ## ## plot(m.nident) > ## ## plot(m.nident, pch = 19:21, cex = matrix(rep((1+1:23)/10, 3), ncol = 3)) > ## ## plot(m.nident, index = FALSE, component = 1:2) > ## ## plot(m.nident, index = TRUE, component = 1:2) > > > proc.time() user system elapsed 3.87 0.62 4.48