Error in .convertData(df) : Currently only variables of class: numeric, integer, logical, or factorbut found additional class types including: labelled
data$fact.var <- factor(data$oldvar)data$newvar <- as.numeric(data$fact.var)
library(sjlabelled)data <- remove_all_labels(data)
Hi Michael,
I am currently utilizing the MplusAutomation package in R for statistical analysis and have found it to be an invaluable tool. However, I have encountered a couple of queries where I believe your expert guidance would be greatly beneficial.
input = mplusObject(TITLE = “test”,
VARIABLE =
"MISSING = all(99999);
CLUSTER = N_index;
LAGGED = sc(1);",
ANALYSIS =
"TYPE = TWOLEVEL RANDOM;
ESTIMATOR = BAYES;
PROCESSORS = 2;
FBITERATIONS = 50000;",
MODEL =
"%WITHIN%
fa2|d2 ON d1;
fa3|d3 ON d2;
fa4|d4 ON d3;
fa5|d5 ON d4;
fa6|d6 ON d5;
fa7|d7 ON d6;
sa | sc ON sc&1;
logfv2|d2;
logfv3|d3;
logfv4|d4;
logfv5|d5;
logfv6|d6;
logfv7|d7;
logsv | sc;
%BETWEEN%
d1-d7 sc fa2-fa7 sa logfv2-logfv7 logsv(var1-var22);
[d1-d7 sc fa2-fa7 sa logfv2-logfv7 logsv] (mu1-mu22);
",
MODELPRIORS =
"mu1-mu22 ~ N(0,100);
var1-var22 ~ IG(0.001,0.001);",
MODELCONSTRAINT =
"NEW (mu_dd);
mu_dd= MEAN(mu1 mu2 mu3 mu4 mu5 mu6 mu7);
NEW (mu_fa);
mu_fa= MEAN(mu9 mu10 mu11 mu12 mu13 mu14);
NEW (mu_logfv);
mu_logfv= MEAN(mu16 mu17 mu18 mu19 mu20 mu21);",
SAVEDATA = paste0("SAVE=FSCORES(200 1);FILE = savedata_",con,"_",re,".csv;"),
OUTPUT = "TECH1 TECH8;",
PLOT = "TYPE = PLOT3;
FACTORS = ALL;",#estimated factor scores for all between-level random effects be available for plotting
usevariables = c("N_index","sc",'d1', 'd2', 'd3', 'd4', 'd5', 'd6', 'd7'),
rdata = Y,
autov = TRUE)
res = mplusModeler(input,dataout = paste0(con,"/threelevel dsem_",con,'_',re,".dat"),modelout = paste0(con,"/threelevel dsem_",con,'_',re,".inp"), run = 1L)
Your expertise and insights into these matters would be greatly appreciated. I am looking forward to implementing these features correctly in my project.
Thank you very much for your time and assistance. I am eagerly awaiting your valuable response.