nlme

Obtaining random-effects matrices from a mixed model

↘锁芯ラ 提交于 2021-02-18 08:43:31
问题 In my below code, I was wondering how I can obtain the equivalent of out and Ts from an lme() object in the library(nlme) ? dat <- read.csv("https://raw.githubusercontent.com/rnorouzian/v/main/mv.l.csv") library(lme4) x <- lmer(value ~0 + name+ (1| School/Student), data = dat, control = lmerControl(check.nobs.vs.nRE= "ignore")) lwr <- getME(x, "lower") theta <- getME(x, "theta") out = any(theta[lwr == 0] < 1e-4) # find this from `x1` object below Ts = getME(x, "Tlist") # find this from `x1`

Obtaining random-effects matrices from a mixed model

被刻印的时光 ゝ 提交于 2021-02-18 08:42:23
问题 In my below code, I was wondering how I can obtain the equivalent of out and Ts from an lme() object in the library(nlme) ? dat <- read.csv("https://raw.githubusercontent.com/rnorouzian/v/main/mv.l.csv") library(lme4) x <- lmer(value ~0 + name+ (1| School/Student), data = dat, control = lmerControl(check.nobs.vs.nRE= "ignore")) lwr <- getME(x, "lower") theta <- getME(x, "theta") out = any(theta[lwr == 0] < 1e-4) # find this from `x1` object below Ts = getME(x, "Tlist") # find this from `x1`

R: lme, cannot evaluate groups for desired levels on 'newdata'

二次信任 提交于 2021-02-11 15:25:33
问题 I'm running an lme -model from the package nlme on R v.3.0.2. I'm trying to extract the model estimates with predict.lme , but it returns an error. Here's the code to replicate the error: my.model = lme(fixed = Maxi ~ Time*Origin, random = ~ 1 |Genotype, method = "REML", weights=varPower(), data=dd) new.my.model <- data.frame(Origin = c("Ka", "Ka", "La", "La"), Time = c("mor", "eve", "mor", "eve")) predict(my.model, new.my.model, level = 0:1) #Error in predict.lme(my.model, new.my.model,

fitting first order equation with nlme and lsoda

試著忘記壹切 提交于 2021-02-08 14:27:08
问题 I a trying to fit a first order differential model using nlme and lsoda . Here is the basic idea: I first define the function allowing to generate the solution of the differential equation: library(deSolve) ODE1 <- function(time, x, parms) {with(as.list(c(parms, x)), { import <- excfunc(time) dS <- import*k/tau - (S-yo)/tau res <- c(dS) list(res)})} solution_ODE1 = function(tau1,k1,yo1,excitation,time){ excfunc <- approxfun(time, excitation, rule = 2) parms <- c(tau = tau1, k = k1, yo = yo1,

combine two plots into one plot in a mixed-model plot

点点圈 提交于 2021-02-08 06:41:06
问题 In my plot below, d_math and d_hyp are each {0,1} variables. Given this fact, in my plot below, I was wondering if we can combine the two plots into one, just like in the desired plot further below? ps. I'm open to any R packages. multivariate <- read.csv('https://raw.githubusercontent.com/hkil/m/master/bv.csv') library(nlme) library(effects) # for plot m2 <- lme(var ~ 0 + d_math + d_hyp + d_math:I(grade-2) + d_hyp:I(grade-2), random = ~ 0 + d_math + d_hyp + d_math:I(grade-2) + d_hyp:I(grade

combine two plots into one plot in a mixed-model plot

早过忘川 提交于 2021-02-08 06:40:55
问题 In my plot below, d_math and d_hyp are each {0,1} variables. Given this fact, in my plot below, I was wondering if we can combine the two plots into one, just like in the desired plot further below? ps. I'm open to any R packages. multivariate <- read.csv('https://raw.githubusercontent.com/hkil/m/master/bv.csv') library(nlme) library(effects) # for plot m2 <- lme(var ~ 0 + d_math + d_hyp + d_math:I(grade-2) + d_hyp:I(grade-2), random = ~ 0 + d_math + d_hyp + d_math:I(grade-2) + d_hyp:I(grade

How to do specific, custom contrasts in EMMEANs with multiple nested factor levels but without subsetting data

假装没事ソ 提交于 2021-02-05 09:23:06
问题 Here is my data frame (my real DF has way more data points): rearing.temp<-c("15", "15", "15", "15", "19", "19", "19", "19") source<-c("field", "field", "woods", "woods", "field", "field", "woods", "woods") runway.temp<-c("40","20","40","20","40","20","40","20") velocity<-c("2.3", "2.1", "1.9", "1.9", "2.3", "2.2", "2.3", "2.0") snail<-data.frame(rearing.temp, source, runway.temp, velocity) Here is my model: mod <- lmer(velocity ~ runway.temp*source*rearing.temp + (1|family) + (1|collection

visualising linear mixed model in R

六月ゝ 毕业季﹏ 提交于 2021-01-29 13:15:48
问题 I am running a linear mixed model for a dataset Developmental trajectory of 2 groups- assessed at 3 timepoints on a number of different measures. Predictor variables are age and maternal education. I am using nlme and ggplot2 packages. Here is my final model (GM_RAW is the dependent variable) Model_5<-lme(GM_RAW~timepoint*Group+age+Maternal_Education, data=dat, random=~timepoint|ID,method="ML", na.action=na.omit,control=list(opt="optim")) summary(Model_5) I have plotted individual

Multiple random effects in a linear mixed model with nlme and lme4

可紊 提交于 2021-01-29 06:17:40
问题 I would like to study differences in fat between 2 visits with a linear mixed effects model. So everything would start as lme(fat~ , now... for the coefficients, I have some that will change from visit 1 to visit 2, as they are hypertension status, diabetis status, bmi, waist circunference, smoking_status etc. And other variables that won't change from visit 1 to visit 2, as they are gender or ethnicity. Note that the following variables are dummy ( hypertension status, diabetis status,

Passing strings into 'contrasts' argument of lme/lmer

时光怂恿深爱的人放手 提交于 2021-01-28 11:47:09
问题 I am writing a sub-routine to return output of longitudinal mixed-effects models. I want to be able to pass elements from lists of variables into lme/lmer as the outcome and predictor variables. I would also like to be able to specify contrasts within these mixed-effects models, however I am having trouble with getting the contrasts() argument to recognise the strings as the variable names referred to in the model specification within the same lme/lme4 call. Here's some toy data, set.seed(345