Error: no slot of name "control" for this object of class "lavModel"

641 views
Skip to first unread message

Garett Howardson

unread,
Oct 30, 2017, 9:30:38 AM10/30/17
to lavaan
Hello, 

I've fit a robust lavaan::sem model using estimator = "mlm" with no issues. However, I would now like to do a series of bootstraps using these results, but I want to perform them on my server so I don't consume resources on my local machine. When attempting to do so, I keep running into the same error below: 

no slot of name "control" for this object of class "lavModel"

I've attempted this a few different ways but the general process is this:


  1. Fit lavaan model on local machine
    1. lavaan version 0.5.23.1097
  2. Save and export fit object as either .rds or .RData (error happens for both)
  3. Upload .rds or .Rdata file to server
  4. Log into server and spin up R
  5. Change working directory to .rds or .Rdata location
  6. Load saved fit object using either readRDS() or load() functions (same error for both)
    1. fit <- readRDS("file-loc.rds")
    2. fit <- load("file-loc.Rdata")
  7. After the actual file loads successfully into the R environment, load lavaan
    1. Version 0.5.22
  8. Attempt to call summary function for lavaan fit object
    1. summary(fit)
  9. lavaan returns error below: 

    1.   Error in short.summary(object) : no slot of name "control" for this object of class "lavModel"

I have also included at times an .r source file including the model syntax with models of the same name as those used in the .rds or .RData files but I receive the same error. I think I have identified the source of the error but I'm not really understanding why the error occurs. When trying to view the str(fit) of the sever .rds file (results below), the lavaan fit object never makes it to the @Model slot because it bombs out at the @SampleStats slot giving error: 

@ SampleStats:Error in FUN(X[[i]], ...) :
no slot of name "CAT" for this object of class "lavSampleStats"


The full str(fit) output is below: 

str(fit)


