[ESS] emacs theme for polymode with noweb files
Dear ESS-list, I tried many dark color themes to do literate programming with polymode (.rnw file) but there are always some drawbacks : the color of the beginning and the end of the chunks (<<>>= and @) are unreadable, the color of the text when I want to see the available buffers (C-x C-b) is unreadable, etc... May you please tell me the name of a color theme which works fine with polymode for noweb files ? I tried to find an answer on the web without success. Thank you Best regards Laurent __ ESS-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/ess-help
Re: [R] back tick names with predict function
On 12/1/2023 11:47 AM, peter dalgaard wrote: Also, and possibly more constructively, when you get an error like CI.c = predict(mod2, data.frame( `plant-density` = x), interval = 'c') # fail Error in eval(predvars, data, env) : object 'plant-density' not found you should check your assumptions. Does "newdata" actually contain a columnn called "plant-density": Great advice/strategy. Thanks! head(data.frame( `plant-density` = x)) plant.density 1 65.0 2 65.11912 3 65.23824 4 65.35736 5 65.47648 6 65.59560 I.e., it doesn't. So check help for data.frame and looking for something with names. On 1 Dec 2023, at 01:47 , Bert Gunter wrote: "Thank you Rui. I didn't know about the check.names = FALSE argument. Another good reminder to always read help, but I'm not sure I understood what help to read in this case" ?data.frame , of course, which says: "check.names logical. If TRUE then the names of the variables in the data frame are checked to ensure that they are syntactically valid variable names and are not duplicated. If necessary they are adjusted (by make.names) so that they are. " -- Bert __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [ESS] [R-win] Difficulty installing R packages under Windows 11 / Cygwin
On 2 December 2023 at 22:06, Tomas Kalibera via ESS-help wrote: | R is not being tested under WSL. (From several arm lengths away:) WSL2 appears to be very solid. I had an early alpha tester of my (then brand-new) r2u [1] using and stressing it, it appears to work a like regular Ubuntu system so 'everything just works' yet it is on Windows. (Which I haven't touched in a decade+.) Dirk [1] r2u provides all of CRAN plus ~ 400 BioC package via apt with bspm as added interface. So say install.packages(c("tidyverse", "rstan", "brms")) and everything installs as binaries in 33 secs [2] with _all_ system dependencies resolved via apt. (Also FYI, Inaki has a similar system for Fedora called cran2copr.) More about r2u is at https://eddelbuettel.github.io/r2u [2] Vidoe of that command running in 33 seconds in an empty container with only R and r2u is at: https://eddelbuettel.github.io/images/2023-12-03/r2u_tidyverse_rstan_brms_33secs_2023-12-03_07-26.gif -- dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org __ ESS-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/ess-help
Re: [R] Try reproduce glmm by hand
Dear Marc, Plugging the BLUPs into the likelihood isn't going to give you the ll of the model. You need to integrate over the random effect. intfun <- function(nu, xi, mi, pred, theta) dbinom(xi, xi+mi, plogis(nu)) * dnorm(nu, pred, theta) lli <- rep(NA, nrow(df)) for (i in 1:nrow(df)) { lli[i] <- log(integrate(intfun, xi=df[i,1], mi=df[i,2], pred=fixep[1] + fixep[2]*x[i], theta=par$theta, lower=-Inf, upper=Inf)$value) } -sum(lli) Best, Wolfgang > -Original Message- > From: R-help On Behalf Of Marc Girondot via R- > help > Sent: Saturday, December 2, 2023 17:36 > To: Marc Girondot via R-help > Subject: [R] Try reproduce glmm by hand > > Dear all, > > In order to be sure I understand glmm correctly, I try to reproduce by > hand a simple result. Here is a reproducible code. The questions are in > _ > > Of course I have tried to find the solution using internet but I was not > able to find a solution. I have also tried to follow glmer but it is > very complicated code! > > Thanks for any help. > > Marc > > # Generate set of df with nb successes and failures > # and ID being A, B or C (the random effect) > # and x being the fixed effect > set.seed(1) > df <- rbind(matrix(data = c(sample(x=5:30, size=40, replace = TRUE), > rep(10, 40)), ncol=2), > matrix(data = c(sample(x=10:30, size=40, replace = TRUE), > rep(10, 40)), ncol=2), > matrix(data = c(sample(x=20:30, size=40, replace = TRUE), > rep(10, 40)), ncol=2)) > ID <- as.factor(c(rep("A", 40), rep("B", 40), rep("C", 40))) > x <- c(runif(40, min=10, max=30), runif(40, min=20, max=30), runif(40, > min=40, max=60)) > x <- (x-min(x))/(max(x)-min(x)) > > # In g0, I have the results of the glmm > library(lme4) > g0 <- glmer(formula = df ~ x + (1 | ID), family = > binomial(link="logit"), nAGQ=1) > -logLik(g0) # 'log Lik.' 268.0188 (df=3) > # I get the fitted parameters > fixep <- fixef(g0) > par <- getME(g0, c("theta","beta")) > # ___ > # Question 1: how theta is converted into the specific effect on > (intercept) for the random effect ? > # Then how a theta parameter is converted into intercepts? > # ___ > intercepts <- ranef(g0)$ID > > # This part is ok, the predict is correct > pfit <- 1-c(1/(1+exp(fixep["(Intercept)"]+intercepts["A", > 1]+x[ID=="A"]*fixep["x"])), >1/(1+exp(fixep["(Intercept)"]+intercepts["B", > 1]+x[ID=="B"]*fixep["x"])), >1/(1+exp(fixep["(Intercept)"]+intercepts["C", 1]+x[ID=="C"]*fixep["x"]))) > > predict(g0, type = "response") > > # ___ > # Why I obtain 266.4874 and not 268.0188 as in -logLik(g0)? > # ___ > -sum(dbinom(x=df[, 1], size=df[, 1]+df[, 2], prob=pfit, log=TRUE)) # > 266.4874 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.