Skip to content

Commit

Permalink
Merge pull request #9 from bdilday/fit-closure-refactor-for-speedup
Browse files Browse the repository at this point in the history
refactored nd_min_fun
  • Loading branch information
bdilday authored Apr 8, 2018
2 parents bfb963f + 02549f7 commit a073a75
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions R/main.R
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,19 @@ nd_min_fun <- function(ev) {

# make sure the data is a data frame, not a tibble
ev$fr <- as.data.frame(ev$fr)

glf <- lme4::glFormula(ev$frm,
data=ev$fr, family='binomial')
fe <- fixed_effects <- (glf$X)
re <- random_effects <- Matrix::t(glf$reTrms$Zt)

y <- matrix(ev$fr[,all.vars(ev$frm)[[1]]], ncol=1)
k_class <- max(y)
k <- max(y)
Lind = glf$reTrms$Lind
fe2 <- Matrix::Matrix(fe, sparse = TRUE)

function(mval) {
glf <- lme4::glFormula(ev$frm,
data=ev$fr, family='binomial')
fe <- fixed_effects <- (glf$X)
re <- random_effects <- Matrix::t(glf$reTrms$Zt)

y <- matrix(ev$fr[,all.vars(ev$frm)[[1]]], ncol=1)
k_class <- max(y)
k <- max(y)
Lind = glf$reTrms$Lind

s = 'mval '
for (v in mval) {
Expand All @@ -229,8 +231,6 @@ nd_min_fun <- function(ev) {

theta_mat <- matrix(mval, ncol=k_class)

fe2 <- Matrix::Matrix(fe, sparse = TRUE)

if (! "beta_re" %in% names(ev)) {
ev$beta_re <- matrix(rnorm(ncol(re) * k_class, 0, 0.2), ncol=k_class)
}
Expand Down

0 comments on commit a073a75

Please sign in to comment.