Re: [R] R vs SPSS - simple effects analysis in mixed 2x2 ANOVA scheme - same data, different results

2016-05-22 Thread Michael Dewey
The only people who will be able to help you are people who use both R 
and SPSS as you do not show the result from either. So even though they 
can re-run your R commands they cannot compare them with SPSS.


On 22/05/2016 09:49, Michu Kom wrote:

down votefavoriteHell
<http://stats.stackexchange.com/questions/213592/r-vs-spss-simple-effects-analysis-in-mixed-2x2-anova-scheme-same-data-diffe#>

Hello,

I prepared a mixed 2x2 ANOVA design analysis both in SPSS and in R. The
SPSS script is correct, but in R script there is a mistake somewhere. To
test that I generated artificial data from a normal distribution to
simulate the interaction between two independent variables. There were no
difference between the results in main effects, but results of simple
effects analysis do not match when comparing between levels of variable
which introduced repeated measures (GROUP A: PRE vs POST ; GROUP B: PRE vs
POST).

I would be very thankful if you can help me. The code below will do
everything for you.

*Here is the code in R which:* - generates the data - calculates mixed
ANOVA - prepares data to csv format to import to SPSS - performs simple
effect analysis (there is probably a mistake)

N <- 100
absMean <- 1
sdCustom <- 5

grA_pre <- data.frame(ID = seq(N), lvl=rnorm(N, mean=absMean,
sd=sdCustom), group=factor('A'), stage = factor('pre'))
grA_post <- data.frame(ID = seq(N), lvl=rnorm(N, mean=-absMean,
sd=sdCustom), group=factor('A'), stage = factor('post'))
grB_pre <- data.frame(ID = seq(N+1,2*N), lvl=rnorm(N, mean=-absMean,
sd=sdCustom), group=factor('B'), stage = factor('pre'))
grB_post <- data.frame(ID = seq(N+1,2*N), lvl=rnorm(N, mean=absMean,
sd=sdCustom), group=factor('B'), stage = factor('post'))

gr <- rbind(grA_pre, grA_post, grB_pre, grB_post)
names(gr)
head(gr)
# save set to .csv to import to SPSS
grSPSS <- reshape(data = gr, timevar = "stage", idvar = c("ID",
"group"), direction = "wide")

write.csv2(grSPSS, file = "sample2.csv")

library(ggplot2)
library(plyr)
library(ez)
print("Omnibus mixed ANOVA - main effects and interactions")
ezPlot(data = gr, wid = ID, dv = lvl, between = group, within = stage,
type = "III", x = group, split = stage, x_lab = "Group", y_lab =
"Level of experience")
ezANOVA(data = gr, wid = ID, dv = lvl, between = group, within =
stage, detailed = TRUE, type = "III")#ezStats(data = gr, wid = ID, dv
= lvl, between = group, within = stage, type = "III")

print("Simple main effects analysis")
dataA <- subset(gr, group == "A" )
dataB <- subset(gr, group == "B" )
dataPRE <- subset(gr, stage == "pre" )
dataPOST <- subset(gr, stage == "post" )
print("GROUP = A: PRE vs POST")
simpleEffControlANOVA <- ezANOVA(data = dataA, dv = lvl, wid = ID,
within = stage, detailed = TRUE, type = "III"
)print(simpleEffControlANOVA)
print("GROUP = B: PRE vs POST")
simpleEffControlANOVA <- ezANOVA(data = dataB, dv = lvl, wid = ID,
within = stage, detailed = TRUE, type = "III"
)print(simpleEffControlANOVA)
print("STAGE = PRE: A vs B")
simpleEffControlANOVA <- ezANOVA(data = dataPRE, dv = lvl, wid = ID,
between = group, detailed = TRUE, type = "III"
)print(simpleEffControlANOVA)
print("STAGE = POST: A vs B")
simpleEffControlANOVA <- ezANOVA(data = dataPOST, dv = lvl, wid = ID,
between = group, detailed = TRUE, type = "III"
)print(simpleEffControlANOVA)

*Here is the code for SPSS Syntax which:* - calculates everything on
imported data, generated by R

