[R] Within-subject factors in lme
Dear R-users I'm considering a repeated measures experiment where two within-subject factors A (2 levels) and B (3 levels) have been measured for each of 14 subjects, S. I wish to test the effect of factor A. I know that a variance component model with random effects S, S:A, S:B and S:A:B can be fitted using aov: aov( y ~ A*B + Error(S/(A*B)) ) If there is no significant interaction, the test for the effect of A is carried out in the S:A error strata. How can a test for the effect of A be performed using lme from the nlme package? ( lme( y ~ A*B, random=~1|S/(A*B)) is apparently not correct ) Thanks in advance for your advice. Kim. __ R-help@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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Within-subject factors in lme
Dear Thilo Thanks for your suggestion. I guess the model you are fitting here has only a single random effect term, namely subject. If the effect of A depends on S, one needs to include an additional random effects term for the S:A interaction. With lme I can get output for the effect of A which is very similar to the aov output using lme( y ~ A + B, random=~ 1|S/A ) but here I have cheated by not including factor B in the 'random=' terms. But the output from anova( lme( y ~ A + B, random=~ 1|S/A ) ) is numDF denDF F-value p-value (Intercept) 154 388.4006 .0001 B254 154.0193 .0001 A113 4.4581 0.0547 where the last line appears equivalent to the aov output: Error: Subject:Treatment Df Sum Sq Mean Sq F value Pr(F) A 1 0.66074 0.66074 4.4581 0.05467 . Residuals 13 1.92676 0.14821 But I still need to account for the random S:B interaction. I can see a similar issue has been discussed earlier, see eg https://stat.ethz.ch/pipermail/r-help/2006-August/111018.html Here, lme( y ~ A*B, random=~1|S ) was also suggested (essentially), but this gives quite different results from aov and the lme example above. In this particular case I get numDF denDF F-value p-value (Intercept) 167 388.3976 .0001 B 267 104.8436 .0001 A 167 10.3707 0.002 I have seen instances of something like random=list(S=pdBlocked(list(pdIdent(~A-1)..., but I can't get this to work (and I have no idea what this does). Best regards, Kim. 2007/1/12, Thilo Kellermann [EMAIL PROTECTED]: Dear Kim, as far as I understandyour problem correct the specification of the model in lme is: lme( fixed=y ~ A*B, random=~1|S) Thilo On Friday 12 January 2007 15:54, Kim Mouridsen wrote: Dear R-users I'm considering a repeated measures experiment where two within-subject factors A (2 levels) and B (3 levels) have been measured for each of 14 subjects, S. I wish to test the effect of factor A. I know that a variance component model with random effects S, S:A, S:B and S:A:B can be fitted using aov: aov( y ~ A*B + Error(S/(A*B)) ) If there is no significant interaction, the test for the effect of A is carried out in the S:A error strata. How can a test for the effect of A be performed using lme from the nlme package? ( lme( y ~ A*B, random=~1|S/(A*B)) is apparently not correct ) Thanks in advance for your advice. Kim. __ R-help@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 and provide commented, minimal, self-contained, reproducible code. -- Thilo Kellermann Department of Psychiatry und Psychotherapy RWTH Aachen University Pauwelstr. 30 52074 Aachen Tel.: +49 (0)241 / 8089977 Fax.: +49 (0)241 / 8082401 E-Mail: [EMAIL PROTECTED] __ R-help@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 and provide commented, minimal, self-contained, reproducible code.
[R] MARS in classification problem
Dear R-experts I recently tried out the Salford Systems MARS software on a large dataset. Apparently MARS outperformed traditional techniques such as logistic regression and k-nearest-neighbor. Since I usually perform all my data analyses in R I have installed the 'mda' package but I seem to get much worse results with R than with the Salford Systems software. In my data set I have 7 continuous predictors and a binary outcome. The training data set has 100.000 samples. I try to use the same parameters I used in the MARS program: mars(x=train.set,y=response,degree=2,nk=80,penalty=3) With the MARS program I would get GCV values of approximately 0.11 but with R I get 0.15. The corresponding reduction in area under the operator characteristics curve (AUC) is from 0.83 to 0.70. What am I doing wrong? Thanks in advance! Kim Mouridsen. __ [EMAIL PROTECTED] 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] logistic regression
Dear R-experts A binary response is observed for patients receiving one of three different drugs injected in different doses. That is for each drug (treatment) we have a dose-response model. Additionlly the patient's age and gender is recorded. Initially I ran three logistic regressions, one for each drug type with gender as categorical variable and age and dose as continuous variables. If I want to know the effect of, say, gender on the response I now have three odds ratios - one for each dose response model. My question is: How can I compare the three odds ratios? Is it possible in R to combine the three dose-response models into a single model to get an overall estimate of the effect of age? Can I do something like lr - glm(vom ~ therapy*age + therapy*gender + therapy*cisdose+therapy*cardose+therapy*cycdose,family=binomial,data=emrisk) Thanks in advance! Kim Mouridsen. _ OFiR Spil - Vind 1.000 vis af kroner! Besøg http://spil.ofir.dk OFiR Kontakt - Find en at dele julen med - Besøg http://kontakt.ofir.dk __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] regression with limited range response
Dear R experts How can you perform a regression analysis in R when the dependent variable is countiuous but bounded, say between 0 and 100? I would be grateful for pointers to R-functions but also for hints to relavant litterature since I have never worked with this problem before. Thanks in advance. Kim Mouridsen. [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] dev.print in R 1.7.1
Dear R experts How do I save a plot to a file in a specified format, f.ex png? Apparently save.plot no longer exists, so I tried instead dev.print(file=H:\\jesperf\\data1image,device=png()) However no file is created and much worse no graphics is produced (on screen or file) if I run f.ex qqnorm afterwards. What am I doing wrong and how do I get R to print graphics on the screen as ususal? Thanks in advance for your help. Kim. Kim Mouridsen M.Sc., Ph.D student Center for Functionally Integrative Neuroscience (CFIN) Århus University Hospital Nørrebrogade 44 Building 30, 1. DK-8000 Århus C, Denmark Phone +45 8949 4099 FAX +45 8949 4400 [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] Jonckheere-Terpstra test
The Jonckheere-Terpstra test is a distribution-free test for ordered alternatives in a one-way layout. More specifically, assume X_ij = m + t_j + e_ij, i=1,...,n_j and j=1,...,k, where the errors are idependent and identically distributed. Then you can use the Jonckheere-Terpstra to test H_0:t_1=t_2=...=t_k against H_A:t_1=t_2=...=t_k, where at least one of the inequalities is strict. To my knowledge there is no R code for this test but the test statistic is not too hard to calculate (you have to calculate some Mann-Whitney counts) and the p-value can be found in a table - or in case you have many observations you can use a large-sample approximation. The original article appeared in Biometrika, Vol. 41, No. 1/2. (Jun., 1954), pp. 133-145 But it is probably easier to read page 120-123 in Nonparametric statistical methods by Hollander and Wolfe (1973) Wiley Sons. A NOT-distribution-free alternative to this test is described in Biometrika, Vol. 72, No. 2. (Aug., 1985), pp. 476-480. Kim. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: 5. oktober 2003 14:51 To: [EMAIL PROTECTED] Subject: [R] Jonckheere-Terpstra test Hello, can anybody here explain what a Jonckheere-Terpstra test is and whether it is implemented in R? I just know it's a non-parametric test, otherwise I've no clue about it ;-( . Are there alternatives to this test? thanks for help, Arne __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help