Invalid formula error

90 views
Skip to first unread message

Sichel, Corianna

unread,
Jan 31, 2020, 9:43:50 AM1/31/20
to tid...@googlegroups.com

Dear TidyLPA-ers,

 

First, thanks so much for developing the tidyLPA package. I’ve been trying to migrate over to R from MPlus, and was really glad to find it.

 

Second, I’m having an issue. When I try to get a printout of my data (for subsequent analyses, when I look at comparisons across profiles), I get an error. I’ve googled around a bit but wasn’t able to come up with a solution. I also spent some time in the tidyLPA documentation to no end.

 

I’m including details on my code, error, output, and data below. Please don’t hesitate to let me know if I can provide anything else and/or if I should direct my question elsewhere.

 

Many thanks,

 

Corianna

 

****

 

Here’s my code

results<-opinions_clean %>%

  select(acc1:feas4)%>%

  single_imputation()%>%

  estimate_profiles(2)%>% 

 

get_data(results)

 

Here’s the output from my model (when I just call “results”)

tidyLPA analysis using mclust: 
 
 Model Classes AIC     BIC     Entropy prob_min prob_max n_min n_max BLRT_p
 1     2       1942.10 2022.56 0.97    0.99     0.99     0.35  0.65  0.01  

 

Here’s my error

Error in formula.default(model) : invalid formula

 

Here’s the plot I get when I use plot_profiles

 

 

And here’s a readout from my data, which I loaded in from SPSS using haven

> head(opinions_clean)
# A tibble: 6 x 12
       acc1      acc2      acc3      acc4      app1      app2      app3      app4     feas1     feas2     feas3     feas4
  <dbl+lbl> <dbl+lbl> <dbl+lbl> <dbl+lbl> <dbl+lbl> <dbl+lbl> <dbl+lbl> <dbl+lbl> <dbl+lbl> <dbl+lbl> <dbl+lbl> <dbl+lbl>
1     1 [1]     1 [1]     1 [1]     1 [1]     2 [2]     1 [1]     3 [3]     1 [1]     2 [2]     5 [5]     2 [2]     3 [3]
2     1 [1]     1 [1]     1 [1]     1 [1]     2 [2]     2 [2]     2 [2]     1 [1]     3 [3]     1 [1]     4 [4]     2 [2]
3     3 [3]     2 [2]     2 [2]     2 [2]     4 [4]     4 [4]     4 [4]     4 [4]     3 [3]     4 [4]     3 [3]     3 [3]
4     4 [4]     5 [5]     4 [4]     4 [4]     4 [4]     4 [4]     4 [4]     4 [4]     4 [4]     4 [4]     4 [4]     4 [4]
5     2 [2]     2 [2]     3 [3]     3 [3]     3 [3]     3 [3]     4 [4]     2 [2]     2 [2]     2 [2]     2 [2]     4 [4]
6     2 [2]     1 [1]     1 [1]     1 [1]     3 [3]     3 [3]     4 [4]     1 [1]     4 [4]     2 [2]     4 [4]     4 [4]

 

 

 

--

Corianna Elizabeth Sichel, MPhil

Pre-Doctoral Psychology Fellow

Division of Prevention and Community Research
Department of Psychiatry

Yale School of Medicine

she, her, hers

 

 

 

Caspar van Lissa

unread,
Jan 31, 2020, 9:57:39 AM1/31/20
to Sichel, Corianna, tid...@googlegroups.com
Dear Corianna,

it is not clear when you get this error message. Can you provide a reproducible example? 

Second, and possibly unrelated to your question, be careful fitting mixture models to ordered categorical data. Although data with >7 categories are often treated as one continuous distribution, your data has 5 categories, and you are fitting two distributions. This violates the assumption that your distribution is a mixture of multiple normal distributions.

Best,
Caspar

--
You received this message because you are subscribed to the Google Groups "tidyLPA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tidylpa+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tidylpa/MN2PR08MB5982A5D792B0DE1D105555AD90070%40MN2PR08MB5982.namprd08.prod.outlook.com.


--
Dr. Caspar van Lissa
Assistant professor of applied data science, Utrecht University
Amsterdam
Haarlemmerweg 57-1, 1051KP Amsterdam
Tel. +31 6 38126513

Alle e-mail berichten (inclusief bijlagen) van deze afzender zijn met grote zorgvuldigheid samengesteld. Voor mogelijke onjuistheid en/of onvolledigheid van de hierin verstrekte informatie kan de afzender geen aansprakelijkheid aanvaarden, evenmin kunnen aan de inhoud van dit bericht (inclusief bijlagen) rechten worden ontleend. De inhoud van dit bericht (inclusief bijlagen) kan vertrouwelijke informatie bevatten en is uitsluitend bestemd voor de geadresseerde van dit bericht. Indien u niet de beoogde ontvanger van dit bericht bent, verzoekt de afzender u dit bericht te verwijderen, eventuele bijlagen niet te openen en wijst de afzender u op de onrechtmatigheid van het gebruiken, kopiëren of verspreiden van de inhoud van dit bericht (inclusief bijlagen).

This e-mail message (including attachments) was composed in good faith by the sender. the sender cannot assume any responsibility for the accuracy or reliability of the information contained in these message (including attachments), nor shall the information be construed as constituting any obligation on the part of the sender. The information contained in messages (with attachments) from the sender may be confidential or privileged and is only intended for the use of the receiver named. If you are not the intended recipient, you are requested by the sender to delete the message (with attachments) without opening it and you are notified by the sender that any disclosure, copying or distribution of the information contained in the message (with attachments) is strictly prohibited and unlawful.

Sichel, Corianna

unread,
Jan 31, 2020, 10:19:34 AM1/31/20
to Caspar van Lissa, tid...@googlegroups.com

Hi Caspar,

 

Thanks for your reply. I’m pretty new to R. How do you recommend I go about creating a reproducible example?

 

Thanks also for your note on the mixture model issue. When I started this project I was intending to use LCA, but then read something that made me think I should switch to an LPA. I looked back in my notes and can’t seem to find whatever that was, so I’ll do a bit more digging and revisit that, as well.

 

Best,

 

Corianna

Sichel, Corianna

unread,
Jan 31, 2020, 3:33:52 PM1/31/20
to Caspar van Lissa, tid...@googlegroups.com

Also – I should have mentioned that I got the error after running get_data(results). Thanks!

cid:image001.jpg@01D5D840.37990760

Sichel, Corianna

unread,
Feb 11, 2020, 10:48:08 AM2/11/20
to Caspar van Lissa, tid...@googlegroups.com

Just following up on this, as I would like to use TidyLPA in other analyses going forward but not sure why the get_data() command did not work as described. Thanks!

Caspar van Lissa

unread,
Feb 11, 2020, 10:53:21 AM2/11/20
to tidyLPA
Dear Corianna, I would be happy to help, but I do need a reproducible example. If you can email your code and data to c.j.va...@uu.nl I'll try to debug it. If you cannot share your data, then you could try to make a synthetic dataset with the synthpop package, and check if you can reproduce the error in the synthetic data!
Reply all
Reply to author
Forward
0 new messages