DATASET ACTIVATE DataSet1.
GLM lvl.pre lvl.post BY group
  /WSFACTOR=stage 2 Polynomial
  /METHOD=SSTYPE(3)
  /POSTHOC=group(TUKEY T3)
  /EMMEANS=TABLES(group) COMPARE ADJ(BONFERRONI)
  /EMMEANS=TABLES(stage) COMPARE ADJ(BONFERRONI)
  /EMMEANS=TABLES(group*stage) COMPARE(group)
  /EMMEANS=TABLES(group*stage) COMPARE(stage)
  /PLOT=PROFILE(group*stage)
  /PRINT=DESCRIPTIVE ETASQ OPOWER HOMOGENEITY
  /CRITERIA=ALPHA(.05)
  /WSDESIGN=stage
  /DESIGN=group.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.



--
Michael
http://www.dewey.myzen.co.uk/home.html

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] R vs SPSS - simple effects analysis in mixed 2x2 ANOVA scheme - same data, different results

2016-05-22 Thread Michu Kom
down votefavoriteHell
<http://stats.stackexchange.com/questions/213592/r-vs-spss-simple-effects-analysis-in-mixed-2x2-anova-scheme-same-data-diffe#>

Hello,

I prepared a mixed 2x2 ANOVA design analysis both in SPSS and in R. The
SPSS script is correct, but in R script there is a mistake somewhere. To
test that I generated artificial data from a normal distribution to
simulate the interaction between two independent variables. There were no
difference between the results in main effects, but results of simple
effects analysis do not match when comparing between levels of variable
which introduced repeated measures (GROUP A: PRE vs POST ; GROUP B: PRE vs
POST).

I would be very thankful if you can help me. The code below will do
everything for you.

*Here is the code in R which:* - generates the data - calculates mixed
ANOVA - prepares data to csv format to import to SPSS - performs simple
effect analysis (there is probably a mistake)

N <- 100
absMean <- 1
sdCustom <- 5

grA_pre <- data.frame(ID = seq(N), lvl=rnorm(N, mean=absMean,
sd=sdCustom), group=factor('A'), stage = factor('pre'))
grA_post <- data.frame(ID = seq(N), lvl=rnorm(N, mean=-absMean,
sd=sdCustom), group=factor('A'), stage = factor('post'))
grB_pre <- data.frame(ID = seq(N+1,2*N), lvl=rnorm(N, mean=-absMean,
sd=sdCustom), group=factor('B'), stage = factor('pre'))
grB_post <- data.frame(ID = seq(N+1,2*N), lvl=rnorm(N, mean=absMean,
sd=sdCustom), group=factor('B'), stage = factor('post'))

gr <- rbind(grA_pre, grA_post, grB_pre, grB_post)
names(gr)
head(gr)
# save set to .csv to import to SPSS
grSPSS <- reshape(data = gr, timevar = "stage", idvar = c("ID",
"group"), direction = "wide")

write.csv2(grSPSS, file = "sample2.csv")

library(ggplot2)
library(plyr)
library(ez)
print("Omnibus mixed ANOVA - main effects and interactions")
ezPlot(data = gr, wid = ID, dv = lvl, between = group, within = stage,
type = "III", x = group, split = stage, x_lab = "Group", y_lab =
"Level of experience")
ezANOVA(data = gr, wid = ID, dv = lvl, between = group, within =
stage, detailed = TRUE, type = "III")#ezStats(data = gr, wid = ID, dv
= lvl, between = group, within = stage, type = "III")

print("Simple main effects analysis")
dataA <- subset(gr, group == "A" )
dataB <- subset(gr, group == "B" )
dataPRE <- subset(gr, stage == "pre" )
dataPOST <- subset(gr, stage == "post" )
print("GROUP = A: PRE vs POST")
simpleEffControlANOVA <- ezANOVA(data = dataA, dv = lvl, wid = ID,
within = stage, detailed = TRUE, type = "III"
)print(simpleEffControlANOVA)
print("GROUP = B: PRE vs POST")
simpleEffControlANOVA <- ezANOVA(data = dataB, dv = lvl, wid = ID,
within = stage, detailed = TRUE, type = "III"
)print(simpleEffControlANOVA)
print("STAGE = PRE: A vs B")
simpleEffControlANOVA <- ezANOVA(data = dataPRE, dv = lvl, wid = ID,
between = group, detailed = TRUE, type = "III"
)print(simpleEffControlANOVA)
print("STAGE = POST: A vs B")
simpleEffControlANOVA <- ezANOVA(data = dataPOST, dv = lvl, wid = ID,
between = group, detailed = TRUE, type = "III"
)print(simpleEffControlANOVA)

