Hi I am trying to convert SAS codes to R, but some of the result are quite different from SAS. When I ran proc mixed, I have an option ddfm=bw followed by the model. How can I show this method in R?(I am thinking that this maybe the reason that I can't get the similar results) below is my SAS codes: proc mixed data=test covtest empirical; class pair grade team school; model score = trt pair grade school/ solution covb ddfm=bw ; random int / sub=team solution type=un; run; I have tried both lmer and hglm, but non of them works. Could anyone tell me how can I covert this SAS codes to R? Thanks -- View this message in context: http://r.789695.n4.nabble.com/HLM-Model-tp3242999p3242999.html Sent from the R help mailing list archive at Nabble.com.
I think it should be fm <- lmer(score ~ trt + pair + grade + school + (1|team), test) The unstructured covariance matrix you use in proc mixed is not available in Rs function for mixed models> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On > Behalf Of Belle > Sent: Thursday, January 27, 2011 2:44 PM > To: r-help at r-project.org > Subject: [R] HLM Model > > > Hi > > I am trying to convert SAS codes to R, but some of the result are quite > different from SAS. > > When I ran proc mixed, I have an option ddfm=bw followed by the model. How > can I show this method in R?(I am thinking that this maybe the reason that I > can't get the similar results) > > below is my SAS codes: > > proc mixed data=test covtest empirical; > class pair grade team school; > model score = trt pair grade school/ solution covb ddfm=bw ; > random int / sub=team solution type=un; > run; > > I have tried both lmer and hglm, but non of them works. > > Could anyone tell me how can I covert this SAS codes to R? Thanks > -- > View this message in context: http://r.789695.n4.nabble.com/HLM-Model- > tp3242999p3242999.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.
Hi Harold: Yes, this was the R code that I tried, and got different result from SAS. Is that mean I cannot actually use R to run unstructured covariance matrix? How can I solve this problem if I need an unstructured covariance matrix method? Thanks for the help. -- View this message in context: http://r.789695.n4.nabble.com/HLM-Model-tp3242999p3243158.html Sent from the R help mailing list archive at Nabble.com.
Hi Belle, try this: SAS: proc mixed data=test noclprint noinfo covtest noitprint method=reml; class pair grade team school; model score = trt pair grade school / solution ddfm=bw notest; random int / sub=team solution type=un r; run; R: require(nlme) unstruct <- gls(score~trt+pair+grade+school, test, correlation=corSymm(form = ~ 1 |id), weights=varIdent(form = ~ 1|team), method="REML") summary(unstruct) -------------------------------------- Silvano Cesar da Costa Departamento de Estat?stica Universidade Estadual de Londrina Fone: 3371-4346 -------------------------------------- ----- Original Message ----- From: "Belle" <ping.yi at gmail.com> To: <r-help at r-project.org> Sent: Thursday, January 27, 2011 5:43 PM Subject: [R] HLM Model> > Hi > > I am trying to convert SAS codes to R, but some of the > result are quite > different from SAS. > > When I ran proc mixed, I have an option ddfm=bw followed > by the model. How > can I show this method in R?(I am thinking that this maybe > the reason that I > can't get the similar results) > > below is my SAS codes: > > proc mixed data=test covtest empirical; > class pair grade team school; > model score = trt pair grade school/ solution covb ddfm=bw > ; > random int / sub=team solution type=un; > run; > > I have tried both lmer and hglm, but non of them works. > > Could anyone tell me how can I covert this SAS codes to R? > Thanks > -- > View this message in context: > http://r.789695.n4.nabble.com/HLM-Model-tp3242999p3242999.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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. >
Hi Silvano: Could you tell me what "correlation=corSymm(form = ~ 1 |id)" represents? In our case, team is random effect, trt, pairs, grade, school are fixed effect, and each team is within school. I still got the different results from both SAS and R.> unstruct <- gls(score~trt+pairs+grade+school, > test,correlation=corSymm(form = ~ 1 |StudentID),+ weights=varIdent(form=~1|team), method="REML") I tried school instead of StudentID, but I got error.> unstruct <- gls(score~trt+pairs+grade+school, > test,correlation=corSymm(form = ~ 1 |school),+ weights=varIdent(form=~1|team), method="REML") Error in vector("double", length) : vector size specified is too large Thanks for the help -- View this message in context: http://r.789695.n4.nabble.com/HLM-Model-tp3242999p3249518.html Sent from the R help mailing list archive at Nabble.com.
Seemingly Similar Threads
- lme and gls : accessing values from correlation structure and variance functions
- Help with mixed effects models
- R vs SAS and HLM on multilevel analysis- basic question
- Help with lme and correlated residuals
- Lmer binomial distribution x HLM Bernoulli distribution