brandmaier / semtree

Recursive Partitioning for Structural Equation Models
https://brandmaier.github.io/semtree/
GNU General Public License v3.0
13 stars 11 forks source link

More permissive check #36

Closed cjvanlissa closed 2 years ago

cjvanlissa commented 2 years ago

closes #35

brandmaier commented 2 years ago

Thanks, Caspar! As far as I can see, your suggestion of the merge()-fix does only work for OpenMx models but is not compatible with other model types (e.g., lavaan). I fixed the merge()-function differently by going through all S3 attributes of the OpenMx model (with some exceptions like output or compute for reasons documented in the code) and compare their digests. For other model types, the entire model object is compared with digest. As for the predict function, I think there needs some more discussions to happen before we can implement it. Thanks for your contributions, though! I am closing this PR now.

brandmaier commented 2 years ago

@cjvanlissa, I decided to go with a variation on your predict.semtree() function because the use of the 'type' argument allows different future prediction return objects. However, I think that it is too early to have a predict.semforest() for now.

cjvanlissa commented 2 years ago

@brandmaier that's good news! predict.semforest(type = "node") does make sense in my opinion, it should just be

predict.semforest <- function(x, type, ...){
  switch(type,
               "node" = {sapply(x$forest, predict}
             )
}

For other types, more complex methods might be needed as discussed via email. But the type argument allows for these to be incorporated without breaking backwards compatibility.