*Here is the code for SPSS Syntax which:* - calculates everything on
imported data, generated by R

DATASET ACTIVATE DataSet1.
GLM lvl.pre lvl.post BY group
  /WSFACTOR=stage 2 Polynomial
  /METHOD=SSTYPE(3)
  /POSTHOC=group(TUKEY T3)
  /EMMEANS=TABLES(group) COMPARE ADJ(BONFERRONI)
  /EMMEANS=TABLES(stage) COMPARE ADJ(BONFERRONI)
  /EMMEANS=TABLES(group*stage) COMPARE(group)
  /EMMEANS=TABLES(group*stage) COMPARE(stage)
  /PLOT=PROFILE(group*stage)
  /PRINT=DESCRIPTIVE ETASQ OPOWER HOMOGENEITY
  /CRITERIA=ALPHA(.05)
  /WSDESIGN=stage
  /DESIGN=group.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] R and SPSS

2012-11-06 Thread Hui Du
Hi group:


I have a data set, which has severe colinearity problem. While running linear 
regression in R and SPSS, I got different models. I am wondering if somebody 
knows how to make the two software output the same results. (I guess the way R 
and SPSS handling singularity is different, which leads to different models.)


Thanks.



[[alternative HTML version deleted]]

__
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] R and SPSS

2012-11-06 Thread Jeremy Miles
I think we'll need some output to know so we can see the differences. (And
data and code would be useful too, if you could provide a small example).

One thought is that the programs might remove a variable that is completely
collinear, but the different programs might remove different variables - so
check that the same variables have been removed.


Jeremy


On 6 November 2012 13:39, Hui Du hui...@dataventures.com wrote:

 Hi group:


 I have a data set, which has severe colinearity problem. While running
 linear regression in R and SPSS, I got different models. I am wondering if
 somebody knows how to make the two software output the same results. (I
 guess the way R and SPSS handling singularity is different, which leads to
 different models.)


 Thanks.



 [[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

__
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] R and SPSS

2012-11-06 Thread Ben Bolker
Jeremy Miles jeremy.miles at gmail.com writes:

 
 I think we'll need some output to know so we can see the differences. (And
 data and code would be useful too, if you could provide a small example).

  Definitely.
 
 One thought is that the programs might remove a variable that is completely
 collinear, but the different programs might remove different variables - so
 check that the same variables have been removed.
 
 Jeremy
 

  Furthermore, with severely collinear models, small numerical differences
can make a big difference, either in which variables you choose to remove
(e.g. if the variance inflation factors come out as (9.999,10.001) for
variables 1 and 2 in one package, but (10.001,9.999) in the other, or
in the actual linear algebra (based on technical details of linear algebra
and floating-point computations)

 On 6 November 2012 13:39, Hui Du Hui.Du at dataventures.com wrote:
 
  Hi group:
 
 
  I have a data set, which has severe colinearity problem. While running
  linear regression in R and SPSS, I got different models. I am wondering if
  somebody knows how to make the two software output the same results. (I
  guess the way R and SPSS handling singularity is different, which leads to
  different models.)

__
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] R and SPSS

2008-11-27 Thread Alain Guillet
Hi,

There exists a R plug-in for SPSS. You can find it on the SPSS website.

Hope it helps.

Alain



Liviu Andronic wrote:
 Hello,

 On Wed, Nov 26, 2008 at 9:25 PM, Applejus [EMAIL PROTECTED] wrote:
   
 I have a code in R. Could anyone give me the best possible way (or just
 ways!) to integrate it in SPSS?

 
 I would doubt you could do this, but for the least provide commented,
 minimal, self-contained, reproducible code. It would help if you were
 more specific.
 Liviu




   

-- 
Alain Guillet
Statistician and Computer Scientist

SMCS - Institut de statistique - Université catholique de Louvain
Bureau d.126
Voie du Roman Pays, 20
B-1348 Louvain-la-Neuve
Belgium

tel: +32 10 47 30 50


[[alternative HTML version deleted]]

__
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] R and SPSS

2008-11-27 Thread Tobias Verbeke
There exists a R plug-in for SPSS. You can find it on the SPSS website.

... and there is a page on the R wiki:

http://wiki.r-project.org/rwiki/doku.php?id=tips:callingr:spss

