Dear Rlist members, We are trying to run a SEM with your package. Unfortunaley while running our code two error messages popped up. For the life of us we could not figure out how to solve these errors . We are hoping very much that somebody can help us: Why do we get these error messages? We built our model structure using an example from the piecewiseSEM package and we double checked the that we do not have any "NAs" in our data set. Thanks a ton!
Error1: Error in data.frame(..., check.names = FALSE) : arguments imply different numbers of rows: 166, 0 Error2: (we ran the model with a smaller,simpler SEM) Error in cbind(ret, isSig(ret[, 5])) : object 'ret' not found Below is our code and the data (as "dput()") # dataCode: (see dput(dataCode) at the very end library (glmmTMB) library(lme4) library(DHARMa)#check for Overdispersion library(piecewiseSEM) library(lavaan) str(dataCode) summary(dataCode) #define factors dataCode$Year<-factor(dataCode$Year) #relevel(dataCode$Year,ref="2019") dataCode$Stand<-as.factor(dataCode$Stand) dataCode$TreeNo <-as.factor(dataCode$TreeNo) dataCode$Drought <-as.factor(dataCode$Drought) #relevel(dataCode$Drought,ref="0") dataCode$Stratum <-as.factor(dataCode$Stratum) levels(dataCode$Stratum) <- list(lower = "shade", upper = "sun") #relevel(dataCode$Stratum,ref="sun") dataCode$Location <-as.factor(dataCode$Location) dataCode$Tree.ID <-as.factor(dataCode$Tree.ID) # Models for SEM mod1x<-lmer(N_pc~StratumDrought+YearDrought+(1|Tree.ID),data) #Check assumptions simulationOutput <- simulateResiduals(fittedModel = mod1x) plot(simulationOutput) summary(mod1x) mod2x<-lmer(log(Fiber)~StratumDrought+YearDrought+(1|Tree.ID),data) #Check assumptions simulationOutput <- simulateResiduals(fittedModel = mod2x) plot(simulationOutput) summary(mod2x) mod3x<-lmer(Lignin~StratumDrought+YearDrought+(1|Tree.ID),data) #Check assumptions simulationOutput <- simulateResiduals(fittedModel = mod3x) plot(simulationOutput) summary(mod3x) mod11a<-glmer(prop_suck~N_pc+(1|Tree.ID), data=data, family=binomial(link = "logit"), weights=weight_suck) mod12a<-glmmTMB(prop_suck~Fiber+(1|Tree.ID), data=data, family=betabinomial(link = "logit"), weights=weight_suck) mod13a<-glmmTMB(prop_suck~Lignin+(1|Tree.ID), data=data, family=betabinomial(link = "logit"), weights=weight_suck) newlist2 = list( mod1x, mod2x, mod3x, mod11a, mod12a, mod13a) model<-as.psem(newlist2)#Error1:-------------------! #We then ran a model with a simpler model structure, to double check if the error occured due to the model structure #Error 1 did not appear anymore. However, error 2 popped up-------------! modlist = list( mod1x, mod11a) model<-as.psem(modlist) summary(model) #Error1: #DATA dput(dataCode) structure(list(Tree.ID = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L, 6L, 6L, 7L, 7L, 8L, 8L, 9L, 9L, 10L, 10L, 11L, 11L, 12L, 12L, 13L, 13L, 14L, 14L, 15L, 15L, 16L, 16L, 17L, 17L, 18L, 18L, 19L, 19L, 20L, 20L, 21L, 21L, 22L, 22L, 23L, 23L, 24L, 24L, 25L, 25L, 26L, 26L, 27L, 27L, 28L, 28L, 29L, 29L, 30L, 30L, 31L, 31L, 32L, 32L, 33L, 33L, 34L, 34L, 35L, 35L, 36L, 36L, 37L, 37L, 38L, 38L, 39L, 39L, 40L, 40L, 41L, 41L, 42L, 42L, 43L, 43L, 44L, 44L, 45L, 45L, 46L, 46L, 47L, 47L, 48L, 48L, 1L, 1L, 2L, 2L, 3L, 3L, 10L, 10L, 11L, 11L, 12L, 12L, 13L, 13L, 14L, 14L, 15L, 15L, 16L, 16L, 17L, 17L, 18L, 18L, 19L, 19L, 21L, 21L, 22L, 22L, 23L, 23L, 24L, 24L, 25L, 25L, 26L, 26L, 27L, 27L, 28L, 28L, 29L, 29L, 30L, 30L, 31L, 31L, 32L, 32L, 33L, 33L, 37L, 37L, 38L, 38L, 39L, 39L, 43L, 43L, 44L, 44L, 45L, 45L, 46L, 46L, 47L, 47L, 48L, 48L), .Label = c("102_6", "102_7", "102_8", "105_1", "105_2", "105_4", "111_7", "111_8", "111_9", "113_2", "113_4", "113_5", "114_7", "114_8", "114_9", "116_6", "116_7", "116_9", "122_3", "122_4", "122_5", "132_3", "132_4", "132_5", "242_2", "242_4", "242_5", "243_1", "243_2", "243_4", "245_1", "245_2", "245_5", "246_1", "246_2", "246_3", "251_10", "251_8", "251_9", "253_7", "253_8", "253_9", "254_6", "254_7", "254_8", "267_10", "267_6", "267_8"), class = "factor"), Year = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("1", "2"), class = "factor"), Drought = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,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, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c("lower", "upper"), class = "factor"), prop_suck = c(0, 0, 0.04, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.08, 0.02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.08, 0, 0, 0, 0.06, 0, 0, 0, 0, 0, 0, 0, 0.02, 0, 0, 0, 0.12, 0, 0.12, 0.04, 0.1, 0, 0.4, 0.7, 0.08, 0, 0.16, 0, 0, 0, 0, 0, 0, 0.02, 0, 0, 0, 0.16, 0.04, 0.04, 0, 0.04, 0.96, 0, 0, 0, 0, 0.06, 0.44, 0.46, 0.28, 0.04, 0, 0.02, 0.02, 0, 0, 0, 0.54, 0.5, 0.32, 0.26, 0.62, 0.36, 0.62, 0.04, 0.5, 0.32, 0.72, 0.42, 0.16, 0.46, 0.26, 0.22, 0.14, 0, 0.7, 0.14, 0.34, 0.08, 0.8, 0, 0.96, 0.34, 0.32, 0.2, 0.68, 0.12, 0.92, 0.14, 0.52, 0.24, 0.48, 0.54, 0.62, 0.5, 0.68, 0.42, 0.88, 0.46, 0.8, 0.6, 0.5, 0.36, 0.7, 0.2, 0.12, 0.2, 0.58, 0.1, 0.48, 0.32, 0.38, 0.22, 0.42, 0.2, 0.36, 0.36, 0.84, 0.66, 0.32, 0.62, 0.32, 0.76, 0.74, 0.56, 0.18, 0.7), N_pc = c(2.27, 2.37, 2.39, 1.9, 2.08, 2.65, 2.25, 2.04, 2.04, 1.81, 3.03, 2.9, 2.11, 2.26, 2.38, 2.51, 2, 2.31, 2.71, 2.02, 2.37, 2.04, 1.95, 2.21, 2.31, 2.39, 2.24, 2.2, 1.94, 2.12, 2.27, 2.15, 2.5, 2.36, 2.1, 2.29, 2.55, 2.39, 2.96, 2.26, 2.75, 2.71, 2.81, 2.79, 2.68, 2.51, 2.17, 2.18, 2.41, 2.19, 2.48, 2.19, 2.42, 1.82, 1.83, 1.65, 1.91, 2.04, 1.96, 1.88, 2.59, 1.85, 2.32, 1.95, 2.09, 1.97, 2.65, 1.8, 2.2, 2.26, 2.32, 1.5, 2.16, 2.37, 2.13, 2.54, 2.19, 1.97, 1.78, 2.29, 1.64, 1.67, 1.98, 1.79, 1.77, 2.03, 1.68, 2.08, 2.145, 2.08, 1.8, 1.99, 1.99, 2.07, 1.98, 2.41, 2.83, 2.83, 2.91, 2.61, 2.73, 2.54, 2.87, 1.91, 2.84, 2.74, 2.87, 2.6, 2.12, 2.64, 2.46, 1.83, 2.06, 2.01, 2.77, 2.41, 2.74, 2.83, 2.51, 2.23, 2.79, 2.66, 2.44, 2.26, 2.85, 2.39, 2.52, 2.13, 2.63, 2, 2.43, 2.36, 2.98, 2.28, 2.12, 2.2, 2.54, 1.28, 2.57, 2.17, 2.32, 2.41, 3.11, 2.591, 2.77, 2.53, 2.67, 2.45, 2.5, 2.52, 2.9, 3.03, 2.83, 2.52, 2.57, 2.62, 2.82, 2.62, 2.98, 3.01, 2.33, 2.11, 2.68, 2.74, 2.53, 2.43), weight_suck = c(50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L), Fiber = c(34.40884091, 35.2306534, 42.52377866, 42.6239323, 41.37861255, 39.60850525, 40.77050193, 43.93561888, 39.85530862, 47.96389221, 33.0164353, 30.40923171, 35.80926768, 38.81499295, 39.78981471, 37.98513805, 37.573016, 39.75442555, 43.30493722, 39.75062718, 42.44068598, 35.17589695, 35.56906323, 37.34316461, 40.01927247, 39.99513562, 36.10434999, 31.57573919, 37.76346099, 37.01815172, 35.59629643, 33.81374455, 37.7827112, 41.28445751, 44.78743608, 34.6394122, 36.30284612, 34.97437449, 41.00523545, 30.91747143, 32.55332568, 32.79375305, 37.51461304, 32.62951938, 40.22559027, 35.43271959, 39.22368591, 34.32029979, 36.41313697, 36.69822326, 37.82870726, 37.85527277, 33.87219095, 36.98176526, 38.04943022, 33.45063417, 36.48627741, 34.46249903, 40.17607643, 36.77713573, 37.98619139, 35.84260289, 37.21843053, 34.84469437, 34.85470551, 33.62314136, 35.04788627, 30.45543443, 43.14168551, 32.23039161, 37.60287057, 34.1427031, 36.52037605, 37.12821519, 43.96781779, 33.21707461, 43.03781432, 38.29479565, 40.07726219, 37.64961992, 48.82421591, 39.26134049, 37.62558769, 36.19289482, 41.39539765, 38.87860666, 36.05830446, 32.07757032, 42.788655, 33.86701205, 38.23211694, 37.89539959, 40.83433837, 38.98175173, 42.83170351, 32.28967624, 33.40239455, 30.92484799, 41.56156442, 34.52930045, 37.75300976, 35.11156393, 39.77687654, 37.98805055, 41.70620266, 31.89415684, 37.68184859, 34.08114509, 34.06411083, 32.23348721, 35.77634719, 21.0576573, 37.76348306, 33.53117231, 40.82264211, 31.19388514, 40.52910082, 27.5031154, 44.50618538, 34.4669349, 30.43628015, 29.89229346, 32.01075647, 35.07254143, 36.57868878, 28.81559417, 36.08462737, 32.86246536, 39.9152505, 36.25423072, 33.51569525, 34.1055226, 38.99118341, 34.53641033, 33.31288766, 31.55618034, 39.31931333, 33.72025274, 34.7083208, 26.84760505, 39.14884466, 34.79548574, 32.81360389, 27.78493879, 30.66829851, 31.03727751, 35.11616534, 29.20690552, 37.48964989, 39.94816985, 41.784186, 36.40317336, 38.77327649, 33.47088406, 35.79855367, 32.94104157, 37.22816497, 29.32884218, 41.30883178, 28.85842064, 39.21708069, 29.93973518, 33.68385156, 25.26360465, 40.07343771, 31.24653541 ), Lignin = c(15.77477865, 16.42526338, 17.81644946, 20.06733454, 17.33068939, 14.46313636, 19.26461698, 22.46710162, 18.35008435, 18.43243391, 13.03248943, 11.61623759, 15.40895691, 16.9786809, 16.54312915, 18.33763105, 12.25320976, 16.10339902, 16.68427585, 17.37699268, 11.72959086, 17.82961819, 10.33102761, 8.329309218, 16.75329644, 16.79263461, 14.56578061, 15.69875657, 9.275559568, 16.18115984, 13.28899644, 14.52231091, 14.33797056, 19.388317, 14.28128214, 12.86508109, 16.54174245, 16.88950337, 16.45236853, 7.719036205, 13.6909977, 11.48255674, 15.13737491, 15.3591499, 16.54946312, 16.14769987, 13.06144297, 11.9173863, 13.43299545, 16.00143957, 17.2118779, 18.19980232, 10.99738867, 13.63569839, 15.48144654, 16.1216259, 16.15568311, 17.6101268, 17.30451969, 14.02253261, 15.43141658, 16.181513, 17.15827242, 17.52861195, 12.35996713, 15.49034533, 13.97079366, 13.28841472, 17.82642197, 14.89135477, 15.27588696, 16.19873246, 11.99168197, 17.9882092, 18.70442548, 16.92756747, 17.30466149, 16.84557327, 16.57039627, 17.50814734, 21.76822852, 20.26882409, 9.727735965, 15.00439034, 17.12361186, 16.14717619, 12.68400834, 15.64995633, 17.8633547, 12.42028546, 14.25760982, 17.83796088, 18.18472772, 19.53135651, 18.08016466, 14.49582092, 13.52200059, 13.59905485, 18.16177538, 16.35014138, 14.96662393, 17.79704702, 14.62402094, 21.42942615, 16.86764575, 13.75565413, 14.82599948, 15.76083246, 11.45566254, 13.43780268, 12.93398942, 13.48983266, 15.65273017, 15.51102512, 16.26246545, 13.86332043, 16.06911693, 12.6946718, 18.10567384, 16.67871224, 10.8869382, 15.31810574, 14.50440655, 18.1268646, 14.02630853, 9.166241719, 14.59336183, 16.33293006, 16.055571, 18.51528605, 11.34765726, 15.06734566, 16.87036405, 17.46982479, 15.66135144, 13.71222274, 16.19165545, 16.624473, 15.57975641, 13.00605673, 14.73386658, 15.76925648, 14.04065352, 12.18372012, 12.05766404, 14.54563609, 14.26939499, 14.72744808, 14.11437465, 18.4789298, 18.01551264, 16.10259417, 14.02537363, 14.58450423, 11.04102835, 13.40957054, 16.8431013, 9.535932181, 16.83859843, 13.05088673, 15.5745046, 14.46076877, 11.98007904, 11.38534032, 15.20342847, 11.4316122)), class = "data.frame", row.names = c(NA, -166L)) [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.