[R] lme Random Effects and Covariates
1. I'm attempting to test for Random Effects. I've grouped the data on subject (grid) but want to use lme to build the model without subject as a RE then add it and do anova between the 2 models. This is the result I get and it appears it's adding Random Effects. tmp.dat4 - groupedData(Trials ~ 1 | grid, data = tmp.dat4) mod2a - lme(Trials ~ factor(group_id) + reversal, data = tmp.dat4, na.action = na.omit, method = REML) summary(mod2a) Linear mixed-effects model fit by REML Data: tmp.dat4 AIC BIClogLik 4544.054 4587.718 -2262.027 Random effects: Formula: ~factor(group_id) + reversal | grid Structure: General positive-definite StdDevCorr (Intercept) 10.505303 (Intr) fc(_)2 factor(group_id)2 9.830679 -0.778 reversal2 7.106839 -0.275 0.023 Residual 9.995963 Fixed effects: Trials ~ factor(group_id) + reversal Value Std.Error DF t-value p-value (Intercept) 23.275874 1.876185 510 12.405960 0e+00 factor(group_id)2 -7.639842 2.151004 72 -3.551757 7e-04 reversal2 7.681495 1.206858 510 6.364869 0e+00 Correlation: (Intr) fc(_)2 factor(group_id)2 -0.785 reversal2 -0.308 -0.015 Standardized Within-Group Residuals: Min Q1Med Q3Max -2.6884393 -0.5059063 -0.1892908 0.4944976 2.8477377 Number of Observations: 585 Number of Groups: 74 2. Secondly is this the correct way to add covariates (such as age). mod2i - lme(Trials ~ factor(group_id)*factor(reversal) * age, data = tmp.dat4, random = ~ 1 | grid, na.action = na.omit, method = ML) -- View this message in context: http://r.789695.n4.nabble.com/lme-Random-Effects-and-Covariates-tp3049181p3049181.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Executing Command on Multiple R Objects
Hello Everyone - I want to print a number of results from lme function objects out to a txt file. How could I do this more efficiently than what you see here: out2 - capture.output(summary(mod2a)) out3 - capture.output(summary(mod3)) out4 - capture.output(summary(mod5)) out5 - capture.output(summary(mod6)) out6 - capture.output(summary(mod7)) cat(out2,file=out.txt,sep=\n,append=TRUE) cat(out3,file=out.txt,sep=\n,append=TRUE) cat(out4,file=out.txt,sep=\n,append=TRUE) cat(out5,file=out.txt,sep=\n,append=TRUE) cat(out6,file=out.txt,sep=\n,append=TRUE) cat(third,file=out.txt,sep=\n,append=TRUE) Here's an example of what I tried, but didn't work. for (i in ls(pat = mod)) { out - capture.output(summary[[i]]) cat(out, file = results_paired.txt, sep = \n, append = TRUE) } -- View this message in context: http://r.789695.n4.nabble.com/Executing-Command-on-Multiple-R-Objects-tp3043871p3043871.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.