Skip to content

Instantly share code, notes, and snippets.

View nrode's full-sized avatar

nrode

View GitHub Profile
@nrode
nrode / Multiple-membership model with nlmer
Created June 16, 2017 19:39
Try to extract the design matrix of the random effects to fit a multiple-membership model in nlmer
#################################
## 0/ simulate the data ##
#################################
set.seed(123)
N2 <- 50 # set the number of groups (higher level units)
N <- 1000 # number of observations
NM <- 2 # number of groups per observation
@nrode
nrode / AR1, exp, Matern model with ASReml-R and spaMM
Last active February 23, 2017 11:22
Compare AR1, exponential and Matern models (with between spatially correlated error variance and spatially uncorrelated (nugget) error variance using ASReml-R/spaMM
---
title: "spaMM"
output: html_document
---
## Goal of this document: Compare AR1, exponential and Matern models (with between spatially correlated error variance and spatially uncorrelated (nugget) error variance using ASReml-R/spaMM
# Simulations
```{r}
## For a general intro see: http://kimura.univ-montp2.fr/%7Erousset/spaMM/spaMMintro.pdf
@nrode
nrode / multiple-membership.R
Last active August 29, 2015 14:26
R - lmer drops unused levels in a random effect
## Goal of this document: show that the first step of lmer (using 'lFormula') drops unused levels in a random effect
## 0/ Simulates some data
## 1/ Shows a way to trick lmer when the number of levels is lower than the number of observations
## 2/ Shows how this fail when the number of levels is higher than the number of observations
set.seed(3)
library(lme4)
#################################
## 0/ simulate the data ##