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

Bootstrap error in seminr model #329

Open
Proost1 opened this issue Apr 12, 2023 · 6 comments
Open

Bootstrap error in seminr model #329

Proost1 opened this issue Apr 12, 2023 · 6 comments

Comments

@Proost1
Copy link

Proost1 commented Apr 12, 2023

I am a master's student conducting research on consumer behavior using the seminr package in Rstudio (version of R: 4.2.3). While working with the bootstrap_model() function, I encountered an error message that reads "8 nodes produced errors; first error: zero variance items cannot be scaled."

I am not certain how to resolve this issue and would appreciate any assistance that could be provided.
Thank you for your help in advance!

@soumyaray
Copy link
Contributor

Hi @Proost1 can I ask how big is your sample size? It seems that during the resampling process of bootstrapping, some of the resampled sets has measurement items that have no variance (all the values are the same). Can you identify which of your items might face this issue?

@Proost1
Copy link
Author

Proost1 commented Apr 13, 2023 via email

@Proost1
Copy link
Author

Proost1 commented Apr 13, 2023

I have found the error. There was a variable that had too little variance, so I removed it for the bootstrap. However, I am now encountering the following error message when trying to estimate the model, which I did not get before.
image

Thanks in advance!

@soumyaray
Copy link
Contributor

Hi, hmm, I haven't encountered this error before. I can try to help trouble shoot if you could share your data/code with me. If so, you can sent it to my email (on my Github profile) – we will delete all the files after your problem is resolved.

@Sumidu
Copy link
Contributor

Sumidu commented Apr 14, 2023 via email

@soumyaray
Copy link
Contributor

Leaving parts of my email response to @Proost1 here for the record

I've figured out the issue and resolved it. The problem seemed to be that the haven package used to load the SAV data file was interfering with seminr's ability to fix the missing values. It seems that the special data.frame created by haven has some extra properties that don't play well with other packages. I was able to resolve the issue by:

a) converting the SAV file into a CSV file (code at top of attached R file – commented out)
b) removing haven from memory (I had to restart my R session; code at top of attached R file – commented out)
b) loading the data from the CSV file instead
c) fixed a typo one of your final paths() statements

The model now estimates and can be summarized (note, the summary function takes a minute to finish)

I've emailed you the new R code and CSV data file. I suggest that instead of following my above steps (first two are commented out in the code), simply run the attached R file, which uses the data in the attached CSV. Do let me know if it works for you. BUT FIRST, you will have to remove the haven package from memory: I suggest using RStudio's "Session" menu > "Restart R" option, because simply detaching the package didn't work for me.

Do let me know if the code runs then!

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

No branches or pull requests

3 participants