HTH,
Tobias

   
 I have a code in R. Could anyone give me the best possible way (or just
 ways!) to integrate it in SPSS?

 
 I would doubt you could do this, but for the least provide commented,
 minimal, self-contained, reproducible code. It would help if you were
 more specific.
 Liviu




   

-- 
Alain Guillet
Statistician and Computer Scientist

SMCS - Institut de statistique - Université catholique de Louvain
Bureau d.126
Voie du Roman Pays, 20
B-1348 Louvain-la-Neuve
Belgium

tel: +32 10 47 30 50


   [[alternative HTML version deleted]]



__
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] R and SPSS

2008-11-27 Thread Applejus

Thanks all!


Tobias Verbeke wrote:
 
There exists a R plug-in for SPSS. You can find it on the SPSS website.
 
 ... and there is a page on the R wiki:
 
 http://wiki.r-project.org/rwiki/doku.php?id=tips:callingr:spss
 
 HTH,
 Tobias
 
   
 I have a code in R. Could anyone give me the best possible way (or just
 ways!) to integrate it in SPSS?

 
 I would doubt you could do this, but for the least provide commented,
 minimal, self-contained, reproducible code. It would help if you were
 more specific.
 Liviu




   

-- 
Alain Guillet
Statistician and Computer Scientist

SMCS - Institut de statistique - Université catholique de Louvain
Bureau d.126
Voie du Roman Pays, 20
B-1348 Louvain-la-Neuve
Belgium

tel: +32 10 47 30 50


  [[alternative HTML version deleted]]


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

-- 
View this message in context: 
http://www.nabble.com/R-and-SPSS-tp20708367p20723360.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] R and SPSS

2008-11-26 Thread Applejus

Hi,

I have a code in R. Could anyone give me the best possible way (or just
ways!) to integrate it in SPSS?

Thanks!
-- 
View this message in context: 
http://www.nabble.com/R-and-SPSS-tp20708367p20708367.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] R and SPSS

2008-11-26 Thread Liviu Andronic
Hello,

On Wed, Nov 26, 2008 at 9:25 PM, Applejus [EMAIL PROTECTED] wrote:
 I have a code in R. Could anyone give me the best possible way (or just
 ways!) to integrate it in SPSS?

I would doubt you could do this, but for the least provide commented,
minimal, self-contained, reproducible code. It would help if you were
more specific.
Liviu




-- 
Do you know how to read?
http://www.alienetworks.com/srtest.cfm
Do you know how to write?
http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail

__
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] R and SPSS

2008-11-26 Thread Andrew Choens
On Wed, 2008-11-26 at 12:25 -0800, Applejus wrote:
 Hi,
 
 I have a code in R. Could anyone give me the best possible way (or just
 ways!) to integrate it in SPSS?
 
 Thanks!

You will need a SPSS registration, but go here and get the SPSS r
plugin.

http://www.spss.com/devcentral/

It lets you access R from within SPSS. Best of both worlds.

-- 
Insert something humorous here.  :-)

__
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] R and SPSS

2008-11-26 Thread David Winsemius


On Nov 26, 2008, at 7:57 PM, Andrew Choens wrote:



It lets you access R from within SPSS. Best of both worlds.

--
Insert something humorous here.  :-)


OK, I'll bite.

It lets you access R from within SPSS. Best of both worlds.


__
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] R vs SPSS contrasts

2008-10-12 Thread Chuck Cleland
On 10/11/2008 3:31 PM, Ted Harding wrote:
 Hi Folks,
 
 I'm comparing some output from R with output from SPSS.
 The coefficients of the independent variables (which are
 all factors, each at 2 levels) are identical.
 
 However, R's Intercept (using default contr.treatment)
 differs from SPSS's 'constant'. It seems that the contrasts
 were set in SPSS using
 
   /CONTRAST (varname)=Simple(1)
 
 I can get R's Intercept to match SPSS's 'constant' if I use
 contr.sum in R.
 
 Can someone please confirm that that is a correct match for
 the SPSS Simple(1), with identical effect?
 
 And is there a convenient on-line reference where I can look
 up what SPSS's /CONTRAST statements exactly mean?
 I've done a lot of googling, withbout coming up with anything
 satisfactory.
 
 With thanks,
 Ted.

Hi Ted:
  Here are two links with the same content giving a brief description of
SPSS simple contrasts:

