Re: [R] HLM Model

2011-01-31 Thread Belle

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.

__
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.


Re: [R] HLM Model

2011-01-28 Thread Silvano

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...@gmail.com

To: r-help@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@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-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.


Re: [R] HLM Model

2011-01-27 Thread Doran, Harold
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-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
 Behalf Of Belle
 Sent: Thursday, January 27, 2011 2:44 PM
 To: r-help@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@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-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.


Re: [R] HLM Model

2011-01-27 Thread Belle

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.

__
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.


Re: [R] HLM Model

2011-01-27 Thread Doran, Harold
Belle:

Before I provide any more help, you'll need to follow some posting guide rules 
and describe what you have done with some R code, describe what the problem is, 
and describe what you are hoping to accomplish.

The fact that the results you get from R and SAS are different doesn't mean 
there is a problem. If you can provide more details on what you are doing, what 
hasn't worked (specifically), then you will also find others on this list will 
provide help too.

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
 Behalf Of Belle
 Sent: Thursday, January 27, 2011 3:54 PM
 To: r-help@r-project.org
 Subject: Re: [R] HLM Model
 
 
 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.
 
 __
 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-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.


Re: [R] HLM Model

2011-01-27 Thread Belle

Hi Harold:

I know the outputs are different between SAS and R, but the results that I
got have big difference.

Here is part of the result based on the SAS code I provided earlier:

Cov Parm SubjectEstimate   Error
Value  Pr  Z

UN(1,1)  team177.53  273.66 
  
0.65   0.2583
Residual2161.15
67.1438  32.19  .0001

   Solution for Fixed
Effects



Standard
 Effect  pairsgrade  schoolEstimate   Error 
DFt ValuePr  |t|

 Intercept 638.82   4.6127  
5 138.49  .0001
 trt  -0.2955 
3.4800   5  -0.08  0.9356
 pairs  10.1899   7.1651
  
5   0.03  0.9799
 pairs  231.1293  6.0636
 
5   5.13  0.0037
   .
   .
   .

In R:
library(lme4)
mixed- lmer(Pre~trt+pairs+grade+school+(1|team), test)

result:

Random effects:
 Groups NameVariance Std.Dev.
 team   (Intercept) 568.61  23.846  
 Residual   2161.21  46.489 

Fixed effects:
  EstimateStd. Errort value
(Intercept)540.402 43.029   12.559
trt   7.29113.0840.557
pairs   -3.535 6.150-0.575

In random effect, the variance of team in SAS is 177.53, but it is 568.61 in
R. Also I have negative estimate for trt in SAS but positive estimate for
trt in R. I am wondering how this happened, and how can I solve this problem
so that I can get similar result from both software.

Also does R provides result for fixed effect of each level? For example, the
result of pair1, pair2,pair3,..., and grade1, grade2, grade3,...

-- 
View this message in context: 
http://r.789695.n4.nabble.com/HLM-Model-tp3242999p3243475.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.


Re: [R] HLM Model

2011-01-27 Thread Jeremy Miles
The empirical statement on the proc mixed line gives you robust
standard errors, I don't think you get them in R.

In SAS you specify that the predictors are to be dummy coded using the
class .  Are they factors in R?  I can't tell from the SAS output,
because the formatting has been lost.  However, it appears that in R
you did not dummy code them.  It also appears you haven't given use
all of the SAS output.

Jeremy





On 27 January 2011 15:52, Belle ping...@gmail.com wrote:

 Hi Harold:

 I know the outputs are different between SAS and R, but the results that I
 got have big difference.

 Here is part of the result based on the SAS code I provided earlier:

                                Cov Parm     Subject    Estimate       Error
 Value      Pr  Z

                                UN(1,1)      team        177.53      273.66
 0.65       0.2583
                                Residual                    2161.15
 67.1438      32.19      .0001

                                                   Solution for Fixed
 Effects


 Standard
  Effect          pairs    grade      school        Estimate       Error
 DF    t Value    Pr  |t|

  Intercept                                             638.82       4.6127
 5     138.49      .0001
  trt                                                      -0.2955
 3.4800       5      -0.08      0.9356
  pairs              1                                    0.1899       7.1651
 5       0.03      0.9799
  pairs              2                                    31.1293      6.0636
 5       5.13      0.0037
   .
   .
   .

 In R:
 library(lme4)
 mixed- lmer(Pre~trt+pairs+grade+school+(1|team), test)

 result:

 Random effects:
  Groups                 Name        Variance Std.Dev.
  team               (Intercept)     568.61  23.846
  Residual                               2161.21  46.489

 Fixed effects:
                          Estimate        Std. Error    t value
 (Intercept)                540.402     43.029       12.559
 trt                           7.291        13.084        0.557
 pairs                       -3.535         6.150        -0.575

 In random effect, the variance of team in SAS is 177.53, but it is 568.61 in
 R. Also I have negative estimate for trt in SAS but positive estimate for
 trt in R. I am wondering how this happened, and how can I solve this problem
 so that I can get similar result from both software.

 Also does R provides result for fixed effect of each level? For example, the
 result of pair1, pair2,pair3,..., and grade1, grade2, grade3,...

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/HLM-Model-tp3242999p3243475.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.




-- 
Jeremy Miles
Psychology Research Methods Wiki: www.researchmethodsinpsychology.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.