Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cleanup.win
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
# Note to Windows users: This is not actually platform specific.
"${R_HOME}/bin/R" --vanilla --slave -e 'roxygen2::roxygenize(load_code = roxygen2::load_source, clean = TRUE)'
cp -r src/stan_files tests/testthat/stan_files
cp -r inst/include tests/testthat/include
exit $?
6 changes: 0 additions & 6 deletions dev-notes/rstanarm_dev_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,6 @@ A brief description of what (generally) goes into each the various files/folders

For example, `continuous.stan` contains all the models that can be declared by `stan_glm` (as well as some others). You can view the compiled model in R by executing `rstanarm:::stanmodels$continuous`.

**`inst/include/` **

This folder can include separate header files (ending with `.hpp`) that implement custom C++
functions. If you add something, be sure to include it in `meta_header.hpp` and test it inside
`tests.cpp`.

**`data`**

* Example data used in the examples/tests.
Expand Down
54 changes: 0 additions & 54 deletions inst/include/csr_matrix_times_vector2.hpp

This file was deleted.

5 changes: 0 additions & 5 deletions inst/include/meta_header.hpp

This file was deleted.

18 changes: 0 additions & 18 deletions inst/include/tests.cpp

This file was deleted.

16 changes: 0 additions & 16 deletions src/stan_files/continuous.stan
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,6 @@ functions {
return -0.5 * (quad_form(XtX, coeff - OLS) + SSR) / square(sigma)
- N * (log(sigma) + log(sqrt(2 * pi())));
}

/**
* test function for csr_matrix_times_vector
*
* @param m Integer number of rows
* @param n Integer number of columns
* @param w Vector (see reference manual)
* @param v Integer array (see reference manual)
* @param u Integer array (see reference manual)
* @param b Vector that is multiplied from the left by the CSR matrix
* @return A vector that is the product of the CSR matrix and b
*/
vector test_csr_matrix_times_vector(int m, int n, vector w,
int[] v, int[] u, vector b) {
return csr_matrix_times_vector(m, n, w, v, u, b);
}
}
data {
// declares N, K, X, xbar, dense_X, nnz_x, w_x, v_x, u_x
Expand Down
15 changes: 0 additions & 15 deletions src/stan_files/functions/common_functions.stan
Original file line number Diff line number Diff line change
Expand Up @@ -247,21 +247,6 @@
return V;
}

/**
* faster version of csr_matrix_times_vector
* declared here and defined in C++
*
* @param m Integer number of rows
* @param n Integer number of columns
* @param w Vector (see reference manual)
* @param v Integer array (see reference manual)
* @param u Integer array (see reference manual)
* @param b Vector that is multiplied from the left by the CSR matrix
* @return A vector that is the product of the CSR matrix and b
*/
vector csr_matrix_times_vector2(int m, int n, vector w,
int[] v, int[] u, vector b);

