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

logt_update_SMLN is broken #38

Open
nathansam opened this issue Apr 29, 2020 · 2 comments
Open

logt_update_SMLN is broken #38

nathansam opened this issue Apr 29, 2020 · 2 comments

Comments

@nathansam
Copy link
Owner

Issue

R version of logt_update_SMLN returns different result to C++ version. This is believed to be caused by the way rtnorm is working and it's upper/lower arguments. Possibly in differences from passing upper and lower from R and from within C++.

@nathansam
Copy link
Owner Author

Function behaves as expected for observations where Cens = 0. Implying the issue only applies when infinite limits are being used.

nathansam added a commit that referenced this issue Apr 29, 2020
@nathansam
Copy link
Owner Author

BASSLINE/src/code.cpp

Lines 973 to 1012 in 1aa7302

// [[Rcpp::export]]
arma::vec logt_update_SMLN (arma::vec Time, arma::vec Cens,
arma::mat X, arma::vec beta, double sigma2,
bool set, double eps_l, double eps_r) {
int n = Time.n_elem;
arma::vec aux(n);
arma::vec MEAN = X * beta;
arma::vec sdVec (n);
sdVec.fill(sqrt(sigma2));
arma::vec maxUpper (n);
maxUpper.fill(1e10);
if (set == true) {
arma::vec TimeGreater(n);
for (int i = 0; i < n; i++){
if (Time[i] > eps_l){
TimeGreater[i] = 1;
}
}
arma::vec minLower(n);
minLower.fill(-1e10);
aux = Cens % (TimeGreater %
rtnorm(n, log(abs(Time - eps_l)), log(Time + eps_r), MEAN, sdVec) +
(1 - TimeGreater) % rtnorm(n, minLower, log(Time + eps_r), MEAN,
sdVec)) + (1 - Cens) %
rtnorm(n, log(Time), maxUpper, MEAN, sdVec);
} else{
aux = Cens % log(Time) + (1 - Cens) %
rtnorm(n, log(Time), maxUpper, MEAN, sdVec);
}
return aux;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant