Articles

Affichage des articles du décembre, 2018

SE for all levels of a factor after a glmm

When you are doing a LM, GLM or GLMM with fixed effect with categorical variable, it is impossible to get the SE for all levels because always one level is fixed to 0. But sometimes, you need to know how this level is really known. Two solutions are presented for this problem. The first solution is to force the intercept to be 0 but it works only when there is only one categorical fixed factor. The second is to use a method know as quasi-variance: Firth, D., de Mezezes, R.X., 2004. Quasi-variances. Biometrika 91, 65-80. It is available in package qvcalc for lm() and glm() and in package HelpersMG for lmer(). Here is an example with lmer(): x <- rnorm(100) y <- rnorm(100) G <- as.factor(sample(c("A", "B", "C", "D"), 100, replace = TRUE)) H <- as.factor(sample(c("A", "B", "C", "D"), 100, replace = TRUE)) R <- as.factor(rep(1:25, 4)) G <- relevel(G, "A") H <-

Insert a plot as a vignette in another plot

Image
Let show how to use par(fig=c(x0, x1, y0, y1)) library(maps) par(fig=c(0, 1, 0, 1)) par(mar=c(4, 4, 1, 2)) map("world", region=c("Sao Tome and Principe:Ilha da Sao Tome",                       "Sao Tome and Principe:Ilha do Principe"),     xlim=c(6, 8), ylim=c(0,2),     asp=1) library(sp) degAxis(side=1, cex.axis=0.8) # in package sp degAxis(side= 2, las=1, cex.axis=0.8) par(fig=c(0.5, 0.9, 0.1, 0.5)) par(new=TRUE) par(mar=c(0, 0, 0, 0)) plot(x=c(-180,180), y=c(-90,90), type="n", axes=FALSE, xlab="n", ylab="n") polygon(x=c(-180, -180, 180, 180), y=c(-90, 90, 90, -90)) par(new=TRUE) map("world", asp=1, add=TRUE, fill=TRUE, col="grey", border=NA) polygon(x=c(6, 6, 8, 8), y=c(0, 2, 2, 0)) library(maps) par(fig=c(0, 1, 0, 1)) par(mar=c(4, 4, 1, 2)) map("world", region=c("Sao Tome and Principe:Ilha da Sao Tome",                       "Sao Tome and Pr

What to do with error : ERROR: failed to lock directory ‘/usr/local/lib/R/site-library’ for modifying

Just after this advice appears: Try removing ‘/usr/local/lib/R/site-library/00LOCK-quantreg’ Then I did: cd /usr/local/lib/R/site-library/ sudo rm -rf 00LOCK-quantreg And I could install the package

Install rJava on ubuntu 18.04

sudo apt-get install openjdk-11-jdk sudo R CMD javareconf JAVA_HOME= /usr/lib/jvm/java-11-openjdk-amd64 sudo R install.packages("rJava")