LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (November 2011, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 31 Oct 2011 23:58:31 -0700
Reply-To:     Daniel Nordlund <djnordlund@FRONTIER.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Daniel Nordlund <djnordlund@FRONTIER.COM>
Subject:      Re: GML in SAS and R
In-Reply-To:  <1320111383.29398.YahooMailNeo@web161403.mail.bf1.yahoo.com>
Content-Type: text/plain; charset="UTF-8"

> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of oslo > Sent: Monday, October 31, 2011 6:36 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: GML in SAS and R > > Dear Farzeeza; > > Thanks a lot. Here is the SAS code. > > proc glm data= a; > class t; > model > y=t/p ss3 solution; > output out=pout1 RESIDUALS > = ry; > run; > data b; > set pout1; > my= 7.273791363+ry; /*here 7.273791363 is means of y; > run; >

I am not sure if my original reply got lost in the luminiferous ether, so I have reposted it.

It would have been useful to see the exact R code that you used along with the SAS code. For your data, what do the values of t stand for? You are treating them as a class variable. Do you really want to do that? Did you create t as factor variable in R?

In any case, if I treat t as a class variable in SAS and treat t as factor variable in R, then the only difference between SAS and R is how the reference class is defined. In SAS, you could create a format to change the minimum value to the max value. With your sample data you could do

/*format minimum value to have largest formatted value*/ proc format; value refmt 15 = '99' ; run; proc glm data= a order=formatted; format t refmt.; class t; model y=t/p ss3 solution; output out=pout1 RESIDUALS=ry; quit;

Using this approach, I get the same results as in R with the syntax

summary(lm(y ~ factor(t))

Hope this is helpful,

Dan

Daniel Nordlund Bothell, WA USA

> > ________________________________ > From: Fareeza Khurshed <fkhurshed@GMAIL.COM> > To: SAS-L@LISTSERV.UGA.EDU > Sent: Monday, October 31, 2011 5:23 PM > Subject: Re: GML in SAS and R > > Can you show the code you ran in SAS Oslo? > > > > On Mon, Oct 31, 2011 at 3:20 PM, oslo <hokut1@yahoo.com> wrote: > > > Peter; > > > > Thanks. ANOVA and p values are the same. But estimation for fixed > effects > > are not the same. > > > > Oslo > > > > From: Peter Flom <peterflomconsulting@MINDSPRING.COM> > > To: SAS-L@LISTSERV.UGA.EDU > > Sent: Monday, October 31, 2011 5:16 PM > > Subject: Re: GML in SAS and R > > > > I ran both this in both SAS and R and got identical results, with no > > parameter fixed at 0. > > > > In SAS > > > > proc glm data = a; > > model y = t; > > run; > > > > in R > > > > y <- c(8.45868914, 8.80001656, 11.19760853, 6.48274648, 4.13212718, > > 2.56846860, 0.93439027, 10.42572772, 3.37216466, 7.97682921, > > 3.90145850, > > 1.42026869, 8.19922699) > > t <- c(48, 28, 35, 15, 21, 50, 31, 46, 40, 26, 48, 32, 15) > > > > m1 <- lm(y ~ t) > > summary(m1) > > > > Peter > > > > Peter Flom > > Peter Flom Consulting > > http://www.statisticalanalysisconsulting.com/ > > http://www.IAmLearningDisabled.com > > > > -----Original Message----- > > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of > oslo > > Sent: Monday, October 31, 2011 5:48 PM > > To: SAS-L@LISTSERV.UGA.EDU > > Subject: GML in SAS and R > > > > Dear SAS-users; > > > > I have run the same data in R and SAS but got different prediction > results > > after model fit. Suppose I want fit the following model for the data > given > > below (a part of data) > > > > y(ij)=mu + t(i) + e(ij) > > > > at the end I want to have > > > > y* =y(ij)-t(i)_hat > > For this I run SAS and R but got differnt results.SAS and R are using > > different constrain on fixed effect. In SAS the last effect, in R the > first > > fixed effect set to zero. > > > > In addition is it possible to set the first fixed effect to zero in SAS > as > > R > > does? > > > > Regards, > > > > Oslo > > data a; > > input y t; > > cards; > > 8.45868914 48 > > 8.80001656 28 > > 11.19760853 35 > > 6.48274648 15 > > 4.13212718 21 > > 2.56846860 50 > > 0.93439027 31 > > 10.42572772 46 > > 3.37216466 40 > > 7.97682921 26 > > 3.90145850 48 > > 1.42026869 32 > > 8.19922699 15 > >


Back to: Top of message | Previous page | Main SAS-L page