I try to move from SPSS to R/S and am trying to reproduce the results of SPSS
in R. I calculated a one-way anova with "spk" as experimental factor and erp
as depended variable.
The result of the Anova are the same concearning the mean square, F and p
values. But I also wanted to caculate the contr.sdif(4) contrast on spk. The
results are completely different now. I hope anybody can help me.
Thanks, Wolfgang
This is what I get in SPSS:
Tests of Within-Subjects Contrasts
Measure: MEASURE_1
Source SPKType III Sum of Squares df Mean Square F Sig.
SPK Level 2 vs. Level 1 3,493 1 3,493 2,026 ,178
Level 3 vs. Previous 20,358 1 20,358 10,168 ,007
Level 4 vs. Previous 18,808 1 18,808 15,368 ,002
Error(SPK) Level 2 vs. Level 1 22,414 13 1,724
Level 3 vs. Previous 26,030 13 2,002
Level 4 vs. Previous 15,911 13 1,224
This is the result in R:
Error: sub
Df Sum Sq Mean Sq F value Pr(>F)
Residuals 13 205.79 15.83
Error: Within
Df Sum Sq Mean Sq F value Pr(>F)
spk 3 29.425 9.808 9.4467 8.055e-05 ***
spk: p 1 1.747 1.747 1.6821 0.2022649
spk: q 1 13.572 13.572 13.0719 0.0008479 ***
spk: r 1 14.106 14.106 13.5861 0.0006915 ***
Residuals 39 40.493 1.038
---
Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
Spk.df <- data.frame(sub,spk,erp)
subset(Spk.df, subset=(sub!="14oddball" & sub!="18odd" & sub!="19odd" &
sub!="20oddball")) -> Spk.selected.df
contrasts(Spk.selected.df$spk) <- contr.sdif(4)
aov(erp ~ spk + Error(sub), data=Spk.selected.df) -> Spk.aov
summary(Spk.aov,data=Spk.selected.df,split=list(spk=list(p=1,q=2,r=3)))
this is the the beginning of the dataframe, which I use:
sub spk erp
1 10oddball spk1 2.587
2 11oddball spk1 -0.335
3 12oddball spk1 5.564
5 15oddball spk1 0.691
6 17oddball spk1 -1.846
10 21oddball spk1 1.825
11 22oddball spk1 0.370
12 2oddball spk1 3.234
13 3oddball spk1 1.462
14 5oddball spk1 2.535
15 6oddball spk1 9.373
16 7oddball spk1 2.132
17 8oddball spk1 -0.518
18 9oddball spk1 2.450
19 10oddball spk2 2.909
20 11oddball spk2 0.708
21 12oddball spk2 4.684
23 15oddball spk2 3.599
...
newbie question on contrasts and aov
6 messages · Wolfgang Pauli, Brian Ripley, Salah Mahmud +2 more
Notice `SPKType III Sum of Squares'. I don't believe your contrasts are orthogonal, and R's are sequential sum of squares. Also, are you sure these are the same contrasts? I presume this is contr.sdif from MASS (in which case it is churlish not to credit it), and SPSS's contrasts look more like Helmert contrasts from their labelling. Since it appears all your treatments are within subjects you do seem to be making life difficult for yourself. Although I would have done a simple fixed-effects analysis, applying summary.lm to the bottom stratum would give you simple t-tests for each contrast, including actual estimates of the magnitudes.
On Sun, 11 Jan 2004, Wolfgang Pauli wrote:
I try to move from SPSS to R/S and am trying to reproduce the results of SPSS
in R. I calculated a one-way anova with "spk" as experimental factor and erp
as depended variable.
The result of the Anova are the same concearning the mean square, F and p
values. But I also wanted to caculate the contr.sdif(4) contrast on spk. The
results are completely different now. I hope anybody can help me.
Thanks, Wolfgang
This is what I get in SPSS:
Tests of Within-Subjects Contrasts
Measure: MEASURE_1
Source SPKType III Sum of Squares df Mean Square F Sig.
SPK Level 2 vs. Level 1 3,493 1 3,493 2,026 ,178
Level 3 vs. Previous 20,358 1 20,358 10,168 ,007
Level 4 vs. Previous 18,808 1 18,808 15,368 ,002
Error(SPK) Level 2 vs. Level 1 22,414 13 1,724
Level 3 vs. Previous 26,030 13 2,002
Level 4 vs. Previous 15,911 13 1,224
This is the result in R:
Error: sub
Df Sum Sq Mean Sq F value Pr(>F)
Residuals 13 205.79 15.83
Error: Within
Df Sum Sq Mean Sq F value Pr(>F)
spk 3 29.425 9.808 9.4467 8.055e-05 ***
spk: p 1 1.747 1.747 1.6821 0.2022649
spk: q 1 13.572 13.572 13.0719 0.0008479 ***
spk: r 1 14.106 14.106 13.5861 0.0006915 ***
Residuals 39 40.493 1.038
---
Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
Spk.df <- data.frame(sub,spk,erp)
subset(Spk.df, subset=(sub!="14oddball" & sub!="18odd" & sub!="19odd" &
sub!="20oddball")) -> Spk.selected.df
contrasts(Spk.selected.df$spk) <- contr.sdif(4)
aov(erp ~ spk + Error(sub), data=Spk.selected.df) -> Spk.aov
summary(Spk.aov,data=Spk.selected.df,split=list(spk=list(p=1,q=2,r=3)))
this is the the beginning of the dataframe, which I use:
sub spk erp
1 10oddball spk1 2.587
2 11oddball spk1 -0.335
3 12oddball spk1 5.564
5 15oddball spk1 0.691
6 17oddball spk1 -1.846
10 21oddball spk1 1.825
11 22oddball spk1 0.370
12 2oddball spk1 3.234
13 3oddball spk1 1.462
14 5oddball spk1 2.535
15 6oddball spk1 9.373
16 7oddball spk1 2.132
17 8oddball spk1 -0.518
18 9oddball spk1 2.450
19 10oddball spk2 2.909
20 11oddball spk2 0.708
21 12oddball spk2 4.684
23 15oddball spk2 3.599
...
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
1 day later
Does anyone know of the existence of R code for estimating the survivor function and its standard error where survival time (T) is defined as the time between two interval-censored events, i.e., both events are only known to occur within an interval? This is the situation that commonly arises in longitudinal studies of viral infections. For instance T could be the time of clearing HPV infection when the dates of acquisition and loss (clearance) of infection are not measured exactly but known to occur between two consecutive dates (dates of prescheduled follow-up visits). Many thanks, Salah
Have you looked at library(survival)? Unless I misunderstand what you
want, it should be there. Further documentation is provided in Venables
and Ripley (2002) Modern Applied Statistics with W, Therneau and
Grambsch (2000) Modeling Survival Data, Harrell (2001) Regression
Modeling Strategies (all Springer), and in materials downloadable from
www.r-project.org; see especially search -> "R site search". Have you
tried these sources?
hope this helps. spencer graves
Salah Mahmud wrote:
Does anyone know of the existence of R code for estimating the survivor function and its standard error where survival time (T) is defined as the time between two interval-censored events, i.e., both events are only known to occur within an interval? This is the situation that commonly arises in longitudinal studies of viral infections. For instance T could be the time of clearing HPV infection when the dates of acquisition and loss (clearance) of infection are not measured exactly but known to occur between two consecutive dates (dates of prescheduled follow-up visits). Many thanks, Salah
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
On Mon, 12 Jan 2004, Spencer Graves wrote:
Have you looked at library(survival)? Unless I misunderstand what you want, it should be there
It isn't. -thomas
. Further documentation is provided in Venables
and Ripley (2002) Modern Applied Statistics with W, Therneau and
Grambsch (2000) Modeling Survival Data, Harrell (2001) Regression
Modeling Strategies (all Springer), and in materials downloadable from
www.r-project.org; see especially search -> "R site search". Have you
tried these sources?
hope this helps. spencer graves
Salah Mahmud wrote:
Does anyone know of the existence of R code for estimating the survivor function and its standard error where survival time (T) is defined as the time between two interval-censored events, i.e., both events are only known to occur within an interval? This is the situation that commonly arises in longitudinal studies of viral infections. For instance T could be the time of clearing HPV infection when the dates of acquisition and loss (clearance) of infection are not measured exactly but known to occur between two consecutive dates (dates of prescheduled follow-up visits). Many thanks, Salah
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Thomas Lumley Assoc. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle
16 days later
In the meantime I figured out that the Difference-contrast is not quite what I
was looking for. But I still have two questions
1) Why do I get different results for Helmert contrasts in SPSS and R. I guess
the contrast matrixes of Helmert are about the same in SPSS and R. I probably
make a mistake as i am a newbie to R. I thought that it might be, because I
have a repaeted measures design. That's why I put the Error(sub) in the
formula of aov.
2)
I tried to make my own contrast matrix, to compute comparisons between
adjacent factor levels, i.e. 1-2, 2-3 and 3-4. My matrix looks like this:
[,1] [,2] [,3]
[1,] 1 0 0
[2,] -1 1 0
[3,] 0 -1 1
[4,] 0 0 -1
But then I get the same result as with contr.helmert(4). What is wrong I
really don't get it!
Thank you,
Wolfgang Pauli
On Sunday January 11 2004 18:07, you wrote:
Notice `SPKType III Sum of Squares'. I don't believe your contrasts are orthogonal, and R's are sequential sum of squares. Also, are you sure these are the same contrasts? I presume this is contr.sdif from MASS (in which case it is churlish not to credit it), and SPSS's contrasts look more like Helmert contrasts from their labelling. Since it appears all your treatments are within subjects you do seem to be making life difficult for yourself. Although I would have done a simple fixed-effects analysis, applying summary.lm to the bottom stratum would give you simple t-tests for each contrast, including actual estimates of the magnitudes. On Sun, 11 Jan 2004, Wolfgang Pauli wrote:
I try to move from SPSS to R/S and am trying to reproduce the results of
SPSS in R. I calculated a one-way anova with "spk" as experimental factor
and erp as depended variable.
The result of the Anova are the same concearning the mean square, F and p
values. But I also wanted to caculate the contr.sdif(4) contrast on spk.
The results are completely different now. I hope anybody can help me.
Thanks, Wolfgang
This is what I get in SPSS:
Tests of Within-Subjects Contrasts
Measure: MEASURE_1
Source SPKType III Sum of Squares df Mean Square F Sig.
SPK Level 2 vs. Level 1 3,493 1 3,493 2,026 ,178
Level 3 vs. Previous 20,358 1 20,358 10,168 ,007
Level 4 vs. Previous 18,808 1 18,808 15,368 ,002
Error(SPK) Level 2 vs. Level 1 22,414 13 1,724
Level 3 vs. Previous 26,030 13 2,002
Level 4 vs. Previous 15,911 13 1,224
This is the result in R:
Error: sub
Df Sum Sq Mean Sq F value Pr(>F)
Residuals 13 205.79 15.83
Error: Within
Df Sum Sq Mean Sq F value Pr(>F)
spk 3 29.425 9.808 9.4467 8.055e-05 ***
spk: p 1 1.747 1.747 1.6821 0.2022649
spk: q 1 13.572 13.572 13.0719 0.0008479 ***
spk: r 1 14.106 14.106 13.5861 0.0006915 ***
Residuals 39 40.493 1.038
---
Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
Spk.df <- data.frame(sub,spk,erp)
subset(Spk.df, subset=(sub!="14oddball" & sub!="18odd" & sub!="19odd" &
sub!="20oddball")) -> Spk.selected.df
contrasts(Spk.selected.df$spk) <- contr.sdif(4)
aov(erp ~ spk + Error(sub), data=Spk.selected.df) -> Spk.aov
summary(Spk.aov,data=Spk.selected.df,split=list(spk=list(p=1,q=2,r=3)))
this is the the beginning of the dataframe, which I use:
sub spk erp
1 10oddball spk1 2.587
2 11oddball spk1 -0.335
3 12oddball spk1 5.564
5 15oddball spk1 0.691
6 17oddball spk1 -1.846
10 21oddball spk1 1.825
11 22oddball spk1 0.370
12 2oddball spk1 3.234
13 3oddball spk1 1.462
14 5oddball spk1 2.535
15 6oddball spk1 9.373
16 7oddball spk1 2.132
17 8oddball spk1 -0.518
18 9oddball spk1 2.450
19 10oddball spk2 2.909
20 11oddball spk2 0.708
21 12oddball spk2 4.684
23 15oddball spk2 3.599
...
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html