nlme

Error message in nlme example present in R but not in S

情到浓时终转凉″ 提交于 2019-12-10 21:24:23
问题 I am working through Mixed Effects Models in S and S-Plus in R but some of the code does not produce the results in-text. In Chapter 6 one of the examples fails to converge with the code supplied. The example is a non-linear mixed effects model performed on the Phenobarb dataset supplied with the nlme package. library(nlme) fm1Pheno.nlme <- nlme(model = conc ~ phenoModel(Subject, time, dose, lCl, lV), data = Phenobarb, fixed = lCl + lV ~ 1, random = pdDiag(lCl + lV ~ 1), start = c(-5,0), na

Specified covariance matrix in lmer in R for penalized splines

﹥>﹥吖頭↗ 提交于 2019-12-10 13:26:32
问题 I have been trying to fit a penalized spline regression model in R using the connection between penalized splines and linear mixed models. While I am quite familiar with the R function lme , using its competitor lmer presents some difficulties. Here is a toy example I would like to generalize to lmer : require(nlme) grid <- seq(0, 1, len = 100) y <- rep(0, length(grid)) for(i in 1:length(grid)){ y[i] <- sin(3*pi*grid[i]) + rnorm(1, 0, 1) } X <- cbind(rep(1, length(grid)), grid, grid^2, grid^3

package car unable to load, wrong version of nlme

五迷三道 提交于 2019-12-10 03:59:44
问题 When I try to load the 'car' package I get this error: library(car) Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : namespace 'nlme' 3.1-122 is already loaded, but >= 3.1.123 is required Error: package or namespace load failed for 'car' But when I run update.packages() there is nothing to update. I'm using MRO 3.2.3 if that matters. 回答1: I had the same problem and solved it simply by installing nlme_3.1-123.tar.gz from https://cran.r-project.org/src

lme() different results each run under Revolution R (MKL to blame?)

 ̄綄美尐妖づ 提交于 2019-12-08 20:10:08
问题 Update (Aug 2014): I never got to the bottom of this, and never got any feedback on Revolution's forum. This issue, however, seems to have been fixed in Revolution R 7.2 (with R 3.0.3, again the academic version). I ran the lme() test below a few hundred times, all produced equal results, as expected.[ end of update ] I just installed the academic version of Revolution R 7.0 (R 3.0.2) on a new PC and am getting strange results for the code below. Every time the code is run, it gives different

Making a loop for lme() in r

故事扮演 提交于 2019-12-08 06:58:30
问题 I am trying to use lme function from nlme package inside a for loop. I have tried (almost) everything now, but without any luck. Without the loop my lme function are working fine. I have 681 different lipids to analyse, so i need the loop. Bonus info: I have used str() and my data has the same lengths before the loop A simplified version of my data look like this: >dput(head("ex.lme(loop)")) structure(list(Lacal.Patient.ID = c(12L, 12L, 12L, 13L, 13L, 13L), Time = c(0L, 1L, 3L, 0L, 1L, 3L),

How do regression models deal with the factor variables?

丶灬走出姿态 提交于 2019-12-06 08:52:08
Suppose I have a data with a factor and response variable. My questions: How linear regression and mixed effect models work with the factor variables? If I have a separate model for each level of the factor variable (m3 and m4) , how does that differ with models m1 and m2 ? Which one is the best model/approach? As an example I use Orthodont data in nlme package. library(nlme) data = Orthodont data2 <- subset(data, Sex=="Male") data3 <- subset(data, Sex=="Female") m1 <- lm (distance ~ age + Sex, data = Orthodont) m2 <- lme(distance ~ age , data = Orthodont, random = ~ 1|Sex) m3 <- lm(distance ~

How to specify different random effects in nlme vs. lme4?

自闭症网瘾萝莉.ら 提交于 2019-12-06 02:04:18
问题 I want to specify different random effects in a model using nlme::lme (data at the bottom). The random effects are: 1) intercept and position varies over subject ; 2) intercept varies over comparison . This is straightforward using lme4::lmer : lmer(rating ~ 1 + position + (1 + position | subject) + (1 | comparison), data=d) > ... Random effects: Groups Name Std.Dev. Corr comparison (Intercept) 0.31877 subject (Intercept) 0.63289 position 0.06254 -1.00 Residual 0.91458 ... However, I want to

Tricks for fitting data in nlme?

爱⌒轻易说出口 提交于 2019-12-05 21:45:10
When I fit data in nlme, I never succeed on the first try, and after nlme(fit.model) I am accustomed to seeing things such as: Error in nlme.formula(model = mass ~ SSbgf(day, w.max, t.e, t.m), random = list( : step halving factor reduced below minimum in PNLS step Error in MEestimate(nlmeSt, grpShrunk) : Singularity in backsolve at level 0, block 1 So I go back and 1)Change the units of the x-axis (e.g. from years to days, or days to growing degree days). 2)Make a x=0, y=0 measurement in my dataset 3)Add a random=pdDiag() 4)Mess with what is random and what is fixed 5)Chop up my dataset and

lmer error: grouping factor must be < number of observations

扶醉桌前 提交于 2019-12-05 18:20:23
I am attempting to run a mixed effect model on some data but struggling with one of the fixed effects, I think primarily due to it a factor?! Sample data: data4<-structure(list(code = structure(1:10, .Label = c("10888", "10889", "10890", "10891", "10892", "10893", "10894", "10896", "10897", "10898", "10899", "10900", "10901", "10902", "10903", "10904", "10905", "10906", "10907", "10908", "10909", "10910", "10914", "10916", "10917", "10919", "10920", "10922", "10923", "10924", "10925", "10927"), class = "factor"), speed = c(0.0296315046039244, 0.0366986630049636, 0.0294297725505692, 0

How to fit two random effects separately in lme?

萝らか妹 提交于 2019-12-04 11:56:30
问题 I'm doing Linear mixed-effects model fit by REML in nlme package. And these are codes that work for me: # Linear mixed-effects model fit by REML (intercept and not slope) x <- lme (DV ~ IV1 + IV2 + IV1*IV2, data=a.frame, random=~1|speaker) summary(x) # Linear mixed-effects model fit by REML (slope and no intercept) x1 <- lme (DV ~ IV1 + IV2 + IV1*IV2, data=a.frame, random=~IV3-1|speaker) summary(x1) # Linear mixed-effects model fit by REML (slope and intercept) x2 <- lme (DV ~ IV1 + IV2 + IV1