# Issues with running spatial survival model in Stan

**URL:** <https://discourse.mc-stan.org/t/issues-with-running-spatial-survival-model-in-stan/22706>\
**Category:** Modeling\
**Tags:** rstan, fitting-issues\
**Created:** [May 26, 2021, 4:09pm UTC](https://discourse.mc-stan.org/t/issues-with-running-spatial-survival-model-in-stan/22706 "2021-05-26T16:09:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Isa\_Nazar](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/isa_nazar/32/9376_2.png) [@Isa\_Nazar](https://discourse.mc-stan.org/u/Isa_Nazar)\
**Post date:** [May 26, 2021, 4:09pm UTC](https://discourse.mc-stan.org/t/issues-with-running-spatial-survival-model-in-stan/22706/1 "2021-05-26T16:09:01Z")

</div>

Hi all,  
I am trying to run a spatial survival model with 10 predictors in Stan. So the type of my predictor variables are as follows:

1. Three predictors are quantitative variables.
2. Four predictors are binary variables.
3. Three predictors are categorical variables with 4 levels.

Can someone help me in defining categorical variables, please?  
Thank you!

My Stan codes for data and parameter blocks:  
"  
data {  
int \<lower=0\> province;  
int \<lower=0\> n\_grid;  
int \<lower=0\> N;  
int \<lower=0\> num;  
int \<lower=0\> number;  
vector \<lower=0\> [province] p;  
matrix [province,n\_grid] kernel;  
matrix [N,num] predictor;  
matrix [N,number] respon;  
}  
parameters{  
vector [num] beta;  
real \<lower=0\> sigma;  
vector [n\_grid] x;  
}  
transformed parameters{  
vector [N] lambdaa;  
for(n in 1:N) {  
lambdaa [n] = exp (predictor [n]\*beta);  
}  
}  
"  
Best,

Eisa

---

<div class="post-metadata">

**Author:** ![martinmodrak](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/martinmodrak/32/133_2.png) [@martinmodrak](https://discourse.mc-stan.org/u/martinmodrak)\
**Post date:** [June 10, 2021, 8:32am UTC](https://discourse.mc-stan.org/t/issues-with-running-spatial-survival-model-in-stan/22706/2 "2021-06-10T08:32:50Z")

</div>

Is this the same model as [Issues with defining the custom likelihoods of spatial survival model in Stan - #4 by martinmodrak](https://discourse.mc-stan.org/t/issues-with-defining-the-custom-likelihoods-of-spatial-survival-model-in-stan/22612/4) ?

In any case, categorical predictors are most often encoded as a set of binary variables via “dummy coding” ([Dummy variable (statistics) - Wikiversity](https://en.wikiversity.org/wiki/Dummy_variable_(statistics))) or “effect coding” ([FAQ: What is effect coding?](https://stats.idre.ucla.edu/other/mult-pkg/faq/general/faqwhat-is-effect-coding/))

---

<div class="post-metadata">

**Author:** ![Isa\_Nazar](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/isa_nazar/32/9376_2.png) [@Isa\_Nazar](https://discourse.mc-stan.org/u/Isa_Nazar)\
**Post date:** [June 10, 2021, 8:40am UTC](https://discourse.mc-stan.org/t/issues-with-running-spatial-survival-model-in-stan/22706/3 "2021-06-10T08:40:44Z")

</div>

Thank you for your information and help.
