线性线性混合效应模型及R语言实现

1.A very basic tutorial for performing linear mixed effects analyses(入门极品)

Tutorial 1: http://www.bodowinter.com/tutorial/bw_LME_tutorial1.pdf

Tutorial 2: http://www.bodowinter.com/tutorial/bw_LME_tutorial.pdf

nlme (Non-Linear Mixed Effects), lme4 (Linear Mixed Effects) and asreml (average spatial real)

 

2.其它资料(Google搜索即有)

Mixed-Eects Models in R (较好)

An Appendix to An R Companion to Applied Regression, Second Edition

 

John Fox & Sanford Weisberg

Linear Mixed-Effects Models Using R(一本教材,进阶选用)

 

A Step-by-Step Approach

 

Andrzej Ga?ecki ? Tomasz Burzykowski

 

3.R中的线性混合模型介绍(简单了解不同的包)

http://blog.sciencenet.cn/blog-2577109-949820.html

https://www.r-bloggers.com/linear-mixed-models-in-r/

 

3.语法备忘

 

  • 三种模型:
  • AOD固定斜率,DAY随机截距:LMM.model = lmer(PM25 ~ AOD + (1|Day) , data=LMMexcdata)
  • AOD随机斜率,DAY固定截距:LMM.model3 = lmer(PM25 ~ AOD + (0 + AOD|Day) , data=LMMexcdata)
  • AOD随机斜率,DAY随机截距:LMM.model2 = lmer(PM25 ~ AOD + (1 + AOD|Day) , data=LMMexcdata)

 

  • 师姐发来的查看斜率和截距的程序:

sslopef=as.numeric(as.matrix(lme4::fixef(fm1)[2]))

sloper=as.numeric(LMM.model(lme4::ranef(fm1)$Day[,2]))

intersf= as.numeric(LMM.model(lme4::fixef(fm1)[1]))

intersr=as.numeric(LMM.model(lme4::ranef(fm1)$Day[,1]))

 

lme4::fixef(yourmodle)读取固定截距和斜率

lme4::fixef(yourmodle)读取随机截距和斜率

 

文档中示例(A very basic tutorial for performing linear mixed effects analyses):

-----------------------------------------

#load data into R

politeness=read.csv("http://www.bodowinter.com/tutorial/politeness_data.csv")

#================view the dataset======================

#show the head of politeness

head(politeness)

#show the tail of politeness

tail(politeness)

# other commands you may use

summary(politeness)

str(politeness)

colnames(politeness)

#================check for missing values======================

which(!complete.cases(politeness))

#======look at the relationship between politeness and pitch by means of a boxplot==========

boxplot(frequency ~ attitude*gender,

        col=c("white","lightgray"),politeness)

#================A random intercept model======================

library(Matrix)

library(lme4)

lmer(frequency ~ attitude, data=

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值