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

Bug with add_lv_model #36

Open
pmpharm opened this issue Apr 1, 2020 · 2 comments
Open

Bug with add_lv_model #36

pmpharm opened this issue Apr 1, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@pmpharm
Copy link

pmpharm commented Apr 1, 2020

Tried to add two complementary LV models as follows:

m5 <- reset_lv_models(m4)
m6 <- add_lv_model(m5, "linear", c(2,4,8,10,14,19,25,29,34,36,41,47,50,52,57))
m6 <- add_lv_model(m6, "linear", setdiff(1:58,c(2,4,8,10,14,19,25,29,34,36,41,47,50,52,57)))

When run got the NM error: RANDOM VARIABLE IS DEFINED IN A NESTED IF STRUCTURE.
Fixed the problem by modified the output code from piraid from:

IF (PSI_MODEL.EQ.1) THEN
    BASE=THETA(233)+ETA(1)
    SLP=THETA(234)+ETA(2)
    PSI=BASE+SLP*TIME
ELSE IF (PSI_MODEL.EQ.2) THEN
    BASE=THETA(235)+ETA(3)
    SLP=THETA(236)+ETA(4)
    PSI=BASE+SLP*TIME
ENDIF

to

IF (PSI_MODEL.EQ.1) THEN
    BASE=THETA(233)+ETA(1)
    SLP=THETA(234)+ETA(2)
    PSI=BASE+SLP*TIME
ELSE 
    BASE=THETA(235)+ETA(3)
    SLP=THETA(236)+ETA(4)
    PSI=BASE+SLP*TIME
ENDIF

Models run without NM error after.

@pmpharm
Copy link
Author

pmpharm commented Apr 1, 2020

Same in different, gave the same NM error:

> m5 <- reset_lv_models(m4)
> m11 <- add_lv_model(m5, "linear", c(2,4,8,10,14,19,25,29,34,36,41,47,50,52,57))
> m11 <- add_lv_model(m11, "linear", c(3,5,12,16,20,23,26,30,32,37,40,42,43,53,55,58))
> m11 <- add_lv_model(m11, "linear", c(6,11,17,27,35,45,49))
> m11 <- add_lv_model(m11, "linear", c(1,7,13,15,18,21,24,28,31,38,39,44,48,51,54,56))
> m11 <- add_lv_model(m11, "linear", c(9,22,33,46))
> save_model_code(m11, "run11.mod")

Fixed by changing:

> IF (PSI_MODEL.EQ.1) THEN
>     BASE=THETA(233)+ETA(1)
>     SLP=THETA(234)+ETA(2)
>     PSI=BASE+SLP*TIME
> ELSE IF (PSI_MODEL.EQ.2) THEN
>     BASE=THETA(235)+ETA(3)
>     SLP=THETA(236)+ETA(4)
>     PSI=BASE+SLP*TIME
> ELSE IF (PSI_MODEL.EQ.3) THEN
>     BASE=THETA(237)+ETA(5)
>     SLP=THETA(238)+ETA(6)
>     PSI=BASE+SLP*TIME
> ELSE IF (PSI_MODEL.EQ.4) THEN
>     BASE=THETA(239)+ETA(7)
>     SLP=THETA(240)+ETA(8)
>     PSI=BASE+SLP*TIME
> ELSE IF (PSI_MODEL.EQ.5) THEN
>     BASE=THETA(241)+ETA(9)
>     SLP=THETA(242)+ETA(10)
>     PSI=BASE+SLP*TIME
> END IF

to

> IF (PSI_MODEL.EQ.1) THEN
>     BASE=THETA(233)+ETA(1)
>     SLP=THETA(234)+ETA(2)
>     PSI=BASE+SLP*TIME
> ENDIF 
> IF (PSI_MODEL.EQ.2) THEN
>     BASE=THETA(235)+ETA(3)
>     SLP=THETA(236)+ETA(4)
>     PSI=BASE+SLP*TIME
> ENDIF
> IF (PSI_MODEL.EQ.3) THEN
>     BASE=THETA(237)+ETA(5)
>     SLP=THETA(238)+ETA(6)
>     PSI=BASE+SLP*TIME
> ENDIF
> IF (PSI_MODEL.EQ.4) THEN
>     BASE=THETA(239)+ETA(7)
>     SLP=THETA(240)+ETA(8)
>     PSI=BASE+SLP*TIME
> ENDIF
> IF (PSI_MODEL.EQ.5) THEN
>     BASE=THETA(241)+ETA(9)
>     SLP=THETA(242)+ETA(10)
>     PSI=BASE+SLP*TIME
> ENDIF

@rikardn
Copy link
Member

rikardn commented Apr 2, 2020

Thanks for reporting this. It is indeed a bug.

@rikardn rikardn added the bug Something isn't working label Apr 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants