Skip to content

Commit

Permalink
Merge branch 'master' of github.com:lme4/lme4
Browse files Browse the repository at this point in the history
  • Loading branch information
bbolker committed Apr 21, 2024
2 parents d6e19ae + a1094d5 commit 6f8b5d9
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .Rbuildignore
Expand Up @@ -37,4 +37,4 @@ src/mcmcsamp\.cpp$
revdep/
Rplots.pdf
R/scaleX.R

\.Rout
33 changes: 28 additions & 5 deletions .github/workflows/rhub.yaml
Expand Up @@ -60,10 +60,37 @@ jobs:
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: teatimeguest/setup-texlive-action@v3
with:
packages: >-
scheme-basic
inputenc
graphicx
array
colortbl
multirow
hhline
calc
tabularx
threeparttable
wrapfig
url
hyperref
fancyvrb
natbib
xcolor
etoolbox
caption
adjustbox
thumbpdf
framed
blkarray
- uses: r-hub/rhub2/actions/rhub-run-check@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
build_args: 'c("--compact-vignettes=both")'


other-platforms:
needs: setup
Expand All @@ -90,7 +117,6 @@ jobs:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
- uses: teatimeguest/setup-texlive-action@v3
if: runner.os != 'Linux'
with:
packages: >-
scheme-basic
Expand All @@ -115,11 +141,8 @@ jobs:
thumbpdf
framed
blkarray
- name: Install LaTeX etc.
if: runner.os == 'Linux'
run: |
sudo apt-get install texlive texlive-science texlive-latex-base texlive-latex-extra texlive-bibtex-extra
- uses: r-hub/rhub2/actions/rhub-run-check@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
build_args: 'c("--compact-vignettes=both")'
2 changes: 1 addition & 1 deletion inst/NEWS.Rd
Expand Up @@ -7,7 +7,7 @@
\section{CHANGES IN VERSION 1.1-35.3}{
\subsection{BUG FIXES}{
\itemize{
bug-fix for ASAN/memory access problem in CholmodDecomposition,
\item bug-fix for ASAN/memory access problem in CholmodDecomposition,
(Mikael Jagan)
}
} % bug fixes
Expand Down
40 changes: 40 additions & 0 deletions misc/lme4_bigpred.R
@@ -0,0 +1,40 @@
library(lme4)
print(packageVersion("Matrix"))
m1 <- lmer(Reaction 1~ Days + (Days|Subject), data = sleepstudy)
predict(m1, newdata = sleepstudy, se.fit = TRUE)
simulate(~Days + (Days|Subject),
newdata = sleepstudy,
newparams = list(beta = c(250, 1),
theta = c(1, 1, 1),
sigma = 1),
family = gaussian)

set.seed(101)
dd <- expand.grid(id = factor(1:1000), year = 1:15)
d_age <- data.frame(id = factor(1:1000),
age0 = sample(20:50, size = 1000, replace= TRUE))
dd2 <- merge(dd, d_age, by = "id") |>
transform(age = age0 + year,
score = sample(1:50, size = nrow(dd), replace = TRUE))
form <- adl~I(year^2)+score*year + age*year + (1+year|id)
colnames(X <- model.matrix(nobars(form[-2]), data = dd2))
beta_vec <- c(20, 0.1, 0.5, 1, 1, 0.5, 0.5)
stopifnot(ncol(X) == length(beta_vec))
dd2$adl <- simulate(form[-2],
newdata = dd2,
newparams = list(beta = beta_vec,
theta = c(2, 0.1, 0),
sigma = 1),
family = gaussian)[[1]]

fit <- lmer(form, data = dd2)

pred.dd <- expand.grid(age = 50:100, year = 1:15,
score = seq(min(dd2$score), max(dd2$score), length.out=100),
id = sample(dd2$id, size = 10, replace = FALSE))

pred <- predict(fit, newdata = pred.dd) ## OK
pred <- predict(fit, newdata = pred.dd, se.fit = TRUE)

pred <- predict(fit, newdata = pred.dd[sample(nrow(pred.dd), size = 1000,
replace = FALSE),], se.fit = TRUE)
33 changes: 1 addition & 32 deletions src/lme4CholmodDecomposition.h
Expand Up @@ -75,38 +75,7 @@ namespace lme4 {

template<typename T>
SEXP Eigen_cholmod_wrap(const lme4CholmodDecomposition<Eigen::SparseMatrix<T> >& obj) {
typedef T* Tpt;
const cholmod_factor* f = obj.factor();
if (f->minor < f->n)
throw std::runtime_error("CHOLMOD factorization was unsuccessful");

//FIXME: Should extend this selection according to T
::Rcpp::S4 ans(std::string(f->is_super ? "dCHMsuper" : "dCHMsimpl"));
::Rcpp::IntegerVector dd(2);
dd[0] = dd[1] = f->n;
ans.slot("Dim") = dd;
ans.slot("perm") = ::Rcpp::wrap((int*)f->Perm, (int*)f->Perm + f->n);
ans.slot("colcount") = ::Rcpp::wrap((int*)f->ColCount, (int*)f->ColCount + f->n);
::Rcpp::IntegerVector tt(f->is_super ? 6 : 4);
tt[0] = f->ordering; tt[1] = f->is_ll;
tt[2] = f->is_super; tt[3] = f->is_monotonic;
ans.slot("type") = tt;
if (f->is_super) {
tt[4] = f->maxcsize; tt[5] = f->maxesize;
ans.slot("super") = ::Rcpp::wrap((int*)f->super, ((int*)f->super) + f->nsuper + 1);
ans.slot("pi") = ::Rcpp::wrap((int*)f->pi, ((int*)f->pi) + f->nsuper + 1);
ans.slot("px") = ::Rcpp::wrap((int*)f->px, ((int*)f->px) + f->nsuper + 1);
ans.slot("s") = ::Rcpp::wrap((int*)f->s, ((int*)f->s) + f->ssize);
ans.slot("x") = ::Rcpp::wrap((Tpt)f->x, ((T*)f->x) + f->xsize);
} else {
ans.slot("i") = ::Rcpp::wrap((int*)f->i, ((int*)f->i) + f->nzmax);
ans.slot("p") = ::Rcpp::wrap((int*)f->p, ((int*)f->p) + f->n + 1);
ans.slot("x") = ::Rcpp::wrap((Tpt)f->x, ((T*)f->x) + f->nzmax);
ans.slot("nz") = ::Rcpp::wrap((int*)f->nz, ((int*)f->nz) + f->n);
ans.slot("nxt") = ::Rcpp::wrap((int*)f->next, ((int*)f->next) + f->n + 2);
ans.slot("prv") = ::Rcpp::wrap((int*)f->prev, ((int*)f->prev) + f->n + 2);
}
return ::Rcpp::wrap(ans);
return M_chm_factor_to_SEXP(obj.factor(), 0);
}

} // namespace lme4
Expand Down

0 comments on commit 6f8b5d9

Please sign in to comment.