http://www.ats.ucla.edu/stat/spss/library/contrast.htm
http://support.spss.com/productsext/spss/documentation/statistics/articles/contrast.htm

  These pages explain how simple contrasts differ from indicator
(contr.treatment) and deviation (contr.sum) contrasts.  For a factor
with 3 levels, I believe you can reproduce SPSS simple contrasts (with
the first category as reference) like this:

 C(warpbreaks$tension, contr=matrix(c(-1/3,2/3,-1/3,-1/3,-1/3,2/3),
ncol=2))
...
attr(,contrasts)
[,1]   [,2]
L -0.333 -0.333
M  0.667 -0.333
H -0.333  0.667
Levels: L M H

  For a factor with 2 levels, like this:

 C(warpbreaks$wool, contr=matrix(c(-1/2,1/2), ncol=1))
...
attr(,contrasts)
  [,1]
A -0.5
B  0.5
Levels: A B

  Your description of the effect of SPSS simple contrasts - intercept
coefficient of contr.sum and non-intercept coefficients of
contr.treatment - sounds accurate to me.

hope this helps,

Chuck

 
 E-Mail: (Ted Harding) [EMAIL PROTECTED]
 Fax-to-email: +44 (0)870 094 0861
 Date: 11-Oct-08   Time: 20:31:53
 -- XFMail --
 
 __
 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. 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
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] R vs SPSS contrasts

2008-10-12 Thread Gabor Grothendieck
Looks like the contrast matrix for indicator is contr.SAS(n),
for deviation is contr.sum(n) and for simple is:

(diag(n) - 1/n)[, -1]

That works at least for the n = 3 example in the link.
Perhaps the others could be checked against SPSS
for a variety of values of n to be sure.

On Sun, Oct 12, 2008 at 12:32 PM, Chuck Cleland [EMAIL PROTECTED] wrote:
 On 10/11/2008 3:31 PM, Ted Harding wrote:
 Hi Folks,

 I'm comparing some output from R with output from SPSS.
 The coefficients of the independent variables (which are
 all factors, each at 2 levels) are identical.

 However, R's Intercept (using default contr.treatment)
 differs from SPSS's 'constant'. It seems that the contrasts
 were set in SPSS using

   /CONTRAST (varname)=Simple(1)

 I can get R's Intercept to match SPSS's 'constant' if I use
 contr.sum in R.

 Can someone please confirm that that is a correct match for
 the SPSS Simple(1), with identical effect?

 And is there a convenient on-line reference where I can look
 up what SPSS's /CONTRAST statements exactly mean?
 I've done a lot of googling, withbout coming up with anything
 satisfactory.

 With thanks,
 Ted.

 Hi Ted:
  Here are two links with the same content giving a brief description of
 SPSS simple contrasts:

 http://www.ats.ucla.edu/stat/spss/library/contrast.htm
 http://support.spss.com/productsext/spss/documentation/statistics/articles/contrast.htm

  These pages explain how simple contrasts differ from indicator
 (contr.treatment) and deviation (contr.sum) contrasts.  For a factor
 with 3 levels, I believe you can reproduce SPSS simple contrasts (with
 the first category as reference) like this:

 C(warpbreaks$tension, contr=matrix(c(-1/3,2/3,-1/3,-1/3,-1/3,2/3),
 ncol=2))
 ...
 attr(,contrasts)
[,1]   [,2]
 L -0.333 -0.333
 M  0.667 -0.333
 H -0.333  0.667
 Levels: L M H

  For a factor with 2 levels, like this:

 C(warpbreaks$wool, contr=matrix(c(-1/2,1/2), ncol=1))
 ...
 attr(,contrasts)
  [,1]
 A -0.5
 B  0.5
 Levels: A B

  Your description of the effect of SPSS simple contrasts - intercept
 coefficient of contr.sum and non-intercept coefficients of
 contr.treatment - sounds accurate to me.

 hope this helps,

 Chuck

 
 E-Mail: (Ted Harding) [EMAIL PROTECTED]
 Fax-to-email: +44 (0)870 094 0861
 Date: 11-Oct-08   Time: 20:31:53
 -- XFMail --

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

 --
 Chuck Cleland, Ph.D.
 NDRI, Inc. (www.ndri.org)
 71 West 23rd Street, 8th floor
 New York, NY 10010
 tel: (212) 845-4495 (Tu, Th)
 tel: (732) 512-0171 (M, W, F)
 fax: (917) 438-0894

 __
 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] R vs SPSS contrasts

