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

Stumped Re: warning #1

Open
dberry77 opened this issue Mar 22, 2022 · 3 comments
Open

Stumped Re: warning #1

dberry77 opened this issue Mar 22, 2022 · 3 comments

Comments

@dberry77
Copy link

Dear Dr. Driver.
Thanks for both your didactic work on CTSEM, as well as this package. I've tried getting the following model to fit ~1000 different ways and, for the life of me I can't figure out why its throwing this error. Was hoping that it was something obvious that I'm missing... any thoughts would be really appreciated.

If I'm using a wide file (created via your long-to-wide function), I have 60 columns (that look just like the example in Driver et al. (2017) JSS). It reflects 2 time-varying manifest variables (t = 20), and then the 20 time-interval variables (time is balanced across individuals). There are NAs, but I’ve tried it w/out. Doesn’t fix anything.

The code is as follows:

the model##

number of latents

F <- 2

number of manifests

I <- F

drift matrix

A <- matrix( c("a_C","a_C}M","a_M}C","a_M"), nrow=F, ncol=F )

diffusion covariance matrix

Q <- matrix( c("var_C","cov_C_M",0,"var_M"), nrow=F, ncol=F )

continuous-time intercepts

b <- matrix( c("b_C","b_M"), nrow=F, ncol=1 )

#Random Person means
Sigmab.lr <- matrix( c("varblr_C","covblr_C_M",0,"varblr_M"), nrow=F, ncol=F )

set all intercepts of manifest variables to 0

manifestmeans <- matrix( 0, nrow=I, ncol=1 )

set measurement error covariance matrix to 0

manifestvar <- matrix( 0, nrow=I, ncol=I )

loading matrix: each item loads on one latent variable

Lambda <- diag( I )

set up model

m <- ctModel( n.latent = F,
latentNames = c("C_Pos","M_Pos"), # set names of latent variables
n.manifest = I,
manifestNames = c("cpos_wpz","mpos_wpz"), # names of manifest variables
# as in data set
DRIFT = A,
DIFFUSION = Q,
CINT = b,
TRAITVAR = Sigmab.lr,
LAMBDA = Lambda,
MANIFESTMEANS = manifestmeans,
MANIFESTVAR = manifestvar,
Tpoints = 20, # number of measurement occasions as in data set
type = "omx" ) # for frequentist estimation

Fit the model

set.seed( 1234 )
r <- ctFit( dat = wideexample2,
ctmodelobj = m,
dataform = "wide",
stationary = "all" ) # stationary assumption

smr <- summary( r )
print( smr$ctparameters )

The error is:
“Error in ctFit(dat = wide_pos, ctmodelobj = m, dataform = "wide", stationary = "all") :
Number of columns in data (60) do not match model (59)”

I’ve had the same issue if I opt for a long datafile.
“Error in ctFit(dat = play_cpmp, ctmodelobj = m, dataform = "long", stationary = "all") :
Tpoints in ctmodelobj = 20, not equal to 1, the maximum number of rows of any subject in dat.

I'm sure I'm just doing something dumb... but I'm at a bit of a loss.

Thanks again for any thoughts.
Best regards,
-dan berry

@cdriveraus
Copy link
Owner

Hi Dan, very quick suggestion before I take the time going through script etc -- try setting type='stanct' when calling ctModel, then fit using ctStanFit, and a long data structure. That should hopefully give better diagnostics as to what is wrong, but don't agonize over it, if doesn't work tell me I'll look a little more when I've more time!

@dberry77
Copy link
Author

dberry77 commented Mar 24, 2022 via email

@cdriveraus
Copy link
Owner

The default is just frequentist, with more flexibility than the old ctsemOmx. Should only take a few minutes i suspect a data structure problem... Can you set the observed variables to NA and post the full code maybe?

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

2 participants