Giter Club home page Giter Club logo

Comments (4)

cdriveraus avatar cdriveraus commented on June 16, 2024 1

Thanks for the report -- do I understand correctly that things work fine so long as everything was fit with the latest version, but the latest version of ctKalman does not play nicely with fit objects from earlier ctsem versions? If that's the case then I don't think I can fix this, but in at least some cases like this the ctFitUpdate function is helpful for bringing an older fit object in line with newer version internals.

from ctsem.

blainmorin avatar blainmorin commented on June 16, 2024 1

Hi Charles,

Looked into it a bit more, ctKalman does not play nicely with fits from the later versions either. Here is a reproducible example using the chicken data from the readme (Note the problem happens when the chicken id does not map directly to the numeric id map). Again, I think this issue is caused by the numeric column selection mentioned above.

`library(data.table)
library(mltools)
library(ctsem)

Runs Fine

chickdata <- one_hot(as.data.table(ChickWeight),cols = 'Diet')

chickdata$weight <- scale(chickdata$weight)

m <- ctModel(
LAMBDA=diag(1), #Factor loading matrix of latent processes on measurements, fixed to 1
type = 'stanct', #Could specify 'standt' here for discrete time.
tipredDefault = FALSE, #limit covariate effects on parameters to those explicitly specified
manifestNames='weight', #Observed measurements of the latent processes
latentNames='Lweight', #Names here simply make parameters and plots more interpretable
TIpredNames = paste0('Diet_',2:4), #Covariates, in this case one category needs to be baseline...
DRIFT='a11 | param', #normally self feedback (diagonal drift terms) are restricted to negative
MANIFESTMEANS=0, #For identification CINT is normally zero with this freely estimated
CINT='cint ||||Diet_2,Diet_3,Diet_4', #diet covariates specified in 5th 'slot' (four '|' separators)
time='Time',
id='Chick')

f <- ctStanFit(chickdata,m,nopriors=FALSE)

ctKalman(f,plot=TRUE,subjects=2:4,kalmanvec=c('yprior','ysmooth'))

Breaks if the chicks have character ids

chickdata <- one_hot(as.data.table(ChickWeight),cols = 'Diet')
chickdata$weight <- scale(chickdata$weight)
chickdata$Chick <- paste0(chickdata$Chick, "a") # Create Chick character id

m <- ctModel(
LAMBDA=diag(1), #Factor loading matrix of latent processes on measurements, fixed to 1
type = 'stanct', #Could specify 'standt' here for discrete time.
tipredDefault = FALSE, #limit covariate effects on parameters to those explicitly specified
manifestNames='weight', #Observed measurements of the latent processes
latentNames='Lweight', #Names here simply make parameters and plots more interpretable
TIpredNames = paste0('Diet_',2:4), #Covariates, in this case one category needs to be baseline...
DRIFT='a11 | param', #normally self feedback (diagonal drift terms) are restricted to negative
MANIFESTMEANS=0, #For identification CINT is normally zero with this freely estimated
CINT='cint ||||Diet_2,Diet_3,Diet_4', #diet covariates specified in 5th 'slot' (four '|' separators)
time='Time',
id='Chick')

f <- ctStanFit(chickdata,m,nopriors=FALSE)

ctKalman(f,plot=TRUE,subjects=2:4,kalmanvec=c('yprior','ysmooth')) `

from ctsem.

cdriveraus avatar cdriveraus commented on June 16, 2024 1

I see, thanks a lot. It's not 'strictly' an error but rather just poor coding practice re backwards compatibility -- in the 2nd example, you really need to specify subjects=c('2a',3a','4a'), but that doesn't match up with earlier versions so I've pushed a fix that allows both specifications (and warns if integers are used when realid=TRUE, which is the default)

from ctsem.

blainmorin avatar blainmorin commented on June 16, 2024

This happens when I use model objects fit with older versions of ctsem. Maybe the id mapping changed? Instead of selecting by column number maybe it should be by column name.

from ctsem.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.