It seems no matter what model I'm trying to build I get the following error on the last line:
Compiling model graph
Resolving undeclared variables
Allocating nodes
Deleting model
Error in jags.model(paste0(tmpdir, "model.bug"), data = list(), n.chains = num_cores) :
RUNTIME ERROR:
Compilation error on line 143.
Unknown variable CVD.p
Either supply values for this variable with the data
or define it on the left hand side of a relation.
I get this error on rjags and Windows jags. The strange this is, as far as I can tell, the exact same code worked a year ago or so (on Windows JAGS). The error on Windows:
Welcome to JAGS 4.3.1 on Wed Mar 6 15:17:58 2024
JAGS is free software and comes with ABSOLUTELY NO WARRANTY
Loading module: basemod: ok
Loading module: bugs: ok
Reading data file post_params.R
Compiling model graph
Resolving undeclared variables
Allocating nodes
RUNTIME ERROR:
Compilation error on line 143.
Dimension mismatch taking subset of CVD.p
Deleting model
C:\Users\Stacey Cherny\tmp\jags>
I'm really at a loss, given this code worked at one point (different variables, but built the same way, using code someone else wrote). I'm hoping that I'm just doing something stupid and someone can point that out to me easily!
I've deleted variables from my model and every time I get the same error on the very last variable.
Thanks in advance for any insights and help anyone can offer.
model.bug:
model {
AGE ~ dnorm(mu.AGE,prec.AGE);
mu.AGE<- AGE.c0;
AGE.M0 ~ dcat(AGE.p[ ,2]);
AGE.c0 <-AGE.p[AGE.M0,1];
prec.AGE.M ~ dcat(prec.AGE.p[ ,2]);
prec.AGE <- prec.AGE.p[prec.AGE.M,1];
ECW ~ dnorm(mu.ECW,prec.ECW);
mu.ECW<- ECW.c0+ECW.c1*AGE+ECW.c2*LYMPabs+ECW.c3*SIRI;
ECW.M0 ~ dcat(ECW.p[ ,2]);
ECW.c0 <-ECW.p[ECW.M0,1];
ECW.M1 ~ dcat(ECW.p[ ,4]);
ECW.c1 <-ECW.p[ECW.M1,3];
ECW.M2 ~ dcat(ECW.p[ ,6]);
ECW.c2 <-ECW.p[ECW.M2,5];
ECW.M3 ~ dcat(ECW.p[ ,8]);
ECW.c3 <-ECW.p[ECW.M3,7];
prec.ECW.M ~ dcat(prec.ECW.p[ ,2]);
prec.ECW <- prec.ECW.p[prec.ECW.M,1];
GDF15_LnLn ~ dnorm(mu.GDF15_LnLn,prec.GDF15_LnLn);
mu.GDF15_LnLn<- GDF15_LnLn.c0+GDF15_LnLn.c1*AGE+GDF15_LnLn.c2*ECW+GDF15_LnLn.c3*D2TM;
GDF15_LnLn.M0 ~ dcat(GDF15_LnLn.p[ ,2]);
GDF15_LnLn.c0 <-GDF15_LnLn.p[GDF15_LnLn.M0,1];
GDF15_LnLn.M1 ~ dcat(GDF15_LnLn.p[ ,4]);
GDF15_LnLn.c1 <-GDF15_LnLn.p[GDF15_LnLn.M1,3];
GDF15_LnLn.M2 ~ dcat(GDF15_LnLn.p[ ,6]);
GDF15_LnLn.c2 <-GDF15_LnLn.p[GDF15_LnLn.M2,5];
GDF15_LnLn.M3 ~ dcat(GDF15_LnLn.p[ ,8]);
GDF15_LnLn.c3 <-GDF15_LnLn.p[GDF15_LnLn.M3,7];
prec.GDF15_LnLn.M ~ dcat(prec.GDF15_LnLn.p[ ,2]);
prec.GDF15_LnLn <- prec.GDF15_LnLn.p[prec.GDF15_LnLn.M,1];
LA_ratio_Ln ~ dnorm(mu.LA_ratio_Ln,prec.LA_ratio_Ln);
mu.LA_ratio_Ln<- LA_ratio_Ln.c0+LA_ratio_Ln.c1*AGE;
LA_ratio_Ln.M0 ~ dcat(LA_ratio_Ln.p[ ,2]);
LA_ratio_Ln.c0 <-LA_ratio_Ln.p[LA_ratio_Ln.M0,1];
LA_ratio_Ln.M1 ~ dcat(LA_ratio_Ln.p[ ,4]);
LA_ratio_Ln.c1 <-LA_ratio_Ln.p[LA_ratio_Ln.M1,3];
prec.LA_ratio_Ln.M ~ dcat(prec.LA_ratio_Ln.p[ ,2]);
prec.LA_ratio_Ln <- prec.LA_ratio_Ln.p[prec.LA_ratio_Ln.M,1];
LYMPabs ~ dnorm(mu.LYMPabs,prec.LYMPabs);
mu.LYMPabs<- LYMPabs.c0;
LYMPabs.M0 ~ dcat(LYMPabs.p[ ,2]);
LYMPabs.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 dcat(HTM.p[ ,6]);
HTM.c2 <-HTM.p[HTM.M2,5];
HTM.M3 ~ dcat(HTM.p[ ,8]);
HTM.c3 <-HTM.p[HTM.M3,7];
CVD ~ dbern(p11);
logit(p11)<- CVD.c0+CVD.c1*ECW+CVD.c2*GDF15_LnLn+CVD.c3*D2TM+CVD.c4*HLD+CVD.c5*HTM;
CVD.M0 ~ dcat(CVD.p[ ,2]);
CVD.c0 <-CVD.p[CVD.M0,1];
CVD.M1 ~ dcat(CVD.p[ ,4]);
CVD.c1 <-CVD.p[CVD.M1,3];
CVD.M2 ~ dcat(CVD.p[ ,6]);
CVD.c2 <-CVD.p[CVD.M2,5];
CVD.M3 ~ dcat(CVD.p[ ,8]);
CVD.c3 <-CVD.p[CVD.M3,7];
CVD.M4 ~ dcat(CVD.p[ ,10]);
CVD.c4 <-CVD.p[CVD.M4,9];
CVD.M5 ~ dcat(CVD.p[ ,12]);
CVD.c5 <-CVD.p[CVD.M5,11];
}
script_1.R:
model in model.bug
data in post_params.R
compile, nchains(1)
parameters in init_1.R, chain(1)
initialize
update 10000, by(1000)
monitor AGE, thin(10)
monitor ECW, thin(10)
monitor GDF15_LnLn, thin(10)
monitor LA_ratio_Ln, thin(10)
monitor LYMPabs, thin(10)
monitor SIRI, thin(10)
monitor D2TM, thin(10)
monitor HLD, thin(10)
monitor HTM, thin(10)
monitor CVD, thin(10)
update 10780, by(1078)
coda *, stem("out_1")
init_1.R
".RNG.name" <-"base::Mersenne-Twister"
".RNG.seed" <- 1