lavaan WARNING: some observed variances are (at least) a factor 1000 times larger than others; use varTable(fit) to investigate

Viewed 2529

I am trying to evaluate the sem model from a dataset, some of the data are in likert scale i.e from 1-5. and some of the data are COUNTS generated from the computer log for some of the activity.

Whereas while performing the fits the laveen is giving me the error as:

lavaan WARNING: some observed variances are (at least) a factor 1000 times larger than others; use varTable(fit) to investigate

To mitigate this warning I want to scale some of the variables. But couldn't understand the way for doing that.

Log_And_SurveyResult <- read_excel("C:/Users/Aakash/Desktop/analysis/Log-And-SurveyResult.xlsx")

model <- '
  Reward =~ REW1 + REW2 + REW3 + REW4
  ECA =~  ECA1 + ECA2 + ECA3
  Feedback =~ FED1 + FED2 + FED3 + FED4
  Motivation =~ Reward + ECA + Feedback
  Satisfaction =~ a*MaxTimeSpentInAWeek + a*TotalTimeSpent + a*TotalLearningActivityView 
  
  Motivation ~ Satisfaction'

fit <- sem(model,data = Log_And_SurveyResult)

summary(fit, standardized=T, std.lv = T)

fitMeasures(fit, c("cfi", "rmsea", "srmr"))

I want to scale some of the variables like MaxTimeSpentInAWeek and TotalTimeSpent

Could you please help me figure out how to scale the variables? Thank you very much.

2 Answers

As Elias pointed out, the difference in the magnitude between the variables is huge and it is suggested to scale the variables. The warning gives a hint and inspecting varTable(fit) returns summary information about the variables in a fitted lavaan object.

Rather than running scale() separately on each column, you could use apply() on a subset or on your whole data.frame:

## Scale the variables in the 4th and 7h column
Log_And_SurveyResult[, c(4, 7)] <- apply(Log_And_SurveyResult[, c(4, 7)],  2, scale)

## Scale the whole data.frame
Log_And_SurveyResult <- apply(Log_And_SurveyResult,  2, scale)

You can just use scale(MaxTimeSpentInAWeek). This will scale your variable to mean = 0 and variance = 1. E.g:

    Log_And_SurveyResult$MaxTimeSpentInAWeek <- 
    scale(Log_And_SurveyResult$MaxTimeSpentInAWeek)
    Log_And_SurveyResult$TotalTimeSpent <- 
    scale(Log_And_SurveyResult$TotalTimeSpent)

Or did I misunderstand your question?

Related