# Trying deprecated constructor; please alert package maintainer Error in new\_CppObject\_xp(fields$.module, fields$.pointer, ...)

**URL:** <https://discourse.mc-stan.org/t/trying-deprecated-constructor-please-alert-package-maintainer-error-in-new-cppobject-xp-fields-module-fields-pointer/2993>\
**Category:** Modeling\
**Created:** [January 15, 2018, 6:31pm UTC](https://discourse.mc-stan.org/t/trying-deprecated-constructor-please-alert-package-maintainer-error-in-new-cppobject-xp-fields-module-fields-pointer/2993 "2018-01-15T18:31:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xianerd](https://avatars.discourse-cdn.com/v4/letter/x/dfb087/32.png) [@Xianerd](https://discourse.mc-stan.org/u/Xianerd)\
**Post date:** [January 15, 2018, 6:31pm UTC](https://discourse.mc-stan.org/t/trying-deprecated-constructor-please-alert-package-maintainer-error-in-new-cppobject-xp-fields-module-fields-pointer/2993/1 "2018-01-15T18:31:36Z")

</div>

Hi, I am trying to run the following stan model with the given data. But it gave me the following error.

trying deprecated constructor; please alert package maintainer  
Error in new\_CppObject\_xp(fields$.module, fields$.pointer, …)

Anyone can help? Thank you very much!

stan.m="  
data {  
int\<lower=0\> N[1];  
vector\<lower=0\>[N[1]] dose;  
real\<lower=0\> dr;  
int DLT[N[1]];  
int total[N[1]];

vector[2] mu;  
cov\_matrix[2] Sigma;  
}  
parameters {  
vector[2] log\_ab;  
}

transformed parameters {  
real log\_a = log\_ab[1];  
real log\_b = log\_ab[2];  
real\<lower=0\> b = exp(log\_b);  
}

model {  
vector[N[1]] prob;  
// Prior  
log\_ab~multi\_normal(mu, Sigma);  
//likelihood

for(i in 1:N[1]){  
prob[i]=exp(log\_a + b_log(dose[i]/dr))/(1+exp(log\_a + b_log(dose[i]/dr)));  
DLT[i] ~ binomial(total[i],prob[i]);  
}  
}  
"

stan\_data \<- list(  
dose = c(800),  
total = c(7),  
DLT = c(1),  
N = 1,  
dr = dr,

```
mu = mu,
Sigma = Sigma,
Rho = rho

```

)

fit = stan(model\_code=stan.m, data=stan\_data, iter=1000, chains=4,thin=2)

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [January 15, 2018, 6:52pm UTC](https://discourse.mc-stan.org/t/trying-deprecated-constructor-please-alert-package-maintainer-error-in-new-cppobject-xp-fields-module-fields-pointer/2993/2 "2018-01-15T18:52:00Z")

</div>

The messages get swallowed but there are several things wrong here.

First, the model doesn’t parse. You need to do `b * log(...)` rather than `b log(...)`; i.e. the Stan language does not support implicit multiplication.

Second, the model doesn’t initialize.

```
Exception: mismatch in number dimensions declared and found in context; processing stage=data initialization; variable name=N; dims declared=(1); dims found=() 

```

This is because you declared `int<lower=0> N[1];` but passed a scalar integer. You should just do

```
int<lower=0> N;

```

and then replace all the `N[1]` with `N`.

The same thing with `dose`, `total`, etc. If you really want it to be a vector of length 1, you can pass it as `as.array(dose)` but you probably just want to declare it as a scalar.

Although it doesn’t throw an error, you should just write your likelihood as

```
DLT ~ binomial_logit(total, log_a + b * log(dose / dr) / 
                     exp(log1p_exp(log_a + b * log(dose / dr));

```

and even then you could avoid the recalculation of `b * log(dose / dr)` by saving it to a temporary vector. Also, only specify `thin > 1` if you run out of RAM, which is unlikely for a model like this.

```

```

---

<div class="post-metadata">

**Author:** ![Xianerd](https://avatars.discourse-cdn.com/v4/letter/x/dfb087/32.png) [@Xianerd](https://discourse.mc-stan.org/u/Xianerd)\
**Post date:** [January 15, 2018, 8:40pm UTC](https://discourse.mc-stan.org/t/trying-deprecated-constructor-please-alert-package-maintainer-error-in-new-cppobject-xp-fields-module-fields-pointer/2993/3 "2018-01-15T20:40:08Z")

</div>

stan.m="  
data {  
int\<lower=0\> N[1];  
vector\<lower=0\>[N[1]] dose;  
real\<lower=0\> dr;  
int DLT[N[1]];  
int total[N[1]];

vector[2] mu;  
cov\_matrix[2] Sigma;  
}  
parameters {  
vector[2] log\_ab;  
}

transformed parameters {  
real log\_a = log\_ab[1];  
real log\_b = log\_ab[2];  
real\<lower=0\> b = exp(log\_b);  
}

model {  
vector[N[1]] prob;  
// Prior  
log\_ab~multi\_normal(mu, Sigma);  
//likelihood

for(i in 1:N[1]){  
prob[i]=exp(log\_a + b_log(dose[i]/dr))/(1+exp(log\_a + b_log(dose[i]/dr)));  
DLT[i] ~ binomial(total[i],prob[i]);  
}  
}  
"  
mu.loga=-3.025  
mu.logb=0.023

sig.loga=1.810  
sig.logb=1.023

rho=-0.450

cov.ab=rho_sig.loga_sig.logb

mu=c(mu.loga,mu.logb)  
Sigma=rbind(c(sig.loga^2,cov.ab),c(cov.ab,sig.logb^2))

stan\_data \<- list(  
dose = as.array(c(800)),  
total = as.array(c(7)),  
DLT = as.array(c(1)),  
N = 1,  
dr = 400,

mu = mu,  
Sigma = Sigma,  
Rho = rho  
)

fit = stan(model\_code=stan.m, data=stan\_data, iter=1000, chains=4,thin=2)

Thank you so much for your reply! Please see the above code. I tried to add as.array() and add the multiplier, but it did not work out. Any other suggestions? Thank you!

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [January 15, 2018, 8:51pm UTC](https://discourse.mc-stan.org/t/trying-deprecated-constructor-please-alert-package-maintainer-error-in-new-cppobject-xp-fields-module-fields-pointer/2993/4 "2018-01-15T20:51:14Z")

</div>

Yes

> [@bgoodri](#):
>
> You should just do
> 
> int\<lower=0\> N;
> 
> and then replace all the N[1] with N.

---

<div class="post-metadata">

**Author:** ![Xianerd](https://avatars.discourse-cdn.com/v4/letter/x/dfb087/32.png) [@Xianerd](https://discourse.mc-stan.org/u/Xianerd)\
**Post date:** [January 15, 2018, 8:54pm UTC](https://discourse.mc-stan.org/t/trying-deprecated-constructor-please-alert-package-maintainer-error-in-new-cppobject-xp-fields-module-fields-pointer/2993/5 "2018-01-15T20:54:16Z")

</div>

It worked, thank you very much!

---

<div class="post-metadata">

**Author:** ![Xianerd](https://avatars.discourse-cdn.com/v4/letter/x/dfb087/32.png) [@Xianerd](https://discourse.mc-stan.org/u/Xianerd)\
**Post date:** [January 15, 2018, 8:55pm UTC](https://discourse.mc-stan.org/t/trying-deprecated-constructor-please-alert-package-maintainer-error-in-new-cppobject-xp-fields-module-fields-pointer/2993/6 "2018-01-15T20:55:26Z")

</div>

I posted another question with link

> [@Help! trying deprecated constructor; please alert package maintainer Error in new\_CppObject\_xp(fields$.module, fields$.pointer, ...)](http://discourse.mc-stan.org/t/help-trying-deprecated-constructor-please-alert-package-maintainer-error-in-new-cppobject-xp-fields-module-fields-pointer/2994):
>
> Hi, I have the following stan model and running code but got the error messages. Would anyone please take a look and give some advice? Thank you very much! trying deprecated constructor; please alert package maintainer Error in new\_CppObject\_xp(fields$.module, fields$.pointer, …) : no valid constructor available for the argument list In addition: Warning message: In if (nchar(CXX) \> 0) return(TRUE) : the condition has length \> 1 and only the first element will be used failed to create th…

I appreciate if you can advice as well!

Thank you!

---

<div class="post-metadata">

**Author:** ![Xianerd](https://avatars.discourse-cdn.com/v4/letter/x/dfb087/32.png) [@Xianerd](https://discourse.mc-stan.org/u/Xianerd)\
**Post date:** [January 15, 2018, 9:32pm UTC](https://discourse.mc-stan.org/t/trying-deprecated-constructor-please-alert-package-maintainer-error-in-new-cppobject-xp-fields-module-fields-pointer/2993/7 "2018-01-15T21:32:17Z")

</div>

Hello, would you please help me with my other question? I am very new to stan and still learning the language. When the code could not go through, it is really frustrated. I appreciate that you helped me with my first question and the code went through successfully. I really appreciate your time taking a look of my other similar question. Thank you very much!!!

---

<div class="post-metadata">

**Author:** ![Xianerd](https://avatars.discourse-cdn.com/v4/letter/x/dfb087/32.png) [@Xianerd](https://discourse.mc-stan.org/u/Xianerd)\
**Post date:** [January 15, 2018, 9:32pm UTC](https://discourse.mc-stan.org/t/trying-deprecated-constructor-please-alert-package-maintainer-error-in-new-cppobject-xp-fields-module-fields-pointer/2993/8 "2018-01-15T21:32:51Z")

</div>

> [@Xianerd](#):
>
> It worked, thank you very much!

It worked, thank you very much!
