My problem statement is to identify the factors that affects net promoter score
I am using lavaan package testing with sample data
Below is the code
library(lavaan)
age=c(24,56,34)
weight=c(76,55,66)
nps=c(9,4,5)
df=c(age,weight,nps)
mat1=matrix(c(cov(abs(scale(df)))),3,3,byrow=TRUE)
mod2 <- "weight ~ age \n weight ~ nps"
mod1 <- "nps ~ age \n nps ~ weight"
mat1=matrix(c(cor(abs(scale(df)))),3,3,byrow=TRUE)
colnames(mat1) <- rownames(mat1) <- c("age", "weight", "nps")
mod1fit <- sem(mod1, sample.cov = mat1, sample.nobs = 100)
From above example can anyone help in understanding nobs[Number of Observations=100]. Usually in ML observations says about number of rows but I don't know the meaning here of nobs parameter .
I have used below link to learn
When I run above code I get error as below
Error in lav_samplestats_icov(COV = cov[[g]], ridge = ridge, x.idx = x.idx[[g]], :
lavaan ERROR: sample covariance matrix is not positive-definite