Bob Green
2005-Nov-20 20:44 UTC
[R] use of the 'by' command & converting SPSS ANOVA/GLM syntax into R syntax
I have two questions I would appreciate assistance with: (1) I believe "by" is the command used to split a file. In the following example, "mydat" is the dataframe , "group" the variable I want to split the analysis by & "WK1FREQ,WK2FREQ" the variables attach(mydat) by (GROUP) cor.test (WK1FREQ,WK2FREQ) I have also tried: (by (GROUP) cor.test (WK1FREQ,WK2FREQ)) (2) I also wanted to run the following analyses, written in SPSS syntax. I have searched the R archives and gather I may need to use lm instead of glm, but got lost. UNIANOVA avfreq BY sex WITH blik /METHOD = SSTYPE(3) /INTERCEPT = INCLUDE /EMMEANS = TABLES(OVERALL) /EMMEANS = TABLES(sex) /PRINT = DESCRIPTIVE ETASQ OPOWER HOMOGENEITY /CRITERIA = ALPHA(.05) /DESIGN = blik sex blik*sex . GLM avmth3fq avfreq BY SEX /WSFACTOR = timex 2 Polynomial /METHOD = SSTYPE (3) /PRINT = DESCRIPTIVE ETASQ TEST(MMATRIX) HOMOGENEITY /CRITERIA = ALPHA (.05) /WSDESIGN = timex /DESIGN = sex . Any assistance with either of these enquiries is most appreciated. Bob
Duncan Murdoch
2005-Nov-21 01:06 UTC
[R] use of the 'by' command & converting SPSS ANOVA/GLM syntax into R syntax
On 11/20/2005 3:44 PM, Bob Green wrote:> I have two questions I would appreciate assistance with: > > (1) I believe "by" is the command used to split a file. In the following > example, "mydat" is the dataframe , "group" the variable I want to split > the analysis by & "WK1FREQ,WK2FREQ" the variables > > attach(mydat) > by (GROUP) > cor.test (WK1FREQ,WK2FREQ) > > I have also tried: (by (GROUP) cor.test (WK1FREQ,WK2FREQ))I think you want by(mydat, mydat$GROUP, function(subset) cor.test(subset$WK1FREQ, subset$WK2FREQ))> > (2) > > I also wanted to run the following analyses, written in SPSS syntax. I have > searched the R archives and gather I may need to use lm instead of glm, but > got lost. > > UNIANOVA > avfreq BY sex WITH blik > /METHOD = SSTYPE(3) > /INTERCEPT = INCLUDE > /EMMEANS = TABLES(OVERALL) > /EMMEANS = TABLES(sex) > /PRINT = DESCRIPTIVE ETASQ OPOWER HOMOGENEITY > /CRITERIA = ALPHA(.05) > /DESIGN = blik sex blik*sex . > > GLM > avmth3fq avfreq BY SEX > /WSFACTOR = timex 2 Polynomial > /METHOD = SSTYPE (3) > /PRINT = DESCRIPTIVE ETASQ TEST(MMATRIX) HOMOGENEITY > /CRITERIA = ALPHA (.05) > /WSDESIGN = timex > /DESIGN = sex .Sorry, I don't know SPSS syntax, so I can't help you with this one. Duncan Murdoch> > Any assistance with either of these enquiries is most appreciated. > > Bob > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html