CecileProust-Lima / lcmm

R package lcmm
https://CecileProust-Lima.github.io/lcmm/
54 stars 13 forks source link

Parameter constraints in LCMM #210

Closed ltd7 closed 11 months ago

ltd7 commented 1 year ago

Hi – I have a simple question – I’m using LCMM to fit a mixture of ordinal probit models and it works fine, an example program and data are attached (and I’ve checked it with other software). My question is that I’d like to restrict the coefficient of the regressor (stim) to zero in one of the classes (class 2 coefficient is not sig), so stim class2 = 0. I’ve checked the manual and your JSS article, but I’m not sure how to do it, thank you in advance for any help! The Swets data has trials (1-1188), stim (0 or 1) and resp (1-6).

(recode responses from 0 to K-1 for lcmm)

swets$resp <- swets$resp - 1 swets <- as.data.frame(swets) inits <- lcmm(resp ~ stim,random = ~-1, link='thresholds',subject='trial', data=swets,maxiter=100, verbose=TRUE)

(use initial values from above) (this fits the general mixture model with non-zero d in both classes)

mixmod <- gridsearch(lcmm(fixed = resp ~ stim, random = ~-1, mixture = ~ -1+stim, ng = 2, link='thresholds', subject='trial', data=swets, B = 'inits', verbose=TRUE), minit=inits, maxiter=60, rep=20) summary(mixmod)

CecileProust-Lima commented 1 year ago

Hi, there is an argument to fix parameters: posfix. You need to give in posfix the vector of the parameter places you need to fix. The program will fix these parameters to the value indicated in B argument. I hope this helps Cécile

ltd7 commented 1 year ago

Thank you, that works. Here's the syntax, if it helps others, I'm fixing the 3rd parameter (slope in the second class) to the third starting value, zero. I had to remove the gridsearch option so that the parameter is fixed.

mixmod <- lcmm(fixed = resp ~ stim, random = ~-1, mixture = ~ -1+stim, ng = 2, link='thresholds', subject='trial', data=swets, B = c(1,2,0,-.5,1,1,1,1), posfix=c(3), verbose=TRUE)