2008-10-12 Thread Gabor Grothendieck
The formula should be (diag(n) - 1/n)[, -n]

On Sun, Oct 12, 2008 at 1:36 PM, Gabor Grothendieck
[EMAIL PROTECTED] wrote:
 Looks like the contrast matrix for indicator is contr.SAS(n),
 for deviation is contr.sum(n) and for simple is:

 (diag(n) - 1/n)[, -1]

 That works at least for the n = 3 example in the link.
 Perhaps the others could be checked against SPSS
 for a variety of values of n to be sure.

 On Sun, Oct 12, 2008 at 12:32 PM, Chuck Cleland [EMAIL PROTECTED] wrote:
 On 10/11/2008 3:31 PM, Ted Harding wrote:
 Hi Folks,

 I'm comparing some output from R with output from SPSS.
 The coefficients of the independent variables (which are
 all factors, each at 2 levels) are identical.

 However, R's Intercept (using default contr.treatment)
 differs from SPSS's 'constant'. It seems that the contrasts
 were set in SPSS using

   /CONTRAST (varname)=Simple(1)

 I can get R's Intercept to match SPSS's 'constant' if I use
 contr.sum in R.

 Can someone please confirm that that is a correct match for
 the SPSS Simple(1), with identical effect?

 And is there a convenient on-line reference where I can look
 up what SPSS's /CONTRAST statements exactly mean?
 I've done a lot of googling, withbout coming up with anything
 satisfactory.

 With thanks,
 Ted.

 Hi Ted:
  Here are two links with the same content giving a brief description of
 SPSS simple contrasts:

 http://www.ats.ucla.edu/stat/spss/library/contrast.htm
 http://support.spss.com/productsext/spss/documentation/statistics/articles/contrast.htm

  These pages explain how simple contrasts differ from indicator
 (contr.treatment) and deviation (contr.sum) contrasts.  For a factor
 with 3 levels, I believe you can reproduce SPSS simple contrasts (with
 the first category as reference) like this:

 C(warpbreaks$tension, contr=matrix(c(-1/3,2/3,-1/3,-1/3,-1/3,2/3),
 ncol=2))
 ...
 attr(,contrasts)
[,1]   [,2]
 L -0.333 -0.333
 M  0.667 -0.333
 H -0.333  0.667
 Levels: L M H

  For a factor with 2 levels, like this:

 C(warpbreaks$wool, contr=matrix(c(-1/2,1/2), ncol=1))
 ...
 attr(,contrasts)
  [,1]
 A -0.5
 B  0.5
 Levels: A B

  Your description of the effect of SPSS simple contrasts - intercept
 coefficient of contr.sum and non-intercept coefficients of
 contr.treatment - sounds accurate to me.

 hope this helps,

 Chuck

 
 E-Mail: (Ted Harding) [EMAIL PROTECTED]
 Fax-to-email: +44 (0)870 094 0861
 Date: 11-Oct-08   Time: 20:31:53
 -- XFMail --

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

 --
 Chuck Cleland, Ph.D.
 NDRI, Inc. (www.ndri.org)
 71 West 23rd Street, 8th floor
 New York, NY 10010
 tel: (212) 845-4495 (Tu, Th)
 tel: (732) 512-0171 (M, W, F)
 fax: (917) 438-0894

 __
 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] R vs SPSS contrasts

2008-10-12 Thread Gabor Grothendieck
I found this link:

http://webs.edinboro.edu/EDocs/SPSS/SPSS%20Regression%20Models%2013.0.pdf

which indicates that the contrast in SPSS that is used
depends not only on the contrast selected but also on the
reference category selected and the two can be chosen
independently.  Thus one could have simple/first, simple/last,
deviation/first, deviation/last, etc.  An R contr.SPSS function
would have to specify both the deviation type and the
first/last in order to handle all SPSS variations.

