Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate summary(std.nox=) argument #75

Merged
merged 1 commit into from
Apr 4, 2024

Conversation

TDJorgensen
Copy link
Contributor

This is for consistency with deprecating the std.nox= argument in lavaan: yrosseel/lavaan#326

This prevents the following error (thanks to Victoria Savalei for the reprex):

library(lavaan) #0.6-18.2018
library(blavaan) #blavaan 0.5-3

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

fit <- cfa(HS.model, data = HolzingerSwineford1939)
summary(fit)

# Error in lav_object_summary(object = object, ...  : 
# unused argument (std.nox = std.nox)

@TDJorgensen
Copy link
Contributor Author

Some more info:

You may notice that the reprex only calls summary() for a lavaan object, which works fine when only library(lavaan) is loaded.

> library(lavaan)
This is lavaan 0.6-18.2018
lavaan is FREE software! Please report any bugs.
> getMethod("summary", "lavaan")
Method Definition:

function (object, ...) 
{
    .local <- function (object, header = TRUE, fit.measures = FALSE, 
        estimates = TRUE, ci = FALSE, fmi = FALSE, standardized = FALSE, 
        std = standardized, std.nox = FALSE, remove.step1 = TRUE, 
        remove.unused = TRUE, cov.std = TRUE, rsquare = FALSE, 
        fm.args = list(standard.test = "default", scaled.test = "default", 
            rmsea.ci.level = 0.9, rmsea.h0.closefit = 0.05, rmsea.h0.notclosefit = 0.08, 
            robust = TRUE, cat.check.pd = TRUE), modindices = FALSE, 
        nd = 3L, cutoff = 0.3, dot.cutoff = 0.1) 
    {
        efa.flag <- object@Options$model.type == "efa"
        res <- lav_object_summary(object = object, header = header, 
            fit.measures = fit.measures, estimates = estimates, 
            ci = ci, fmi = fmi, std = std, standardized = standardized, 
            remove.step1 = remove.step1, remove.unused = remove.unused, 
            cov.std = cov.std, rsquare = rsquare, efa = efa.flag, 
            fm.args = fm.args, modindices = modindices)
        attr(res, "nd") <- nd
        if (efa.flag) {
            attr(res, "cutoff") <- cutoff
            attr(res, "dot.cutoff") <- dot.cutoff
        }
        res
    }
    .local(object, ...)
}
<bytecode: 0x7fb8cd8b4638>
<environment: namespace:lavaan>

Signatures:
        object  
target  "lavaan"
defined "lavaan"

The moment library(blavaan) is loaded, R seems to magically recall lavaan's old summary() method, even after I uninstall and reinstall blavaan after the new lavaan (0.6-18.2018) installed:

> library(blavaan)
Loading required package: Rcpp
This is blavaan 0.5-3
On multicore systems, we suggest use of future::plan("multicore") or
  future::plan("multisession") for faster post-MCMC computations.
> getMethod("summary", "lavaan")
Method Definition:

function (object, ...) 
{
    .local <- function (object, header = TRUE, fit.measures = FALSE, 
        estimates = TRUE, ci = FALSE, fmi = FALSE, std = FALSE, 
        standardized = FALSE, remove.step1 = TRUE, remove.unused = TRUE, 
        cov.std = TRUE, rsquare = FALSE, std.nox = FALSE, fm.args = list(standard.test = "default", 
            scaled.test = "default", rmsea.ci.level = 0.9, rmsea.h0.closefit = 0.05, 
            rmsea.h0.notclosefit = 0.08, robust = TRUE, cat.check.pd = TRUE), 
        modindices = FALSE, nd = 3L, cutoff = 0.3, dot.cutoff = 0.1) 
    {
        efa.flag <- object@Options$model.type == "efa"
        res <- lav_object_summary(object = object, header = header, 
            fit.measures = fit.measures, estimates = estimates, 
            ci = ci, fmi = fmi, std = std, standardized = standardized, 
            remove.step1 = remove.step1, remove.unused = remove.unused, 
            cov.std = cov.std, rsquare = rsquare, std.nox = std.nox, 
            efa = efa.flag, fm.args = fm.args, modindices = modindices)
        attr(res, "nd") <- nd
        if (efa.flag) {
            attr(res, "cutoff") <- cutoff
            attr(res, "dot.cutoff") <- dot.cutoff
        }
        res
    }
    .local(object, ...)
}
<bytecode: 0x7fb8de613bc0>
<environment: namespace:lavaan>

Signatures:
        object  
target  "lavaan"
defined "lavaan"

Notice that the lower one has the old std.nox= argument in lavaan's summary() method. This is a weird behavior of R's method dispatch that I don't understand. Maybe it has something to do with the way remotes::install_github() operates.

@ecmerkle
Copy link
Owner

ecmerkle commented Apr 3, 2024

Thanks! Do you see any problem with removing the std.nox argument now? I have not seen this argument used in blavaan, and I will probably forget about it by 2025.

About the old summary() method: that is odd. That sort of thing has happened to me when an old version of lavaan is still installed in a different folder, then that other folder is unexpectedly used. For example, sometimes the order of the folders in .libPaths() changes depending on whether or not you have sudo permissions. Then if I install something using sudo, I see unexpected behavior as compared to when I was running R as a regular user.

@TDJorgensen
Copy link
Contributor Author

TDJorgensen commented Apr 4, 2024

Do you see any problem with removing the std.nox argument now?

Probably not, but I just kept it in, in case something became apparent later. Like I did in this PR for blavaan, the argument remains in lavaan's summary() method, so that it doesn't immediately break any package that explicitly uses it. But it doesn't do anything anymore (described as deprecated in the class?lavaan documentation), and I have it flagged to remove after some time (a year is probably overkill). When I do, I'll remove it from blavaan too, so you don't have to worry about remembering it.

That sort of thing has happened to me when an old version of lavaan is still installed in a different folder, then that other folder is unexpectedly used

That's what I was thinking too, but I uninstalled both lavaan and blavaan from everywhere in .libPaths(), then installed lavaan from GitHub and blavaan from CRAN.

@ecmerkle ecmerkle merged commit c0bf3a9 into ecmerkle:master Apr 4, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants