16
16
#
17
17
18
18
PLSSEMInternal <- function (jaspResults , dataset , options , ... ) {
19
+
19
20
jaspResults $ addCitation(" Rademaker ME, Schuberth F (2020). cSEM: Composite-Based Structural Equation Modeling. Package version: 0.4.0, https://m-e-rademaker.github.io/cSEM/." )
20
21
21
22
options <- .plsSemPrepOpts(options )
@@ -24,6 +25,9 @@ PLSSEMInternal <- function(jaspResults, dataset, options, ...) {
24
25
dataset <- .plsSemReadData(dataset , options )
25
26
ready <- .plsSemIsReady(dataset , options )
26
27
28
+ saveRDS(dataset , " ~/Downloads/dataset.rds" )
29
+ saveRDS(options , " ~/Downloads/options.rds" )
30
+
27
31
# Store in container
28
32
modelContainer <- .plsSemModelContainer(jaspResults )
29
33
@@ -146,7 +150,7 @@ checkCSemModel <- function(model, availableVars) {
146
150
147
151
# check for '~~'
148
152
if (grepl(" ~~" , vmodel )) {
149
- return (gettext(" Using '~~' is not supported. Try '~' instead" ))
153
+ return (gettext(" Using '~~' is not yet supported. Try '~' instead" ))
150
154
}
151
155
152
156
# if checks pass, return empty string
@@ -165,7 +169,7 @@ checkCSemModel <- function(model, availableVars) {
165
169
" structuralModelIgnored" , " innerWeightingScheme" , " errorCalculationMethod" ,
166
170
" bootstrapSamples" , " ciLevel" ,
167
171
" setSeed" , " seed" , " handlingOfInadmissibles" , " endogenousIndicatorPrediction" ,
168
- " kFolds" , " repetitions" , " benchmark" , " predictedScore " , " models" ))
172
+ " kFolds" , " repetitions" , " benchmark" , " models" ))
169
173
jaspResults [[" modelContainer" ]] <- modelContainer
170
174
}
171
175
@@ -257,7 +261,7 @@ checkCSemModel <- function(model, availableVars) {
257
261
}
258
262
259
263
results [[i ]] <- fit
260
-
264
+ saveRDS( fit , " ~/Downloads/fit.rds " )
261
265
}
262
266
263
267
# store results in model container
@@ -897,7 +901,7 @@ checkCSemModel <- function(model, availableVars) {
897
901
898
902
predict <- createJaspContainer(gettext(" Endogenous Indicator Prediction" ))
899
903
predict $ position <- 2
900
- predict $ dependOn(c(" endogenousIndicatorPrediction" , " models" , " kFolds" , " repetitions" , " benchmark" , " predictedScore " ))
904
+ predict $ dependOn(c(" endogenousIndicatorPrediction" , " models" , " kFolds" , " repetitions" , " benchmark" ))
901
905
modelContainer [[" predict" ]] <- predict
902
906
903
907
if (length(options [[" models" ]]) < 2 ) {
@@ -924,27 +928,12 @@ checkCSemModel <- function(model, availableVars) {
924
928
925
929
if (options [[" benchmark" ]] != " none" && options [[" benchmark" ]] != " all" ) {
926
930
benchmarks <- options [[" benchmark" ]]
927
- }
928
- else if (options [[" benchmark" ]] == " all" ) {
929
- benchmarks <- c(" lm" , " PLS-PM" , " GSCA" , " PCA" , " MAXVAR" )
930
- benchmarks <- benchmarks [benchmarks != " PLS-PM" ]
931
+ } else if (options [[" benchmark" ]] == " all" ) {
932
+ benchmarks <- c(" lm" , " GSCA" , " PCA" , " MAXVAR" )
931
933
} else {
932
934
benchmarks <- NULL
933
935
}
934
936
935
- if (options [[" benchmark" ]] != " none" && options [[" benchmark" ]] != " all" && benchmarks == " PLS-PM" ) {
936
- errormsg <- gettextf(" The target model uses the same weighting approach as the benchmark model, please choose another benchmark." )
937
- modelContainer $ setError(errormsg )
938
- modelContainer $ dependOn(" benchmark" )
939
- return ()
940
- }
941
- if (options [[" benchmark" ]] == " all" && options [[" predictedScore" ]]) {
942
- errormsg <- gettextf(" For the predicted indicator scores table(s), please select a single benchmark or 'none'." )
943
- modelContainer $ setError(errormsg )
944
- modelContainer $ dependOn(" benchmark" )
945
- return ()
946
- }
947
-
948
937
# Create metrics table
949
938
metricstab <- createJaspTable(gettext(" Prediction Metrics" ))
950
939
@@ -956,9 +945,7 @@ checkCSemModel <- function(model, availableVars) {
956
945
metricstab $ addColumnInfo(name = " mae" , title = gettext(" Target MAE" ), type = " number" )
957
946
958
947
if (" lm" %in% benchmarks )
959
- metricstab $ addColumnInfo(name = " maelm" , title = gettext(" Linear model MAE" ), type = " number" )
960
- if (" PLS-PM" %in% benchmarks )
961
- metricstab $ addColumnInfo(name = " maePLS-PM" , title = gettext(" PLS-PM MAE" ), type = " number" )
948
+ metricstab $ addColumnInfo(name = " maelm" , title = gettext(" LM MAE" ), type = " number" )
962
949
if (" GSCA" %in% benchmarks )
963
950
metricstab $ addColumnInfo(name = " maeGSCA" , title = gettext(" GSCA MAE" ), type = " number" )
964
951
if (" PCA" %in% benchmarks )
@@ -969,9 +956,7 @@ checkCSemModel <- function(model, availableVars) {
969
956
metricstab $ addColumnInfo(name = " rmse" , title = gettext(" Target RMSE" ), type = " number" )
970
957
971
958
if (" lm" %in% benchmarks )
972
- metricstab $ addColumnInfo(name = " rmselm" , title = gettext(" Linear model RMSE" ), type = " number" )
973
- if (" PLS-PM" %in% benchmarks )
974
- metricstab $ addColumnInfo(name = " rmsePLS-PM" , title = gettext(" PLS-PM RMSE" ), type = " number" )
959
+ metricstab $ addColumnInfo(name = " rmselm" , title = gettext(" LM RMSE" ), type = " number" )
975
960
if (" GSCA" %in% benchmarks )
976
961
metricstab $ addColumnInfo(name = " rmseGSCA" , title = gettext(" GSCA RMSE" ), type = " number" )
977
962
if (" PCA" %in% benchmarks )
@@ -1003,7 +988,7 @@ checkCSemModel <- function(model, availableVars) {
1003
988
return ()
1004
989
}
1005
990
progressbarTick()
1006
- prediction_list [i ] <- prediction
991
+ prediction_list [[ benchmarks [ i ]] ] <- prediction
1007
992
}
1008
993
} else if (options [[" benchmark" ]] == " none" ) {
1009
994
prediction <- try(cSEM :: predict(fit , .handle_inadmissibles = " ignore" , .cv_folds = options [[" kFolds" ]], .r = options [[" repetitions" ]]))
@@ -1063,7 +1048,7 @@ checkCSemModel <- function(model, availableVars) {
1063
1048
metricstab [[paste0(" rmse" , benchmarks )]] <- unlist(lapply(prediction , function (x ) x [[" Prediction_metrics" ]][[" RMSE_benchmark" ]]))
1064
1049
}
1065
1050
1066
- if (options [[" benchmark" ]] == " all" ) {
1051
+ if (options [[" benchmark" ]] == " all" ) {
1067
1052
for (i in seq_along(benchmarks )) {
1068
1053
prediction <- prediction_list [[benchmarks [[i ]]]]
1069
1054
metricstab [[paste0(" mae" , benchmarks [[i ]])]] <- unlist(lapply(prediction , function (x ) x [[" Prediction_metrics" ]][[" MAE_benchmark" ]]))
0 commit comments