On Sun, Oct 12, 2008 at 1:48 PM, Gabor Grothendieck
[EMAIL PROTECTED] wrote:
 The formula should be (diag(n) - 1/n)[, -n]

 On Sun, Oct 12, 2008 at 1:36 PM, Gabor Grothendieck
 [EMAIL PROTECTED] wrote:
 Looks like the contrast matrix for indicator is contr.SAS(n),
 for deviation is contr.sum(n) and for simple is:

 (diag(n) - 1/n)[, -1]

 That works at least for the n = 3 example in the link.
 Perhaps the others could be checked against SPSS
 for a variety of values of n to be sure.

 On Sun, Oct 12, 2008 at 12:32 PM, Chuck Cleland [EMAIL PROTECTED] wrote:
 On 10/11/2008 3:31 PM, Ted Harding wrote:
 Hi Folks,

 I'm comparing some output from R with output from SPSS.
 The coefficients of the independent variables (which are
 all factors, each at 2 levels) are identical.

 However, R's Intercept (using default contr.treatment)
 differs from SPSS's 'constant'. It seems that the contrasts
 were set in SPSS using

   /CONTRAST (varname)=Simple(1)

 I can get R's Intercept to match SPSS's 'constant' if I use
 contr.sum in R.

 Can someone please confirm that that is a correct match for
 the SPSS Simple(1), with identical effect?

 And is there a convenient on-line reference where I can look
 up what SPSS's /CONTRAST statements exactly mean?
 I've done a lot of googling, withbout coming up with anything
 satisfactory.

 With thanks,
 Ted.

 Hi Ted:
  Here are two links with the same content giving a brief description of
 SPSS simple contrasts:

 http://www.ats.ucla.edu/stat/spss/library/contrast.htm
 http://support.spss.com/productsext/spss/documentation/statistics/articles/contrast.htm

  These pages explain how simple contrasts differ from indicator
 (contr.treatment) and deviation (contr.sum) contrasts.  For a factor
 with 3 levels, I believe you can reproduce SPSS simple contrasts (with
 the first category as reference) like this:

 C(warpbreaks$tension, contr=matrix(c(-1/3,2/3,-1/3,-1/3,-1/3,2/3),
 ncol=2))
 ...
 attr(,contrasts)
[,1]   [,2]
 L -0.333 -0.333
 M  0.667 -0.333
 H -0.333  0.667
 Levels: L M H

  For a factor with 2 levels, like this:

 C(warpbreaks$wool, contr=matrix(c(-1/2,1/2), ncol=1))
 ...
 attr(,contrasts)
  [,1]
 A -0.5
 B  0.5
 Levels: A B

  Your description of the effect of SPSS simple contrasts - intercept
 coefficient of contr.sum and non-intercept coefficients of
 contr.treatment - sounds accurate to me.

 hope this helps,

 Chuck

 
 E-Mail: (Ted Harding) [EMAIL PROTECTED]
 Fax-to-email: +44 (0)870 094 0861
 Date: 11-Oct-08   Time: 20:31:53
 -- XFMail --

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

 --
 Chuck Cleland, Ph.D.
 NDRI, Inc. (www.ndri.org)
 71 West 23rd Street, 8th floor
 New York, NY 10010
 tel: (212) 845-4495 (Tu, Th)
 tel: (732) 512-0171 (M, W, F)
 fax: (917) 438-0894

 __
 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] R vs SPSS contrasts

2008-10-12 Thread Ted Harding
Very many thanks, Chuck and Gabor, for the comments and the
references to on-line explanations. It is beginning to become
clear!

Most grateful.
Ted.

