Search code examples
rp-valuer-lavaanfactor-analysis

Extract full p-value from Lavaan CFA output in R


R-novice here. I am running a CFA using the Lavaan package. It is giving me everything I need, except my p-value is coming up at .000 and I would like to find the exact p-value (i.e. .0000009 or whatever it might be).

I have tried to use:

format.pval(p, digits=6)

and

options(digits=10)

but neither of these changed my output.

The code I am using is:

fit<-cfa(model,data=fulldata,estimator = "WLSMV") 
summary(fit,fit.measures=TRUE,standardized=TRUE)  

Solution

  • lavaan has special classes for its output, with dedicated print methods. The number of digits is controlled by the nd= argument (see the class?lavaan help page for more details). For example:

    example(cfa)
    summary(cfa, nd = 5)
    
    PE <- parameterEstimates(fit)
    print(PE, nd = 6)
    
    FM <- fitMeasures(fit, "pvalue")
    print(FM, nd = 7)