variable lengths differ (found for 'age')

22 views
Skip to first unread message

Kassahun Abere

unread,
Jul 29, 2025, 12:03:23 PMJul 29
to R-inla discussion group
Dear INLA support group,
I am running a geostatistical model for point referenced data using longitude and latitude vales to construct the mesh, and fitted a binary outcome variable with predictor variables. But I keep on getting an error stating that: "  Error in inla.core.safe(formula = formula, family = family, contrasts = contrasts,  :  variable lengths differ (found for 'age')
The inla program failed and the maximum number of tries has been reached." 
May you please help in resolving this error?
The codes are shown below.

Many thanks!
Kassahun  


coords<-cbind(mydata$longitude, mydata$latitude)

 

mesh<-inla.mesh.2d(loc=coords, max.edge = c(0.1, 5), cutoff = 0.002)

A.est<-inla.spde.make.A(mesh=mesh, loc=coords)

spde<-inla.spde2.matern(mesh=mesh, loc=coords)

s.index<-inla.spde.make.index(name="spatial.field", n.spde =spde$n.spde)

stack.est <- inla.stack(data=list(y=mydata$outcome),

    A=list(A.est, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),

     effects=list(c(s.index, list(Intercept=1)),                               

     list(emp= mydata$empstatus),

    list(marital= mydata$maritstatus),

    list(income=mydata$recevincome),

    list(educ=mydata$educstatus),

    list(TB=mydata$testdTB),

    list(lengthtstd=mydata$lengthTestedHIV),

    list(rdyARV=mydata$redy2strtARV),

   list=(age=mydata$age_q),

    List=(sx=mydata$sx), 

    list(acohl=mydata$freqalcoluse)),

    tag="est")

formula <- y ~ -1 + Intercept + emp+ marital+ income+ educ+ TB+ lengthtstd+ rdyARV+ acohl+age+sx+ f(spatial.field, model=spde)

output <- inla(formula,

    data=inla.stack.data(stack.est, spde=spde),

    family="binomial",Ntrials=1,

    control.predictor=list(A=inla.stack.A(stack.est),

    compute=TRUE),

    control.compute=list(dic=TRUE))

 

*** inla.core.safe:  The inla program failed, but will rerun in case better initial values may help. try=1/1

Error in inla.core.safe(formula = formula, family = family, contrasts = contrasts,  :

  variable lengths differ (found for 'age')

The inla program failed and the maximum number of tries has been reached.

Reply all
Reply to author
Forward
0 new messages