Formal class 'lavaan' [package "lavaan"] with 16 slots


  ..@ call       : language lavaan::lavaan(model = epm.sem.mod.d, data = epm.tiny.dat, estimator = "MLM",      model.type = "sem", int.ov.free = TRUE, int.lv.free = FALSE, auto.fix.first = TRUE,  ...


  ..@ timing     :List of 10


  .. ..$ InitOptions: Named num 0.442


  .. .. ..- attr(*, "names")= chr "elapsed"


  .. ..$ InitData   : Named num 0.335


  .. .. ..- attr(*, "names")= chr "elapsed"


  .. ..$ ParTable   : Named num 0.007


  .. .. ..- attr(*, "names")= chr "elapsed"


  .. ..$ Sample     : Named num 0.621


  .. .. ..- attr(*, "names")= chr "elapsed"


  .. ..$ Start      : Named num 0.003


  .. .. ..- attr(*, "names")= chr "elapsed"


  .. ..$ Model      : Named num 0.007


  .. .. ..- attr(*, "names")= chr "elapsed"


  .. ..$ Estimate   : Named num 0.218


  .. .. ..- attr(*, "names")= chr "elapsed"


  .. ..$ VCOV       : Named num 1.62


  .. .. ..- attr(*, "names")= chr "elapsed"


  .. ..$ TEST       : Named num 8.49


  .. .. ..- attr(*, "names")= chr "elapsed"


  .. ..$ total      : Named num 11.8


  .. .. ..- attr(*, "names")= chr "elapsed"


  ..@ Options    :List of 59


  .. ..$ model.type            : chr "sem"


  .. ..$ mimic                 : chr "lavaan"


  .. ..$ meanstructure         : logi TRUE


  .. ..$ int.ov.free           : logi TRUE


  .. ..$ int.lv.free           : logi FALSE


  .. ..$ conditional.x         : logi FALSE


  .. ..$ fixed.x               : logi FALSE


  .. ..$ orthogonal            : logi FALSE


  .. ..$ std.lv                : logi FALSE


  .. ..$ parameterization      : chr "delta"


  .. ..$ auto.fix.first        : logi TRUE


  .. ..$ auto.fix.single       : logi TRUE


  .. ..$ auto.var              : logi TRUE


  .. ..$ auto.cov.lv.x         : logi TRUE


  .. ..$ auto.cov.y            : logi TRUE


  .. ..$ auto.th               : logi TRUE


  .. ..$ auto.delta            : logi TRUE


  .. ..$ std.ov                : logi FALSE


  .. ..$ missing               : chr "listwise"


  .. ..$ sample.cov.rescale    : logi TRUE


  .. ..$ ridge                 : num 1e-05


  .. ..$ group.label           : NULL


  .. ..$ group.equal           : chr(0)


  .. ..$ group.partial         : chr(0)


  .. ..$ group.w.free          : logi FALSE


  .. ..$ cluster               : NULL


  .. ..$ level.label           : NULL


  .. ..$ estimator             : chr "ML"


  .. ..$ likelihood            : chr "normal"


  .. ..$ link                  : chr "default"


  .. ..$ representation        : chr "LISREL"


  .. ..$ do.fit                : logi TRUE


  .. ..$ information           : chr "expected"


  .. ..$ h1.information        : chr "structured"


  .. ..$ se                    : chr "robust.sem"


  .. ..$ test                  : chr "satorra.bentler"


  .. ..$ bootstrap             : int 1000


  .. ..$ observed.information  : chr "hessian"


  .. ..$ control               : list()


  .. ..$ optim.method          : chr "nlminb"


  .. ..$ optim.method.cor      : chr "nlminb"


  .. ..$ optim.force.converged : logi FALSE


  .. ..$ optim.gradient        : chr "analytic"


  .. ..$ optim.init_nelder_mead: logi FALSE


  .. ..$ integration.ngh       : int 21


  .. ..$ parallel              : chr "no"


  .. ..$ ncpus                 : int 1


  .. ..$ cl                    : NULL


  .. ..$ iseed                 : NULL


  .. ..$ zero.add              : num [1:2] 0.5 0


  .. ..$ zero.keep.margins     : logi TRUE


  .. ..$ zero.cell.warn        : logi TRUE


  .. ..$ start                 : chr "default"


  .. ..$ check                 : chr [1:2] "start" "post"


  .. ..$ verbose               : logi FALSE


  .. ..$ warn                  : logi TRUE


  .. ..$ debug                 : logi FALSE


  .. ..$ categorical           : logi FALSE


  .. ..$ partrace              : logi FALSE


  ..@ ParTable   :List of 15


  .. ..$ id    : int [1:189] 1 2 3 4 5 6 7 8 9 10 ...


  .. ..$ lhs   : chr [1:189] "TR" "TR" "TR" "TR" ...


  .. ..$ op    : chr [1:189] "=~" "=~" "=~" "=~" ...


  .. ..$ rhs   : chr [1:189] "TReact1" "TReact6" "TReact9" "TReact10" ...


  .. ..$ user  : int [1:189] 1 1 1 1 1 1 1 1 1 1 ...


  .. ..$ block : int [1:189] 1 1 1 1 1 1 1 1 1 1 ...


  .. ..$ group : int [1:189] 1 1 1 1 1 1 1 1 1 1 ...


  .. ..$ free  : int [1:189] 0 1 2 3 4 5 0 6 7 8 ...


  .. ..$ ustart: num [1:189] 1 NA NA NA NA NA 1 NA NA NA ...


  .. ..$ exo   : int [1:189] 0 0 0 0 0 0 0 0 0 0 ...


  .. ..$ label : chr [1:189] "" "" "" "" ...


  .. ..$ plabel: chr [1:189] ".p1." ".p2." ".p3." ".p4." ...


  .. ..$ start : num [1:189] 1 0.761 0.718 0.872 0.748 ...


  .. ..$ est   : num [1:189] 1 0.789 0.778 0.867 0.725 ...


  .. ..$ se    : num [1:189] 0 0.0885 0.0775 0.0826 0.1004 ...


  ..@ pta        :List of 8


  .. ..$ vnames        :List of 22


  .. .. ..$ ov            :List of 1


  .. .. .. ..$ : chr [1:49] "TReact1" "TReact6" "TReact9" "TReact10" ...


  .. .. ..$ ov.x          :List of 1


  .. .. .. ..$ : chr(0)


  .. .. ..$ ov.nox        :List of 1


  .. .. .. ..$ : chr [1:49] "TReact1" "TReact6" "TReact9" "TReact10" ...


  .. .. ..$ ov.model      :List of 1


  .. .. .. ..$ : chr [1:49] "TReact1" "TReact6" "TReact9" "TReact10" ...


  .. .. ..$ ov.y          :List of 1


  .. .. .. ..$ : chr(0)


  .. .. ..$ ov.num        :List of 1


  .. .. .. ..$ : chr [1:49] "TReact1" "TReact6" "TReact9" "TReact10" ...


  .. .. ..$ ov.ord        :List of 1


  .. .. .. ..$ : chr(0)


  .. .. ..$ ov.ind        :List of 1


  .. .. .. ..$ : chr [1:49] "TReact1" "TReact6" "TReact9" "TReact10" ...


  .. .. ..$ ov.orphan     :List of 1


  .. .. .. ..$ : chr(0)


  .. .. ..$ ov.interaction:List of 1


  .. .. .. ..$ : chr(0)


  .. .. ..$ th            :List of 1


  .. .. .. ..$ : chr(0)


  .. .. ..$ th.mean       :List of 1


  .. .. .. ..$ : chr [1:49] "TReact1" "TReact6" "TReact9" "TReact10" ...


  .. .. ..$ lv            :List of 1


  .. .. .. ..$ : chr [1:8] "TR" "IPVC" "ANGR" "NCOG" ...


  .. .. ..$ lv.regular    :List of 1


  .. .. .. ..$ : chr [1:8] "TR" "IPVC" "ANGR" "NCOG" ...


  .. .. ..$ lv.formative  :List of 1


  .. .. .. ..$ : chr(0)


  .. .. ..$ lv.x          :List of 1


  .. .. .. ..$ : chr "TR"


  .. .. ..$ lv.y          :List of 1


  .. .. .. ..$ : chr [1:4] "CWBI" "CWBO" "OCBI" "OCBO"


  .. .. ..$ lv.nox        :List of 1


  .. .. .. ..$ : chr [1:7] "IPVC" "ANGR" "NCOG" "CWBI" ...


  .. .. ..$ lv.nonnormal  :List of 1


  .. .. .. ..$ : chr(0)


  .. .. ..$ lv.interaction:List of 1


  .. .. .. ..$ : chr(0)


  .. .. ..$ eqs.y         :List of 1


  .. .. .. ..$ : chr [1:7] "IPVC" "ANGR" "NCOG" "OCBI" ...


  .. .. ..$ eqs.x         :List of 1


  .. .. .. ..$ : chr [1:4] "TR" "IPVC" "NCOG" "ANGR"


  .. ..$ vidx          :List of 22


  .. .. ..$ ov            :List of 1


  .. .. .. ..$ : int [1:49] 1 2 3 4 5 6 7 8 9 10 ...


  .. .. ..$ ov.x          :List of 1


  .. .. .. ..$ : int(0)


  .. .. ..$ ov.nox        :List of 1


  .. .. .. ..$ : int [1:49] 1 2 3 4 5 6 7 8 9 10 ...


  .. .. ..$ ov.model      :List of 1


  .. .. .. ..$ : int [1:49] 1 2 3 4 5 6 7 8 9 10 ...


  .. .. ..$ ov.y          :List of 1


  .. .. .. ..$ : int(0)


  .. .. ..$ ov.num        :List of 1


  .. .. .. ..$ : int [1:49] 1 2 3 4 5 6 7 8 9 10 ...


  .. .. ..$ ov.ord        :List of 1


  .. .. .. ..$ : int(0)


  .. .. ..$ ov.ind        :List of 1


  .. .. .. ..$ : int [1:49] 1 2 3 4 5 6 7 8 9 10 ...


  .. .. ..$ ov.orphan     :List of 1


  .. .. .. ..$ : int(0)


  .. .. ..$ ov.interaction:List of 1


  .. .. .. ..$ : int(0)


  .. .. ..$ th            :List of 1


  .. .. .. ..$ : int(0)


  .. .. ..$ th.mean       :List of 1


  .. .. .. ..$ : int [1:49] 1 2 3 4 5 6 7 8 9 10 ...


  .. .. ..$ lv            :List of 1


  .. .. .. ..$ : int [1:8] 1 2 3 4 5 6 7 8


  .. .. ..$ lv.regular    :List of 1


  .. .. .. ..$ : int [1:8] 1 2 3 4 5 6 7 8


  .. .. ..$ lv.formative  :List of 1


  .. .. .. ..$ : int(0)


  .. .. ..$ lv.x          :List of 1


  .. .. .. ..$ : int 1


  .. .. ..$ lv.y          :List of 1


  .. .. .. ..$ : int [1:4] 5 6 7 8


  .. .. ..$ lv.nox        :List of 1


  .. .. .. ..$ : int [1:7] 2 3 4 5 6 7 8


  .. .. ..$ lv.nonnormal  :List of 1


  .. .. .. ..$ : int(0)


  .. .. ..$ lv.interaction:List of 1


  .. .. .. ..$ : int(0)


  .. .. ..$ eqs.y         :List of 1


  .. .. .. ..$ : int(0)


  .. .. ..$ eqs.x         :List of 1


  .. .. .. ..$ : int(0)


  .. ..$ nblocks       : int 1


  .. ..$ ngroups       : int 1


  .. ..$ nlevels       : int 1


  .. ..$ nvar          :List of 1


  .. .. ..$ : int 49


  .. ..$ nfac          :List of 1


  .. .. ..$ : int 8


  .. ..$ nfac.nonnormal:List of 1


  .. .. ..$ : int 0


  ..@ Data       :Formal class 'lavData' [package "lavaan"] with 16 slots


  .. .. ..@ data.type  : chr "full"


  .. .. ..@ ngroups    : int 1


  .. .. ..@ group      : chr(0)


  .. .. ..@ group.label: chr(0)


  .. .. ..@ std.ov     : logi FALSE


  .. .. ..@ nobs       :List of 1


  .. .. .. ..$ : int 231


  .. .. ..@ norig      :List of 1


  .. .. .. ..$ : int 231


  .. .. ..@ ov.names   :List of 1


  .. .. .. ..$ : chr [1:49] "TReact1" "TReact6" "TReact9" "TReact10" ...


  .. .. ..@ ov.names.x :List of 1


  .. .. .. ..$ : chr(0)


  .. .. ..@ ov         :List of 10


  .. .. .. ..$ name: chr [1:49] "TReact1" "TReact6" "TReact9" "TReact10" ...


  .. .. .. ..$ idx : int [1:49] 43 44 45 46 47 48 1 2 3 4 ...


  .. .. .. ..$ nobs: int [1:49] 231 231 231 231 231 231 231 231 231 231 ...


  .. .. .. ..$ type: chr [1:49] "numeric" "numeric" "numeric" "numeric" ...


  .. .. .. ..$ exo : int [1:49] 0 0 0 0 0 0 0 0 0 0 ...


  .. .. .. ..$ user: int [1:49] 0 0 0 0 0 0 0 0 0 0 ...


  .. .. .. ..$ mean: num [1:49] 2.52 3.13 2.13 2.75 2.77 ...


  .. .. .. ..$ var : num [1:49] 1.312 1.293 0.896 1.058 1.204 ...


  .. .. .. ..$ nlev: int [1:49] 0 0 0 0 0 0 0 0 0 0 ...


  .. .. .. ..$ lnam: chr [1:49] "" "" "" "" ...


  .. .. ..@ case.idx   :List of 1


  .. .. .. ..$ : int [1:231] 1 2 3 4 5 6 7 8 9 10 ...


  .. .. ..@ missing    : chr "listwise"


  .. .. ..@ Mp         :List of 1


  .. .. .. ..$ : NULL


  .. .. ..@ Rp         :List of 1


  .. .. .. ..$ : NULL


  .. .. ..@ eXo        :List of 1


  .. .. .. ..$ : NULL


  .. .. ..@ X          :List of 1


  .. .. .. ..$ : num [1:231, 1:49] 4 2 1 4 4 1 1 4 2 4 ...


  ..@ SampleStats:Error in FUN(X[[i]], ...) :


  no slot of name "CAT" for this object of class "lavSampleStats"



I would greatly welcome any thoughts you have. This process is one I'd like to be repeat / automate and so I'd like to understand some of the finer  technical aspects of lavaan across OS / R versions. Below is the version information for R on both the server and local machine. Other than the obvious differences in OS, the versions of R and lavaan seem comparable so there aren't major differences between local machine and server. 


Server version info: 


platform       x86_64-pc-linux-gnu         

arch           x86_64                      

os             linux-gnu                   

system         x86_64, linux-gnu           

status                                     

major          3                           

minor          2.3                         

year           2015                        

month          12                          

day            10                          

svn rev        69752                       

language       R                           

version.string R version 3.2.3 (2015-12-10)

nickname       Wooden Christmas-Tree  


Local machine version info: 


platform       x86_64-apple-darwin15.6.0   

arch           x86_64                      

os             darwin15.6.0                

system         x86_64, darwin15.6.0        

status                                     

major          3                           

minor          4.1                         

year           2017                        

month          06                          

day            30                          

svn rev        72865                       

language       R                           

version.string R version 3.4.1 (2017-06-30)

nickname       Single Candle               


 

Terrence Jorgensen

unread,
Oct 30, 2017, 11:51:18 PM10/30/17
to lavaan
I would now like to do a series of bootstraps using these results, but I want to perform them on my server so I don't consume resources on my local machine.

Why don't you fit the model on the server instead of saving the fit object from your local machine?  Fitting the model is not the time-consuming part, it is the bootstrapping that takes up time.  So start the process from scratch on the server to avoid issues like this.

When attempting to do so, I keep running into the same error below: 

no slot of name "control" for this object of class "lavModel"


Is this an error, or is it just a warning?  This is probably a version issue.  You are using 0.5-23, but your server is using 0.5-22.  lavaan has had some internal structural changes, even between these versions.  
 

I've attempted this a few different ways but the general process is this:


  1. Fit lavaan model on local machine
    1. lavaan version 0.5.23.1097
  2. Save and export fit object as either .rds or .RData (error happens for both)
  3. Upload .rds or .Rdata file to server
  4. Log into server and spin up R
  5. Change working directory to .rds or .Rdata location
  6. Load saved fit object using either readRDS() or load() functions (same error for both)
    1. fit <- readRDS("file-loc.rds")
    2. fit <- load("file-loc.Rdata")
  1. After the actual file loads successfully into the R environment, load lavaan
    1. Version 0.5.22
At the very least, you could avoid the error or warning by loading lavaan first, so that it recognizes the lavaan-class object you are loading into  your workspace.  But again, you shouldn't waste your time with steps 1, 2, 3, 5, 6.  Just log into  your server, then change the directory to where your data are located, import the data into R and fit your model.  Then you can bootstrap easily. 

Terrence D. Jorgensen
Postdoctoral Researcher, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam

Garett Howardson

unread,
Oct 31, 2017, 6:30:23 AM10/31/17
to lavaan
Hi Terry, 

Thanks for your response! I've interlaced responses below. 


On Monday, October 30, 2017 at 11:51:18 PM UTC-4, Terrence Jorgensen wrote:
I would now like to do a series of bootstraps using these results, but I want to perform them on my server so I don't consume resources on my local machine.

Why don't you fit the model on the server instead of saving the fit object from your local machine?  Fitting the model is not the time-consuming part, it is the bootstrapping that takes up time.  So start the process from scratch on the server to avoid issues like this.

Thanks for the thoughts. For various reasons the data can only be stored on a local machine in its raw form, which is partly why I only wanted to load the fitted object but not the actual data frame. So starting from scratch on the server isn't an option in this case. 


When attempting to do so, I keep running into the same error below: 

no slot of name "control" for this object of class "lavModel"


Is this an error, or is it just a warning?  This is probably a version issue.  You are using 0.5-23, but your server is using 0.5-22.  lavaan has had some internal structural changes, even between these versions.  

It's an error.  I thought had copied the "Error:" part but I must have missed that. Hmmm, interesting. I guess I shouldn't be surprised if this is a version issue. I can look through the code on my own but I if you have a quick answer, does lavaan (either the .23 or .22 versions) not store the sample stats in the fitted object but rather calls to calculate them only when requested by summary? 

The thing I'm having trouble understanding is that if I do start from scratch on the server and fit the lavaan object (using a different data set) on both the server and my local machine, calling str(fit) on the object seems to produce the identical structure between server and local machine and both including the @Model slot even though the versions differ. In other words, it seems like there is some information lost when porting the .rds file to the server. Even if there were structural differences between the two versions, I would expect the str(fit) base function to show in full the structure to be identify where the differences might be, right? 

 

I've attempted this a few different ways but the general process is this:


  1. Fit lavaan model on local machine
    1. lavaan version 0.5.23.1097
  2. Save and export fit object as either .rds or .RData (error happens for both)
  3. Upload .rds or .Rdata file to server
  4. Log into server and spin up R
  5. Change working directory to .rds or .Rdata location
  6. Load saved fit object using either readRDS() or load() functions (same error for both)
    1. fit <- readRDS("file-loc.rds")
    2. fit <- load("file-loc.Rdata")
  1. After the actual file loads successfully into the R environment, load lavaan
    1. Version 0.5.22
At the very least, you could avoid the error or warning by loading lavaan first, so that it recognizes the lavaan-class object you are loading into  your workspace.  But again, you shouldn't waste your time with steps 1, 2, 3, 5, 6.  Just log into  your server, then change the directory to where your data are located, import the data into R and fit your model.  Then you can bootstrap easily. 

Tried loading lavaan first and then loading the data and receive the same error. R recognizes that the object is of the lavaan-class even if I attempt summary before loading lavaan (i.e., the attempt returns a message that the object is of the S4 class lavaan). Unfortunately, changing the directory only wouldn't fix things in that no director on the server will have the raw data (i.e., is only on the local machine). I can certainly rig something up that calls / accepts the data from a different source (e.g., local machine) in an encrypted format but I wanted to see if there are existing solutions first. 

Thanks for your time and thoughts!

Terrence Jorgensen

unread,
Nov 1, 2017, 4:43:06 AM11/1/17
to lavaan
Another option might be to synchronize the version you use.  If the server version cannot be updated to the one available on CRAN, then you can download and install 0.5-22 on your local machine.


install.packages("https://cran.r-project.org/src/contrib/Archive/lavaan/lavaan_0.5-22.tar.gz", type = "source", repos = NULL)

Terrence D. Jorgensen

Garett Howardson

unread,
Nov 1, 2017, 6:10:36 AM11/1/17
to lav...@googlegroups.com
Thinking that might be the way to go. Thanks for your all of your help!

--
You received this message because you are subscribed to a topic in the Google Groups "lavaan" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lavaan/0RLZE4-YKo8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lavaan+un...@googlegroups.com.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at https://groups.google.com/group/lavaan.
For more options, visit https://groups.google.com/d/optout.
--
Garett Howardson, Ph.D.
Founder, CEO, and Principal Work Scientist
Tuple Work Science, Limited
Reply all
Reply to author
Forward
0 new messages