On 12-Oct-08 18:03:53, Gabor Grothendieck wrote:
 I found this link:
 
 http://webs.edinboro.edu/EDocs/SPSS/SPSS%20Regression%20Models%2013.0.pd
 f
 
 which indicates that the contrast in SPSS that is used
 depends not only on the contrast selected but also on the
 reference category selected and the two can be chosen
 independently.  Thus one could have simple/first, simple/last,
 deviation/first, deviation/last, etc.  An R contr.SPSS function
 would have to specify both the deviation type and the
 first/last in order to handle all SPSS variations.
 
 On Sun, Oct 12, 2008 at 1:48 PM, Gabor Grothendieck
 [EMAIL PROTECTED] wrote:
 The formula should be (diag(n) - 1/n)[, -n]

 On Sun, Oct 12, 2008 at 1:36 PM, Gabor Grothendieck
 [EMAIL PROTECTED] wrote:
 Looks like the contrast matrix for indicator is contr.SAS(n),
 for deviation is contr.sum(n) and for simple is:

 (diag(n) - 1/n)[, -1]

 That works at least for the n = 3 example in the link.
 Perhaps the others could be checked against SPSS
 for a variety of values of n to be sure.

 On Sun, Oct 12, 2008 at 12:32 PM, Chuck Cleland
 [EMAIL PROTECTED] wrote:
 On 10/11/2008 3:31 PM, Ted Harding wrote:
 Hi Folks,

 I'm comparing some output from R with output from SPSS.
 The coefficients of the independent variables (which are
 all factors, each at 2 levels) are identical.

 However, R's Intercept (using default contr.treatment)
 differs from SPSS's 'constant'. It seems that the contrasts
 were set in SPSS using

   /CONTRAST (varname)=Simple(1)

 I can get R's Intercept to match SPSS's 'constant' if I use
 contr.sum in R.

 Can someone please confirm that that is a correct match for
 the SPSS Simple(1), with identical effect?

 And is there a convenient on-line reference where I can look
 up what SPSS's /CONTRAST statements exactly mean?
 I've done a lot of googling, withbout coming up with anything
 satisfactory.

 With thanks,
 Ted.

 Hi Ted:
  Here are two links with the same content giving a brief description
  of
 SPSS simple contrasts:

 http://www.ats.ucla.edu/stat/spss/library/contrast.htm
 http://support.spss.com/productsext/spss/documentation/statistics/art
 icles/contrast.htm

  These pages explain how simple contrasts differ from indicator
 (contr.treatment) and deviation (contr.sum) contrasts.  For a factor
 with 3 levels, I believe you can reproduce SPSS simple contrasts
 (with
 the first category as reference) like this:

 C(warpbreaks$tension, contr=matrix(c(-1/3,2/3,-1/3,-1/3,-1/3,2/3),
 ncol=2))
 ...
 attr(,contrasts)
[,1]   [,2]
 L -0.333 -0.333
 M  0.667 -0.333
 H -0.333  0.667
 Levels: L M H

  For a factor with 2 levels, like this:

 C(warpbreaks$wool, contr=matrix(c(-1/2,1/2), ncol=1))
 ...
 attr(,contrasts)
  [,1]
 A -0.5
 B  0.5
 Levels: A B

  Your description of the effect of SPSS simple contrasts - intercept
 coefficient of contr.sum and non-intercept coefficients of
 contr.treatment - sounds accurate to me.

 hope this helps,

 Chuck

 
 E-Mail: (Ted Harding) [EMAIL PROTECTED]
 Fax-to-email: +44 (0)870 094 0861
 Date: 11-Oct-08   Time:
 20:31:53
 -- XFMail
 --

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

 --
 Chuck Cleland, Ph.D.
 NDRI, Inc. (www.ndri.org)
 71 West 23rd Street, 8th floor
 New York, NY 10010
 tel: (212) 845-4495 (Tu, Th)
 tel: (732) 512-0171 (M, W, F)
 fax: (917) 438-0894

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


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 12-Oct-08   Time: 21:04:48
-- XFMail --

__
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

Re: [R] R vs SPSS contrasts

2008-10-11 Thread Gabor Grothendieck
Don't know but perhaps you could just use each of:
contr.helmert, contr.poly, contr.sum, contr.treatment, contr.SAS
in turn on the R side until you get one that matches.  Once you
find out adding a contr.SPSS to R might be nice.

On Sat, Oct 11, 2008 at 3:31 PM, Ted Harding
[EMAIL PROTECTED] wrote:
 Hi Folks,

 I'm comparing some output from R with output from SPSS.
 The coefficients of the independent variables (which are
 all factors, each at 2 levels) are identical.

 However, R's Intercept (using default contr.treatment)
 differs from SPSS's 'constant'. It seems that the contrasts
 were set in SPSS using

  /CONTRAST (varname)=Simple(1)

 I can get R's Intercept to match SPSS's 'constant' if I use
 contr.sum in R.

 Can someone please confirm that that is a correct match for
 the SPSS Simple(1), with identical effect?

 And is there a convenient on-line reference where I can look
 up what SPSS's /CONTRAST statements exactly mean?
 I've done a lot of googling, withbout coming up with anything
 satisfactory.

 With thanks,
 Ted.

 
 E-Mail: (Ted Harding) [EMAIL PROTECTED]
 Fax-to-email: +44 (0)870 094 0861
 Date: 11-Oct-08   Time: 20:31:53
 -- XFMail --

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