search for: contr

Displaying 20 results from an estimated 623 matches for "contr".

Did you mean: cont
2002 Dec 01
1
generating contrast names
Dear R-devel list members, I'd like to suggest a more flexible procedure for generating contrast names. I apologise for a relatively long message -- I want my proposal to be clear. I've never liked the current approach. For example, the names generated by contr.treatment paste factor to level names with no separation between the two; contr.sum simply numbers contrasts (I recall an...
2010 Apr 21
5
Bugs? when dealing with contrasts
...07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Below are two cases where I don't seem to be getting contr.sum contrasts even though they were specified. Are these bugs? The first case is an interaction betwee...
2012 Oct 27
1
contr.sum() and contrast names
Hi! I would like to suggest to make it possible, in one way or another, to get meaningful contrast names when using contr.sum(). Currently, when using contr.treatment(), one gets factor levels as contrast names; but when using contr.sum(), contrasts are merely numbered, which is not practical and can lead to mistakes (see code at the end of this message). This issue was discussed quickly in...
2005 Apr 13
2
multinom and contrasts
Hi, I found that using different contrasts (e.g. contr.helmert vs. contr.treatment) will generate different fitted probabilities from multinomial logistic regression using multinom(); while the fitted probabilities from binary logistic regression seem to be the same. Why is that? and for multinomial logisitc regression, what contrast sh...
2011 May 11
1
Help with contrasts
Hi, I need to build a function to generate one column for each level of a factor in the model matrix created on an arbitrary formula (instead of using the available contrasts options such as contr.treatment, contr.SAS, etc). My approach to this was first to use the built-in function for contr.treatment but changing the default value of the contrasts argument to FALSE (I named this function "contr.identity" and it shown at the bottom of the email for refer...
2010 Jul 07
6
forcing a zero level in contr.sum
I need to use contr.sum and observe that some levels are not statistically different from the overall mean of zero. What is the proper way of forcing the zero estimate? It seems the column corresponding to that level should become a column of zeros. Is there a way to achieve that without me constructing the design mat...
2007 Oct 09
2
fit.contrast and interaction terms
...X a categorical variable (with 4 categories), with the aim of comparing the basal category of X (category=1) with category 4. Unfortunately, there is another categorical variable with 2 categories which interact with x and I have to include it, so my model is s "reg3: Y=x*x3". Using fit.contrast to make the contrast (category 1 vs category 4) with options(contrasts=c("contr.treatment", "contr.poly")), it makes the contrast but just for the basal category of x3, (coincident with the corresponding result of summary(reg3)), so that it is not what I am looking for, and i...
2011 Feb 03
3
interpret significance from the contr.poly() function
Hello R-help I don’t know how to interpret significance from the contr.poly() function . From the example below : how can I tell if data has a significant Linear/quadratic/cubic trend? > contr.poly(4, c(1,2,4,8))               .L         .Q          .C [1,] -0.51287764  0.5296271 -0.45436947 [2,] -0.32637668 -0.1059254  0.79514657 [3,]  0.04662524 -0.7679594 -0.39...
1999 May 05
1
Ordered factors , was: surrogate poisson models
For ordered factor the natural contrast coding would be to parametrize by the succsessive differences between levels, which does not assume equal spacing of factor levels as does the polynomial contrasts (implicitly at least). This requires the contr.cum, which could be: contr.cum <- function (n, contrasts = TRUE) { if (is.n...
2008 Oct 11
2
R vs SPSS contrasts
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 SP...
2009 Nov 08
2
reference on contr.helmert and typo on its help page.
I'm wondering which textbook discussed the various contrast matrices mentioned in the help page of 'contr.helmert'. Could somebody let me know? BTW, in R version 2.9.1, there is a typo on the help page of 'contr.helmert' ('cont.helmert' should be 'contr.helmert').
2005 Jul 13
1
Name for factor's levels with contr.sum
Good morning, I used in R contr.sum for the contrast in a lme model: > options(contrasts=c("contr.sum","contr.poly")) > Septo5.lme<-lme(Septo~Variete+DateSemi,Data4.Iso,random=~1|LieuDit) > intervals(Septo5.lme)$fixed lower est. upper (Intercept) 17.0644033 23.106110 29.147816 Variete1 9.5819873 1...
2007 May 17
1
model.matrix bug? Nested factor yields singular design matrix.
...2 a x 3 x x 4 x x So of course the full design matrix is singular, this is expected. > model.matrix(~ A * B, df) (Intercept) Aa Bb Aa:Bb 1 1 1 1 1 2 1 1 0 0 3 1 0 0 0 4 1 0 0 0 attr(,"assign") [1] 0 1 2 3 attr(,"contrasts") attr(,"contrasts")$A [1] "contr.treatment" attr(,"contrasts")$B [1] "contr.treatment" I'd like to drop the B main effect column, but get the unexpected result of a column of zeroes. > model.matrix(~ A * B - B, df) (Intercept) Aa Ax:Bb A...
2003 Feb 14
5
Translating lm.object to SQL, C, etc function
This is my first post to this list so I suppose a quick intro is in order. I've been using SPLUS 2000 and R1.6.2 for just a couple of days, and love S already. I'm reading MASS and also John Fox's book - both have been very useful. My background in stat software was mainly SPSS (which I've never much liked - thanks heavens I've found S!), and Perl is my tool of choice for
2012 May 07
1
Repeating
...a. I want to repeat this process 999 times. However, i am getting an error when i use the "for i in" function. Is there any way to repeat this analysis 999 times. Here are the codes i used ; data4 <- matrix(c(sample(id),data1),203,3) a <- data4[,1] random.case=data4[a==0,] random.contr=data4[a==1,] random.case.locations<-list(x=random.case[,1],y=random.case[,2]) ppregion(xl=min(random.case[,1])-0.0001,xu=max(random.case[,1])+0.0001,yl=min(random.case[,2])-0.0001,yu=max(random.case[,2])+0.0001) random.l.case <- Kfn(random.case.locations,0.01) random.k.case <- ((random.l...
2008 May 20
1
contr.treatments query
Hi Folks, I'm a bit puzzled by the following (example): N<-factor(sample(c(1,2,3),1000,replace=TRUE)) unique(N) # [1] 3 2 1 # Levels: 1 2 3 So far so good. Now: contrasts(N)<-contr.treatment(3, base=1, contrasts=FALSE) contrasts(N) # 1 2 # 1 1 0 # 2 0 1 # 3 0 0 whereas: contr.treatment(3, base=1, contrasts=FALSE) # 1 2 3 # 1 1 0 0 # 2 0 1 0 # 3 0 0 1 contr.treatment(3, base=1, contrasts=TRUE) # 2 3 # 1 0 0 # 2 1 0 # 3 0 1 I can follow the last two f...
2001 Jun 15
1
contrasts in lm and lme
...t,dbp,dbp1) > sapply(dat1,data.class) Patient Visit Center Treatment dbp dbp1 "factor" "factor" "factor" "factor" "numeric" "numeric" After which the following code was run > library(nlme) # needed for the contrast contr.SAS > options(contrasts=c(factor="contr.SAS",ordered="contr.poly")) > res <- lm(dbp~Treatment+Visit+dbp1) > anova(res) > summary(res) and was repeated leaving out library(nlme) and replacing > options(contrasts=c(factor="contr.SAS",ordered=...
2010 Sep 23
2
Contraste polinomial con dos factores con niveles no equidistantes
...2, 0.5, 1 y mi variable de respuesta es continua, todo dentro del set de datos llamado "datos". Mi asesor de tesis me recomienda que en vez de aplicar una anova de dos factores, que mejor aproveche que los factores A y B son continuos en vez de categóricos, y que mejor aplique un contraste polinomial para analizar los datos. Como se habrán dado cuenta, los niveles de los factores no son equidistantes, condición que según entiendo es necesaria para poder codificar los mismos con la función "contr.poly". Investigando por la red encontré que existe una forma de co...
2005 Aug 29
1
lme and ordering of terms
Dear R users, When fitting a lme() object (from the nlme library), is it possible to test interactions *before* main effects? As I understand, R conventionally re-orders all terms such that highest-order interactions come last - but I??d like to know if it??s possible (and sensible) to change this ordering of terms. I??ve tried the terms() command (from aov) but I don??t know if something
2012 Oct 05
1
Setting the desired reference category with contr.sum
Hi, I have 6 career types, represented as a factor in R, coded from 1 to 6. I need to use the effect coding (also known as deviation coding) which is normally done by contr.sum, e.g. contrasts(career) <- contr.sum(6) However, this results in the 6th category being the reference, that is being coded as -1: $contrasts [,1] [,2] [,3] [,4] [,5] 1 1 0 0 0 0 2 0 1 0 0 0 3 0 0 1 0 0 4 0 0 0 1 0 5 0 0...