| 所在主题: | |
| 文件名: R01.pdf | |
| 资料下载链接地址: https://bbs.pinggu.org/a-1566716.html | |
| 附件大小: | |
|
We first import the tab-delimited file, rat_pup.dat, assumed to be located in the C:\temp directory, into a data frame object in R named ratpup. The h = T argument in the read.table() function indicates that the first row (the header) in the rat_pup.dat file contains variable names. After reading the data, we “attach” the ratpup data frame to R’s working memory so that the columns (i.e., variables) in the data
frame can be easily accessed as separate objects. Note that we show the “>” prompt for each command as it would appear in R, but this prompt is not typed as part of the commands. > ratpup <- read.table("c:\\temp\\rat_pup.dat", h = T) > attach(ratpup) To facilitate comparisons with the analyses performed using the other software procedures, we recode the variable SEX into SEX1, which is an indicator variable for females, so that males will be the reference group: > ratpup$sex1[sex == "Female"] <- 1 > ratpup$sex1[sex == "Male"] <- 0Step 1: Fit a model with a “loaded” mean structure (Model 3.1). We first load the nlme package,* so that the lme() function will be available for model fitting: > library(nlme) We fit the initial LMM, Model 3.1, to the Rat Pup data using the lme() function: > # Model 3.1. > model3.1.fit <- lme(weight ~ treatment + sex1 + litsize +treatment*sex1, random = ~1 | litter, ratpup, method = "REML") We next explain each part of the syntax used for the lme() function:
By default, the lme() function treats the lowest level (alphabetically or numerically) of a categorical fixed factor as the reference category. This means that “Control” will be the reference category of TREATMENT because “Control” is the lowest level of treatment alphabetically. We obtain estimates from the model fit by using the summary() function: > summary(model3.1.fit) Additional results for the fit of Model 3.1 can be obtained by using other functions in conjunction with the model3.1.fit object. For example, we can obtain F-tests for the fixed effects in the model by using the anova() function: > anova(model3.1.fit) The anova() function performs a series of Type I (or sequential) F-tests for the fixed effects in the model, each of which are conditional on the preceding terms in the model specification. For example, the F-test for SEX1 is conditional on the TREATMENT effects, but the F-test for TREATMENT is not conditional on the SEX1 effect. The random.effects() function can be used to display the EBLUPs for the random litter effects: > # Display the random effects (EBLUPs) from the model. > random.effects(model3.1.fit) |
|
熟悉论坛请点击新手指南
|
|
| 下载说明 | |
|
1、论坛支持迅雷和网际快车等p2p多线程软件下载,请在上面选择下载通道单击右健下载即可。 2、论坛会定期自动批量更新下载地址,所以请不要浪费时间盗链论坛资源,盗链地址会很快失效。 3、本站为非盈利性质的学术交流网站,鼓励和保护原创作品,拒绝未经版权人许可的上传行为。本站如接到版权人发出的合格侵权通知,将积极的采取必要措施;同时,本站也将在技术手段和能力范围内,履行版权保护的注意义务。 (如有侵权,欢迎举报) |
|
京ICP备16021002号-2 京B2-20170662号
京公网安备 11010802022788号
论坛法律顾问:王进律师
知识产权保护声明
免责及隐私声明