[R] R: fractional factorial design in R
If an orthogonal main effect plan exists for the number of trials you specify, optFederov() in AlgDesign will more than likely find it for you, since such a design should be an optimal design. thanks very much to you and the others!! I have written a little function, and now the syntax to obtain an orthogonal design such as 2x4x3x2 is: design.test - gen.orthogonal.design(c(2,4,3,2)) gen.orthogonal.design - function(listFactors){ library(AlgDesign) FactorsNames-c(A,B,C,D,E,F,G,H,J,K,L) numFactors-length(listFactors) dat-gen.factorial(listFactors,center=FALSE,varNames=FactorsNames[1:numFacto rs]) desPB-optFederov(~.,dat,nRepeats=20,approximate=TRUE) design-desPB$design[,2:numFactors] cat(Minimum number of trials: , fill=T, length(design[,1]), append=T) #cor(design) return(design) } Roberto Furlan University of Turin, Italy La mia Cartella di Posta in Arrivo è protetta con SPAMfighter 188 messaggi contenenti spam sono stati bloccati con successo. Scarica gratuitamente SPAMfighter! __ 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
[R] R: fractional factorial design in R
sorry, some small mistakes in the previuos syntax. This works! design.test - gen.orthogonal.design(c(2,4,3),numCards=16) design.test gen.orthogonal.design - function(listFactors,numCards){ library(AlgDesign) FactorsNames-c(A,B,C,D,E,F,G,H,J,K,L) numFactors-length(listFactors) dat-gen.factorial(listFactors,center=FALSE,varNames=FactorsNames[1:numFacto rs]) desPB-optFederov(~.,dat,nRepeats=20,approximate=FALSE,nTrials=numCards) design-desPB$design#[,2:(numFactors+1)] cat(Number of trials: , fill=T, length(design[,1]), append=T) print(cor(design)) return(design) } However, it is necessary to run the function and guess numCards until the correlation matrix is diagonal and all levels are selected for the final design. Any idea how to solve this problem without an iterative function? Roberto Furlan University of Turin, Italy La mia Cartella di Posta in Arrivo è protetta con SPAMfighter 188 messaggi contenenti spam sono stati bloccati con successo. Scarica gratuitamente SPAMfighter! __ 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
Re: [R] R: fractional factorial design in R
I think you need to add factors=all to gen.factorial(), otherwise the model df will be less than what you expect. gen.orthogonal.design(c(2,2,3,3,3,3,2,2),numCards=16) [EMAIL PROTECTED] wrote: sorry, some small mistakes in the previuos syntax. This works! design.test - gen.orthogonal.design(c(2,4,3),numCards=16) design.test gen.orthogonal.design - function(listFactors,numCards){ library(AlgDesign) FactorsNames-c(A,B,C,D,E,F,G,H,J,K,L) numFactors-length(listFactors) dat-gen.factorial(listFactors,center=FALSE,varNames=FactorsNames[1:numFacto rs]) desPB-optFederov(~.,dat,nRepeats=20,approximate=FALSE,nTrials=numCards) design-desPB$design#[,2:(numFactors+1)] cat(Number of trials: , fill=T, length(design[,1]), append=T) print(cor(design)) return(design) } However, it is necessary to run the function and guess numCards until the correlation matrix is diagonal and all levels are selected for the final design. Any idea how to solve this problem without an iterative function? Roberto Furlan University of Turin, Italy La mia Cartella di Posta in Arrivo è protetta con SPAMfighter 188 messaggi contenenti spam sono stati bloccati con successo. Scarica gratuitamente SPAMfighter! -- Bob Wheeler --- http://www.bobwheeler.com/ ECHIP, Inc. --- Randomness comes in bunches. __ 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
[R] R: fractional factorial design in R
Hi! thanks for your response! unfortunately, fractional factorial designs typically require all factors to have the same number of levels. Hence, your 2x3x3x5x2 example is not a simple special case of a fractional factorial design. There are some special plans for mixed level designs, but the conf.design function requires all factors to have the same number of levels, as you can also find in its help: p: The common number of levels for each factor. Must be a prime number. ffDesMatrix from package BHH2 is even worse, since it requires all factors to have 2 levels: k: numeric. The number of 2-levels design factors in the designs. I've tried both ffDesMatrix and conf.design and i realized that they cannot help me for the problem above. At the moment, I am using an SPSS function (orthoplan) for my needs. It provides factorial design with only main effects (small orthogonal designs). Since SPSS is very expensive (in particular with this add-on), I would like to use R as for all my other projects and research activity. Do you know any other way to produce these designs in R? Thanks in advance, Roberto Furlan University of Turin, Italy La mia Cartella di Posta in Arrivo è protetta con SPAMfighter 188 messaggi contenenti spam sono stati bloccati con successo. Scarica gratuitamente SPAMfighter! __ 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
[R] R: fractional factorial design in R
Yes, you're right. For, say, a 3 x 5 design, one can do this in as few as 7 runs -- but only in general by some version of one-factor-at-a-time (OFAT) designs, which are inefficient. It is easy, via, say model.matrix() to write a general function to produce these. But I think it's a bad idea; more efiicient algorithmic designs are better, IMO, which is why I suggested AlgDesign. You and others are free to disagree, of course. Hi Bert, thanks for your suggestion. However, let us say that i need a 2x2x2x3x3x3 design, which should not be too hard. I've loaded AlgDesign, and i am aware now that gen.factorial allows me to create a full desing. But how to create a main-effects-only factorial design (orthogonal)? I am still not able to produce what i need. The function model.matrix.formula is not very clear... :( Could you please indicate which syntax should i use? I'd really appreciate your help. Thanks in advance, Roberto Furlan University of Turin, Italy La mia Cartella di Posta in Arrivo è protetta con SPAMfighter 188 messaggi contenenti spam sono stati bloccati con successo. Scarica gratuitamente SPAMfighter! __ 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
Re: [R] R: fractional factorial design in R
In general, a main effects design need not be orthogonal -- the main effects merely need to be estimable. The trick is to estimate them with good efficiency, etc. I think you need to consult a local statistician for help to understand what these statistical concepts mean. In your example you could cross the 2^(3-1) with the 3^(3-1) to produce an orthogonal design to estimate main effects. But of course that's 72 runs, which I don't think you would consider small. As a previous poster commented, there are orthogonal mixed level arrays (Addleman, Kempthorne Youden -designs are a couple of phrases to try googling on) which stem from the 1960's. I doubt that, in general, they would satisfy your needs. I have not used the AlgDesign package myself. I suggest you direct questions about it to the author/maintainer, Bob Wheeler. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Monday, January 23, 2006 12:20 PM To: Berton Gunter; [EMAIL PROTECTED]; r-help@stat.math.ethz.ch Subject: [R] R: fractional factorial design in R Yes, you're right. For, say, a 3 x 5 design, one can do this in as few as 7 runs -- but only in general by some version of one-factor-at-a-time (OFAT) designs, which are inefficient. It is easy, via, say model.matrix() to write a general function to produce these. But I think it's a bad idea; more efiicient algorithmic designs are better, IMO, which is why I suggested AlgDesign. You and others are free to disagree, of course. Hi Bert, thanks for your suggestion. However, let us say that i need a 2x2x2x3x3x3 design, which should not be too hard. I've loaded AlgDesign, and i am aware now that gen.factorial allows me to create a full desing. But how to create a main-effects-only factorial design (orthogonal)? I am still not able to produce what i need. The function model.matrix.formula is not very clear... :( Could you please indicate which syntax should i use? I'd really appreciate your help. Thanks in advance, Roberto Furlan University of Turin, Italy La mia Cartella di Posta in Arrivo è protetta con SPAMfighter 188 messaggi contenenti spam sono stati bloccati con successo. Scarica gratuitamente SPAMfighter! __ 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
Re: [R] R: fractional factorial design in R
I think that there is an understandable wish to have the simple orthogonal plans (and be it only for non-experts to be able to analyse the results themselves). For mixed levels, there is e.g. the L36 that should be able to accomodate plans like 2x2x2x3x3x3. Unfortunately, R is not very strong in this arena. If I had more time, I would think about writing a package on comfortably designing experiments supported e.g. by the catalogues of Chen, J., Sun, D.X., and Wu, C.F.J. (1993). (A catalogue of two-level and three-level fractional factorial designs with small runs. International Statistical Review 61, 131-145.) Such a package should also provide the analysis facilities for any design generated with it, once it has been enriched with observed data. (This is a bit different from the typical R spirit, where users are often required to be experts themselves.) If anyone is planning a project like this or wants to make a diploma student work on it I would be interested in contributing. For the moment, if you want to implement main effects plans of the orthogonal sort (e.g. a Taguchi-plan like the L36) you have to use books or tables published on the internet, if you don't want to use expensive software like SPSS - not very comfortable, but possible. For example, you can find the L36 - which would be able to accomodate your 2x2x2x3x3x3 - in http://www.itl.nist.gov/div898/handbook/pri/section3/pri33a.htm. With kind regards, Ulrike In general, a main effects design need not be orthogonal -- the main effects merely need to be estimable. The trick is to estimate them with good efficiency, etc. I think you need to consult a local statistician for help to understand what these statistical concepts mean. In your example you could cross the 2^(3-1) with the 3^(3-1) to produce an orthogonal design to estimate main effects. But of course that's 72 runs, which I don't think you would consider small. As a previous poster commented, there are orthogonal mixed level arrays (Addleman, Kempthorne Youden -designs are a couple of phrases to try googling on) which stem from the 1960's. I doubt that, in general, they would satisfy your needs. I have not used the AlgDesign package myself. I suggest you direct questions about it to the author/maintainer, Bob Wheeler. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of statistical.model at googlemail.com Sent: Monday, January 23, 2006 12:20 PM To: Berton Gunter; statistical.model at googlemail.com; r-help at stat.math.ethz.ch Subject: [R] R: fractional factorial design in R Yes, you're right. For, say, a 3 x 5 design, one can do this in as few as 7 runs -- but only in general by some version of one-factor-at-a-time (OFAT) designs, which are inefficient. It is easy, via, say model.matrix() to write a general function to produce these. But I think it's a bad idea; more efiicient algorithmic designs are better, IMO, which is why I suggested AlgDesign. You and others are free to disagree, of course. Hi Bert, thanks for your suggestion. However, let us say that i need a 2x2x2x3x3x3 design, which should not be too hard. I've loaded AlgDesign, and i am aware now that gen.factorial allows me to create a full desing. But how to create a main-effects-only factorial design (orthogonal)? I am still not able to produce what i need. The function model.matrix.formula is not very clear... :( Could you please indicate which syntax should i use? I'd really appreciate your help. Thanks in advance, Roberto Furlan University of Turin, Italy La mia Cartella di Posta in Arrivo è protetta con SPAMfighter 188 messaggi contenenti spam sono stati bloccati con successo. Scarica gratuitamente SPAMfighter! __ 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
Re: [R] R: fractional factorial design in R
If an orthogonal main effect plan exists for the number of trials you specify, optFederov() in AlgDesign will more than likely find it for you, since such a design should be an optimal design. Ulrike Grömping wrote: I think that there is an understandable wish to have the simple orthogonal plans (and be it only for non-experts to be able to analyse the results themselves). For mixed levels, there is e.g. the L36 that should be able to accomodate plans like 2x2x2x3x3x3. Unfortunately, R is not very strong in this arena. If I had more time, I would think about writing a package on comfortably designing experiments supported e.g. by the catalogues of Chen, J., Sun, D.X., and Wu, C.F.J. (1993). (A catalogue of two-level and three-level fractional factorial designs with small runs. International Statistical Review 61, 131-145.) Such a package should also provide the analysis facilities for any design generated with it, once it has been enriched with observed data. (This is a bit different from the typical R spirit, where users are often required to be experts themselves.) If anyone is planning a project like this or wants to make a diploma student work on it I would be interested in contributing. For the moment, if you want to implement main effects plans of the orthogonal sort (e.g. a Taguchi-plan like the L36) you have to use books or tables published on the internet, if you don't want to use expensive software like SPSS - not very comfortable, but possible. For example, you can find the L36 - which would be able to accomodate your 2x2x2x3x3x3 - in http://www.itl.nist.gov/div898/handbook/pri/section3/pri33a.htm. With kind regards, Ulrike In general, a main effects design need not be orthogonal -- the main effects merely need to be estimable. The trick is to estimate them with good efficiency, etc. I think you need to consult a local statistician for help to understand what these statistical concepts mean. In your example you could cross the 2^(3-1) with the 3^(3-1) to produce an orthogonal design to estimate main effects. But of course that's 72 runs, which I don't think you would consider small. As a previous poster commented, there are orthogonal mixed level arrays (Addleman, Kempthorne Youden -designs are a couple of phrases to try googling on) which stem from the 1960's. I doubt that, in general, they would satisfy your needs. I have not used the AlgDesign package myself. I suggest you direct questions about it to the author/maintainer, Bob Wheeler. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of statistical.model at googlemail.com Sent: Monday, January 23, 2006 12:20 PM To: Berton Gunter; statistical.model at googlemail.com; r-help at stat.math.ethz.ch Subject: [R] R: fractional factorial design in R Yes, you're right. For, say, a 3 x 5 design, one can do this in as few as 7 runs -- but only in general by some version of one-factor-at-a-time (OFAT) designs, which are inefficient. It is easy, via, say model.matrix() to write a general function to produce these. But I think it's a bad idea; more efiicient algorithmic designs are better, IMO, which is why I suggested AlgDesign. You and others are free to disagree, of course. Hi Bert, thanks for your suggestion. However, let us say that i need a 2x2x2x3x3x3 design, which should not be too hard. I've loaded AlgDesign, and i am aware now that gen.factorial allows me to create a full desing. But how to create a main-effects-only factorial design (orthogonal)? I am still not able to produce what i need. The function model.matrix.formula is not very clear... :( Could you please indicate which syntax should i use? I'd really appreciate your help. Thanks in advance, Roberto Furlan University of Turin, Italy La mia Cartella di Posta in Arrivo è protetta con SPAMfighter 188 messaggi contenenti spam sono stati bloccati con successo. Scarica gratuitamente SPAMfighter! __ 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 -- Bob Wheeler --- http://www.bobwheeler.com/ ECHIP, Inc. --- Randomness comes in bunches. __ 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