/**
* Calculate lower bound on intercept
*
Expand Down
2 changes: 1 addition & 1 deletion src/stan_files/model/eta_add_Zb.stan
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
if (special_case) for (i in 1:t) eta += b[V[i]];
else eta += csr_matrix_times_vector2(N, q, w, v, u, b);
else eta += csr_matrix_times_vector(N, q, w, v, u, b);
2 changes: 1 addition & 1 deletion src/stan_files/model/make_eta.stan
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
vector[N] eta; // linear predictor
if (K > 0) {
if (dense_X) eta = X[1] * beta;
else eta = csr_matrix_times_vector2(N, K, w_X, v_X, u_X, beta);
else eta = csr_matrix_times_vector(N, K, w_X, v_X, u_X, beta);
}
else eta = rep_vector(0.0, N);
if (has_offset == 1) eta += offset_;
Expand Down
8 changes: 4 additions & 4 deletions src/stan_files/model/make_eta_bern.stan
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
eta1 = N[2] > 0 ? X1[1] * beta : rep_vector(0.0, 0);
}
else {
eta0 = csr_matrix_times_vector2(N[1], K, w_X0, v_X0, u_X0, beta);
eta1 = csr_matrix_times_vector2(N[2], K, w_X1, v_X1, u_X1, beta);
eta0 = csr_matrix_times_vector(N[1], K, w_X0, v_X0, u_X0, beta);
eta1 = csr_matrix_times_vector(N[2], K, w_X1, v_X1, u_X1, beta);
}
}
else {
Expand All @@ -31,6 +31,6 @@
if (N[1] > 0) eta0 += b[V0[i]];
if (N[2] > 0) eta1 += b[V1[i]];
} else if (t > 0) {
if (N[1] > 0) eta0 += csr_matrix_times_vector2(N[1], q, w0, v0, u0, b);
if (N[2] > 0) eta1 += csr_matrix_times_vector2(N[2], q, w1, v1, u1, b);
if (N[1] > 0) eta0 += csr_matrix_times_vector(N[1], q, w0, v0, u0, b);
if (N[2] > 0) eta1 += csr_matrix_times_vector(N[2], q, w1, v1, u1, b);
}
14 changes: 0 additions & 14 deletions src/stan_files/polr.stan
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,6 @@ functions {
else reject("invalid link");
return ystar;
}

/**
* faster version of csr_matrix_times_vector
* declared here and defined in C++
*
* @param m Integer number of rows
* @param n Integer number of columns
* @param w Vector (see reference manual)
* @param v Integer array (see reference manual)
* @param u Integer array (see reference manual)
* @param b Vector that is multiplied from the left by the CSR matrix
* @return A vector that is the product of the CSR matrix and b
*/
vector csr_matrix_times_vector2(int m, int n, vector w, int[] v, int[] u, vector b);
}
data {
// declares N, K, X, xbar, dense_X, nnz_x, w_x, v_x, u_x
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/include

This file was deleted.

7 changes: 0 additions & 7 deletions tests/testthat/test_stan_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ functions <- sapply(dir(MODELS_HOME, pattern = "stan$", full.names = TRUE), func
} else return(as.character(NULL))
})
names(functions) <- basename(names(functions))
functions$polr.stan <- grep("csr_matrix_times_vector2",
functions$polr.stan,
value = TRUE, fixed = TRUE, invert = TRUE)
functions <- c(unlist(lapply(file.path(MODELS_HOME, "functions",
c("common_functions.stan",
"bernoulli_likelihoods.stan",
Expand All @@ -65,7 +62,6 @@ model_code <- paste(c("functions {", functions, "}"), collapse = "\n")
stanc_ret <- stanc(model_code = model_code, model_name = "Stan Functions",
allow_undefined = TRUE)
expose_stan_functions(stanc_ret, rebuild = TRUE, verbose = TRUE)
Rcpp::sourceCpp(file.path(INCLUDE_DIR, "tests.cpp"), rebuild = TRUE, verbose = TRUE)
N <- 99L

# bernoulli
Expand Down Expand Up @@ -399,16 +395,13 @@ if (require(lme4) && require(HSAUR3)) test_that("the Stan equivalent of lme4's Z
tol = 1e-14)

parts <- extract_sparse_parts(Z)
Zb <- csr_matrix_times_vector2_test(nrow(Z), ncol(Z), parts$w,
parts$v - 1L, parts$u - 1L, b)
expect_equal(Zb, as.vector(Z %*% b), tol = 1e-14)
if (all(sapply(group$cnms, FUN = function(x) {
length(x) == 1 && x == "(Intercept)"
})) ) {
V <- matrix(parts$v, nrow = sum(p), ncol = nrow(Z))
expect_true(all(V ==
t(as.matrix(as.data.frame(make_V(nrow(Z), nrow(V), parts$v - 1L))))))
expect_equal(Zb, apply(V, 2, FUN = function(v) sum(b[v])))
}
}
test_lme4(glFormula(Reaction ~ Days + (Days | Subject), data = sleepstudy)$reTrms)
Expand Down
2 changes: 0 additions & 2 deletions tools/make_cc.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ make_cc <- function(file) {
file <- sub("\\.cc$", ".stan", file)
cppcode <- rstan::stanc(file, allow_undefined = TRUE,
obfuscate_model_name = FALSE)$cppcode
cppcode <- sub("(class[[:space:]][A-Za-z_][A-Za-z0-9_]*[[:space:]])",
paste("#include <meta_header.hpp>\n", "\\1"), cppcode)

cat(readLines(dir("stan_files", pattern = "license.stan", recursive = TRUE, full.names = TRUE)),
"#ifndef MODELS_HPP", "#define MODELS_HPP", "#define STAN__SERVICES__COMMAND_HPP",
Expand Down