Questions tagged [nlme]

An R package for fitting Non-Linear Mixed Effects statistical models.

An package for fitting Non-Linear Mixed Effects statistical models ().

Repositories

Books

Other resources

Related tags

494 questions
3
votes
1 answer

Missing values in object in R lme

I am working on a simple model in R: fit<-lme(x~y, data, random=~1|subject) But I keep getting this error: Error in na.fail.default(list(h1 = c(103L, 20L, 34L, 85L, 47L, 136L, 76L, : missing values in object (h1 is one of my column titles…
Katie Tetzloff
  • 55
  • 1
  • 1
  • 6
3
votes
1 answer

How do regression models deal with the factor variables?

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…
Geo-sp
  • 1,704
  • 3
  • 19
  • 42
3
votes
1 answer

How to obtain the standard errors of the random effects in lme?

If I fix a linear mixed effects model using R's lme from the nlme package, how do I obtain the standard errors of the random effects estimates? For example, if lme gives the following results: null.model <- lme(fixed = fev1 ~ 1, data = Data, random…
Alexis
  • 784
  • 8
  • 32
3
votes
1 answer

Mixed Modelling - Different Results between lme and lmer functions

I am currently working through Andy Field's book, Discovering Statistics Using R. Chapter 14 is on Mixed Modelling and he uses the lme function from the nlme package. The model he creates, using speed dating data, is such: speedDateModel <-…
user3585829
  • 945
  • 11
  • 24
3
votes
1 answer

Create lme object within a function

Background I am trying to fit a mixed model in a function based on some parameters. If I want to use contrast from library(contrast) I have to use a workaround, as contrast uses the call slot from the lme object to determine the data, fixed or…
thothal
  • 16,690
  • 3
  • 36
  • 71
3
votes
0 answers

Linear mixed model: kronecker product covariance matrix

Let's take the Pixel dataset as example. Grouped Data: pixel ~ day | Dog/Side Dog Side day pixel 1 1 R 0 1045.8 2 1 R 1 1044.5 3 1 R 2 1042.9 pixel is the response. Dog with 10 levels. Side with 2 levels. day with 9…
qoheleth
  • 2,219
  • 3
  • 18
  • 23
3
votes
1 answer

Extract range of NLME object

I have a NLME object with a correlation. I was wondering how I could extract the range of the correlation from the model. I'm running simulations, so I can't just read the summary, and get it manually. So my model looks something like…
Galadude
  • 253
  • 1
  • 3
  • 11
3
votes
0 answers

confidence intervals or SE of gls {nlme} predicted values

I'm running a multivariate gls model: m <- gls(y ~ x + factor1 + factor2, cor = corPagel(1,phylogeny), weight= ~1/log(n)) I want to plot the results and I could get predicted values like this: newdata <- data.frame(expand.grid( x = mean(x), …
Jasmine
  • 103
  • 2
  • 7
2
votes
1 answer

two random effects on the intercept in the lme() function

I'm trying to introduce two random effects into the intercept using the lme() function from the nlme package. The idea is to rewrite the barleyprogeny1.lmer model in nlme(). I found some information in this post: multiple random effects in nlme and…
user55546
  • 37
  • 1
  • 15
2
votes
0 answers

Using splines in TMB models

I have a nonlinear mixed-effects model that I have implemented in nlme that I would like to implement in TMB to decrease computation times and hopefully some occasional convergence issues. In its simplest form, the model is given by y_ij = f((1 -…
Lars Lau Raket
  • 1,905
  • 20
  • 35
2
votes
2 answers

Access results of intervals.lme as a dataframe + r + lme

I am using a linear mixed effects model to determine the relationship between 2 variables over time, model - data(mtcars) # linear mixed effects model mlme <- lme(mpg ~ wt, random = ~ 1|cyl, data = mtcars) I then access the confidence intervals…
John Conor
  • 722
  • 6
  • 20
2
votes
0 answers

Variogram with time series data

I want to check the results of my lme-model for temporal autocorrelation. The data can be downloaded here (password: Variogram_2023). It contains the sampling date, group and extracted residuals from the model (E1). These residuals derived from an…
M.Teich
  • 575
  • 5
  • 22
2
votes
1 answer

Issue when running ns(variable, i) over a loop in R

I run the following loop to print a model for each index as a ns(x, df=j) library(splines) library(nlme) # Generate some data x <- 1:100 xid <- sort(rep.int(1:10, 10)) y <- x + rnorm(10) # Loop through the number of knots in the spline for (j in…
phg
  • 536
  • 1
  • 7
  • 19
2
votes
1 answer

Converting code using nlme::lme to lme4::lmer

I'm following the R code (here) in Applied Longitudinal Analysis by Fitzmaurice, Laird and Ware to conduct a penalized spline regression analysis using nlme::lme. My actual application will have many more random coefficients, so I plan to use…
stats134711
  • 624
  • 1
  • 5
  • 15
2
votes
2 answers

Specify random effect with different variance across groups in nlme

I have a dataset with measures for individuals, where each measure represents a specific type of measure (say '1' or '2') and each individual belongs to specific group (say 'A' or 'B'). For a subset of individuals, I have observed both measures '1'…
Lars Lau Raket
  • 1,905
  • 20
  • 35