simsem / semTools

Useful tools for structural equation modeling
75 stars 36 forks source link

Problems with print method on OS El Captian #13

Closed sammerk closed 8 years ago

sammerk commented 8 years ago

Running the help-examples yields the error message:

Error in sprintf(" %10.3f", object@test[[1]]$stat) : no slot of name "test" for this object of class "lavaanStar"

on following session:

R version 3.2.2 (2015-08-14)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.1 (El Capitan)

locale:
[1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] multilevel_2.5 MASS_7.3-45    nlme_3.1-122   dplyr_0.4.3    mice_2.25      semTools_0.4-9 lavaan_0.5-20 

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.2      magrittr_1.5     MBESS_3.3.3      splines_3.2.2    pscl_1.4.9       mnormt_1.5-3     pbivnorm_0.6.0   lattice_0.20-33  R6_2.1.1        
[10] quadprog_1.5-5   minqa_1.2.4      tools_3.2.2      psychometric_2.2 nnet_7.3-11      parallel_3.2.2   grid_3.2.2       DBI_0.3.1        stargazer_5.2   
[19] lme4_1.1-10      survival_2.38-3  lazyeval_0.1.10  assertthat_0.1   Matrix_1.2-3     Amelia_1.7.3     nloptr_1.0.4     rpart_4.1-10     stats4_3.2.2    
[28] foreign_0.8-66  

On Windows and Ubuntu everythings works fine - thank´s for the very useful functions!

TDJorgensen commented 8 years ago

Please help us reproduce this problem by telling us which help-example(s) produce(s) this message. Judging from the "lavaanStar" class it looks like a problem with the missing-data functions (runMI and auxiliary).

Running example(auxiliary) works fine, but once you try to run a summary() of the fitted object, then the error appears. Hopefully that just means the summary() method needs to be updated. Specifically, it only seems to be the fit measures that are a problem (the fitMeasures and modindices functions, both of which are called by the summary method), but you can still inspect the parameterEstimates(fitaux).

Terry

sammerk commented 8 years ago

Hey Terry,

if I use the first example:

HS.model <- ' visual  =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed   =~ x7 + x8 + x9 '

HSMiss <- HolzingerSwineford1939[,paste("x", 1:9, sep="")]
randomMiss <- rbinom(prod(dim(HSMiss)), 1, 0.1)
randomMiss <- matrix(as.logical(randomMiss), nrow=nrow(HSMiss))
HSMiss[randomMiss] <- NA

out <- cfa.mi(HS.model, data=HSMiss, m = 3, chi="all")

everthing works fine.

But summary(out) or print(out)` results in

Error in sprintf(" %10.3f", object@test[[1]]$stat) : no slot of name "test" for this object of class "lavaanStar".

parameterEstimates(out) works, as you anticipated.

Cheers - and thank's again for your work! Samuel

TDJorgensen commented 8 years ago

Thanks for the additional information. Also, I forgot to mention in my previous discussion that I get the same result on Windows 7, so this has nothing to do with using Mac OS X.

schoam4 commented 8 years ago

Hmmm, there's something weird with the lavaanStar object and lavaan 0.5-20. Short version: everything works fine with lavaan 0.5-19.

Long version: lavaanStar isn't inheriting all the slots from lavaan it needs (in particular test and vcov, which provide fit statistics and standard errors).

> slotNames("lavaan")
 [1] "call"        "timing"      "Options"     "ParTable"    "pta"         "Data"       
 [7] "SampleStats" "Model"       "Cache"       "Fit"         "boot"        "optim"      
[13] "implied"     "vcov"        "test"        "external"   
> slotNames("lavaanStar")
 [1] "nullfit"     "imputed"     "auxNames"    "call"        "timing"      "Options"    
 [7] "ParTable"    "pta"         "Data"        "SampleStats" "Model"       "Cache"      
[13] "Fit"   

I'm working on diagnosing why this is happening...

psunthud commented 8 years ago

Please download the 0.4-11 version. This issue has been fixed.