nlme

Better fits for a linear model

依然范特西╮ 提交于 2019-12-03 13:56:32
问题 I am fitting some lines and I feel like I am telling R exactly how to fit them, but I feel like there is something (some factor or effect) I am unaware of that is preventing a good fit. My experimental unit is "plot" as in field plot, which I am sorry is confusing. The data can be found: https://www.dropbox.com/s/a0tplyvs8lxu1d0/rootmeansv2.csv . with df$plot.f<-as.factor(df$plot) dfG<-groupedData(mass ~ year|plot.f, data=df) dfG30<-dfG[dfG$depth == 30,] Simply, I have mass over time and I

How to fit two random effects separately in lme?

不想你离开。 提交于 2019-12-03 07:10:23
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*IV2, data=a.frame, random=~IV3|speaker) summary(x2) #nested random effect x5 <- lme (DV ~ IV1 + IV2 +

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

时光怂恿深爱的人放手 提交于 2019-12-02 19:21:06
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 include a random effect? mod3 = ???(response ~ fixed1 + fixed2, REML=T, data) mod4 = lmer(response ~

Can I use emmeans with LME model?

℡╲_俬逩灬. 提交于 2019-12-02 15:19:49
问题 I am using LME model defined like: mod4.lme <- lme(pRNFL ~ Init.Age + Status + I(Time^2), random= ~1|Patient/EyeID,data = long1, na.action = na.omit) The output is: > summary(mod4.lme) Linear mixed-effects model fit by REML Data: long1 AIC BIC logLik 2055.295 2089.432 -1018.647 Random effects: Formula: ~1 | Patient (Intercept) StdDev: 7.949465 Formula: ~1 | EyeID %in% Patient (Intercept) Residual StdDev: 12.10405 2.279917 Fixed effects: pRNFL ~ Init.Age + Status + I(Time^2) Value Std.Error DF

Can I use emmeans with LME model?

荒凉一梦 提交于 2019-12-02 07:32:15
I am using LME model defined like: mod4.lme <- lme(pRNFL ~ Init.Age + Status + I(Time^2), random= ~1|Patient/EyeID,data = long1, na.action = na.omit) The output is: > summary(mod4.lme) Linear mixed-effects model fit by REML Data: long1 AIC BIC logLik 2055.295 2089.432 -1018.647 Random effects: Formula: ~1 | Patient (Intercept) StdDev: 7.949465 Formula: ~1 | EyeID %in% Patient (Intercept) Residual StdDev: 12.10405 2.279917 Fixed effects: pRNFL ~ Init.Age + Status + I(Time^2) Value Std.Error DF t-value p-value (Intercept) 97.27827 6.156093 212 15.801950 0.0000 Init.Age 0.02114 0.131122 57 0

extracting coefficients and their standard error from lme

落花浮王杯 提交于 2019-11-29 04:43:20
How could I extract coefficients (b0 and b1) with their respectively standard errors for each experimental unit (plot )in a linear mixed model such as this one: Better fits for a linear model with this same dataset(df), and for the fitted model (fitL1): how could I get a data frame as this one... plot b0 b0_se b1 b1_se 1 2898.69 53.85 -7.5 4.3 ... ... ... ... ... The first comment is that this is actually a non-trivial theoretical question: there is a rather long thread on r-sig-mixed-models that goes into some of the technical details; you should definitely have a look, even though it gets a

Error in na.fail.default: missing values in object - but no missing values

随声附和 提交于 2019-11-28 11:58:00
I am trying to run a lme model with these data: tot_nochc=runif(10,1,15) cor_partner=factor(c(1,1,0,1,0,0,0,0,1,0)) age=runif(10,18,75) agecu=age^3 day=factor(c(1,2,2,3,3,NA,NA,4,4,4)) dt=as.data.frame(cbind(tot_nochc,cor_partner,agecu,day)) attach(dt) corpart.lme.1=lme(tot_nochc~cor_partner+agecu+cor_partner *agecu, random = ~cor_partner+agecu+cor_partner *agecu |day, na.exclude(day)) I get this error code: Error in na.fail.default(list(cor_partner = c(1L, 1L, 2L, 1L, 1L, 1L, : missing values in object I am aware there are similar questions in the forum. However, in my case: cor_partner has

Print R-squared for all of the models fit with lmList

≡放荡痞女 提交于 2019-11-28 10:30:54
I used lmList to fit 480 relationships and I would like the R2 of each of these. Here is an example dataset and model which are pretty close to what it really looks like, except I have 480 eu (experimental units): eu mass day 11 .02 1 11 .03 2 11 .04 3 11 .06 4 12 .01 1 12 .03 2 12 .04 3 12 .05 4 fit<-lmList(mass ~ day | eu, data=df) Printing fit or summary does not give me the information I want. I am ultimately trying to make a new dataframe that will look like: eu intercept slope R2 11 .01 .95 .98 12 .01 .96 .98 I've got the coefficients through coef , now I need the R-squared. Here you go:

extracting coefficients and their standard error from lme

拥有回忆 提交于 2019-11-27 18:37:44
问题 How could I extract coefficients (b0 and b1) with their respectively standard errors for each experimental unit (plot )in a linear mixed model such as this one: Better fits for a linear model with this same dataset(df), and for the fitted model (fitL1): how could I get a data frame as this one... plot b0 b0_se b1 b1_se 1 2898.69 53.85 -7.5 4.3 ... ... ... ... ... 回答1: The first comment is that this is actually a non-trivial theoretical question: there is a rather long thread on r-sig-mixed

Print R-squared for all of the models fit with lmList

隐身守侯 提交于 2019-11-27 03:41:50
问题 I used lmList to fit 480 relationships and I would like the R2 of each of these. Here is an example dataset and model which are pretty close to what it really looks like, except I have 480 eu (experimental units): eu mass day 11 .02 1 11 .03 2 11 .04 3 11 .06 4 12 .01 1 12 .03 2 12 .04 3 12 .05 4 fit<-lmList(mass ~ day | eu, data=df) Printing fit or summary does not give me the information I want. I am ultimately trying to make a new dataframe that will look like: eu intercept slope R2 11 .01