nlme

specifying multiple separate random effects in nlme

筅森魡賤 提交于 2021-01-24 07:17:28
问题 I am analysing some whale tourism data and am trying to construct linear mixed effect models in the nlme package to see if any of my explanatory variables affect encounter time between whales and tourists. (I am also open to running this model in lme4 .) My variables are: mins : encounter time (response variable) Id : individual whale ID (random effect) Vessel : vessel Id (random effect) Sex : sex of the animal Length : length of the animal Year Month (nested within Year ). So my random

How do regression models deal with the factor variables?

喜夏-厌秋 提交于 2020-01-13 19:35:10
问题 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 +

lmer error: grouping factor must be < number of observations

本秂侑毒 提交于 2020-01-02 06:39:31
问题 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"

How to compare a model with no random effects to a model with a random effect using lme4?

五迷三道 提交于 2019-12-31 09:16:16
问题 I can use gls() from the nlme package to build mod1 with no random effects. I can then compare mod1 using AIC to mod2 built using lme() which does include a random effect. mod1 = gls(response ~ fixed1 + fixed2, method="REML", data) mod2 = lme(response ~ fixed1 + fixed2, random = ~1 | random1, method="REML",data) AIC(mod1,mod2) Is there something similar to gls() for the lme4 package which would allow me to build mod3 with no random effects and compare it to mod4 built using lmer() which does

R Ordering of LME covariates for level 1 and level 2 variables?

半世苍凉 提交于 2019-12-25 09:00:33
问题 I have longitudinal data with level 1 and level 2 variables in R my dataframe (df) : ID Year Gender Race MathScore DepressionScore MemoryScore 1 1999 M C 80 15 80 1 2000 M C 81 25 60 1 2001 M C 70 50 75 2 1999 F C 65 15 99 2 2000 F C 70 31 98 2 2001 F C 71 30 99 3 1999 F AA 92 10 90 3 2000 F AA 89 10 91 3 2001 F AA 85 26 80 I've tried these: summary(fix <- lme(MathScore ~ Gender+Race+DepressionScore+MemoryScore, random= Year|ID, data=df, na.action="na.omit") summary(fix2 <- lme(MathScore ~ 1

Adding covariates to nlme model in R

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 14:21:21
问题 I've recently started learning to fit data using the nlme model. I was wondering if there was a more logical way of generating all possible combinations of covariates (for the variables asy and int ) in the nlme model below: fmzeta.nlme <- nlme( z ~ asy - (asy - int)*exp(-c*t), fixed = list(asy ~ age + wfa + vl, int ~ age + wfa + vl, c ~ 1), random = int + asy ~ 1, start = c(-1, 0, -2, 0, 0, 0, 0, 0, 0.03), data = DATA) As you can see there are three covariates for the two variables asy and

Model failure for nonlinear mixed-effects model from Pinhiero and Bates

狂风中的少年 提交于 2019-12-23 22:25:58
问题 I have been working through Mixed-Effects Models in S and S-Plus by Pinhiero and Bates and am discovering a lot of problems making the models in the book work. The latest is this, using a constant plus power function to model heteroscedastic within-group error in the Theo dataset, (p.393). The error comes at the end of a model-building exercise. The first three models work in R but the last does not library(nlme) fm1Theo.nlme <- nlme( model = conc ~ SSfol(Dose, Time, lKe, lKa, lCl), data =

Solving error message “step halving factor reduced below minimum in NLS step”: adjusting nlsTols not working

痞子三分冷 提交于 2019-12-22 17:46:50
问题 I am trying to fit a logistic growth curve to some data using the gnls function. Data: structure(list(Nest = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 16L, 10L, 4L, 5L, 7L, 12L, 4L, 6L, 20L, 8L, 14L, 16L, 3L, 9L, 15L, 19L, 6L, 7L, 17L, 18L, 12L, 13L, 10L, 20L, 5L, 8L, 11L, 16L, 6L, 12L, 1L, 2L, 4L, 6L, 9L, 18L, 21L, 16L, 3L, 20L), .Label = c("WTSN01", "WTSN02", "WTSN04", "WTSN05", "WTSN06", "WTSN07", "WTSN08", "WTSN09",