search for: contrasts

Displaying 20 results from an estimated 2802 matches for "contrasts".

Did you mean: contrast
2011 May 18
1
Need expert help with model.matrix
...model.matrix.default so that an alternative factor coding is used when the function is called instead of the default factor coding? Basically, I'd like to reproduce the results in 'mat' below, without having to explicitly specify my desired factor coding (identity matrices) in the 'contrasts.arg'. dd <- data.frame(a = gl(3,4), b = gl(4,1,12)) ca <- contrasts(dd$a, contrasts= FALSE) # 3 x 3 identity matrix cb <- contrasts(dd$b, contrasts= FALSE) # 4 x 4 identity matrix mat <- model.matrix(~ a + b, dd, contrasts.arg = list(a=ca, b=cb)) My approach was to modify the co...
2019 Feb 21
2
model.matrix.default() silently ignores bad contrasts.arg
Dear Ben, Perhaps I'm missing the point, but contrasts.arg is documented to be a list. From ?model.matrix: "contrasts.arg: A list, whose entries are values (numeric matrices or character strings naming functions) to be used as replacement values for the contrasts replacement function and whose names are the names of columns of data containing fact...
2005 Feb 20
1
Treatment-Contrast Interactions
...all, (Apologies in advance if my terminology is incorrect, I'm relatively new to R and statistics). I have data from a factorial design with two treatments (CRF-23), and I'm trying to compute treatment-contrast interactions through analysis of variance. I can't figure out how to do contrasts properly, despite reading the help for "C" and "contrasts" functions. (I'm actually trying to solve an exercise in a textbook: "Experimental Design" by Kirk, Ex. 9.7b). Here's what my data looks like: score <- c(12, 8,10, 6, 8, 4, 10,12, 8, 6,10...
2019 Feb 22
2
model.matrix.default() silently ignores bad contrasts.arg
>>>>> Ben Bolker >>>>> on Thu, 21 Feb 2019 08:18:51 -0500 writes: > On Thu, Feb 21, 2019 at 7:49 AM Fox, John <jfox at mcmaster.ca> wrote: >> >> Dear Ben, >> >> Perhaps I'm missing the point, but contrasts.arg is documented to be a list. From ?model.matrix: "contrasts.arg: A list, whose entries are values (numeric matrices or character strings naming functions) to be used as replacement values for the contrasts replacement function and whose names are the names of columns of data containing fact...
2017 Oct 22
2
Syntax for fit.contrast
...lf from the coefficients of the matrix) Thank you, John My model: model=glm(events~type,family=poisson(link=log),offset=log(SS),data=data) Model details: > summary(data$type) general regional 16 16 > levels(data$type) [1] "general" "regional" > contrasts(data$type) regional general 0 regional 1 I have tried the following syntax for fit.contrast fit.contrast(model,type,c(1,0)) and get an error: Error in `[[<-`(`*tmp*`, varname, value = cmat) : no such index at level 1 > fit.contrast(model,type,c(0,1),showall=TRUE...
2001 Aug 31
2
contrasts in lm
I've been playing around with contrasts in lm by specifying the contrasts argument. So, I want to specify a specific contrast to be tested Say: > y _ rnorm(100) > x _ cut(rnorm(100, mean=y, sd=0.25),c(-3,-1.5,0,1.5,3)) > reg _ lm(y ~ x, contrasts=list(x=c(1,0,0,-1))) > coef(reg)[2] x1 -1.814101 I was surpri...
2011 Oct 28
4
Contrasts with an interaction. How does one specify the dummy variables for the interaction
Forgive my resending this post. To data I have received only one response (thank you Bert Gunter), and I still do not have an answer to my question. Respectfully, John Windows XP R 2.12.1 contrast package. I am trying to understand how to create contrasts for a model that contatains an interaction. I can get contrasts to work for a model without interaction, but not after adding the interaction. Please see code below. The last two contrast statements show the problem. I would appreciate someone letting me know what is wrong with the syntax of my con...
2007 Oct 09
2
fit.contrast and interaction terms
...ng 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 it seems that when I write (contrasts=c("contr.sum", "contr....
2000 Jul 13
1
documentation for contrasts and contrasts<- (PR#607)
The documentation (in ver 1.1) for contrasts and contrasts<- does not list all the arguments for those functions. In addition to x, the factor whose contrasts are being extracted or set, contrasts() has the argument 'contrasts=TRUE', and contrasts<-() has the argument 'how.many'. It was this latter that had me flummoxe...
2017 Oct 22
3
Syntax for fit.contrast (from package gmodels)
...model: > > model=glm(events~type,family=poisson(link=log),offset=log(SS),data=data) > > > Model details: > >> summary(data$type) > > general regional > 16 16 > >> levels(data$type) > [1] "general" "regional" > >> contrasts(data$type) > regional > general 0 > regional 1 > > > I have tried the following syntax for fit.contrast > > fit.contrast(model,type,c(1,0)) > and get an error: > Error in `[[<-`(`*tmp*`, varname, value = cmat) : > no such index at level 1...
2019 Feb 23
1
model.matrix.default() silently ignores bad contrasts.arg
...'t clear in my response to Ben's > post). > Also, it would be nice to correct the omission in the help > file, which as far as I could see doesn't mention that a > contrast-generating function (as opposed to its quoted > name) can be an element of the contrasts.arg list. > Best, John Thank you John for the clarification and the reminder about filling the omission there! Prepared to go (into the sources) now. Martin >> -----Original Message----- From: Martin Maechler >> [mailto:maechler at stat.math.ethz.ch] Sent: Friday,...
2017 Oct 22
0
Syntax for fit.contrast
...> > model=glm(events~type,family=poisson(link=log),offset=log(SS),data=data) > > > Model details: > >> summary(data$type) > > general regional > 16 16 > >> levels(data$type) > [1] "general" "regional" > >> contrasts(data$type) > regional > general 0 > regional 1 > > > I have tried the following syntax for fit.contrast > > fit.contrast(model,type,c(1,0)) > and get an error: > Error in `[[<-`(`*tmp*`, varname, value = cmat) : > no such index at level...
2013 Sep 13
1
Creating dummy vars with contrasts - why does the returned identity matrix contain all levels (and not n-1 levels) ?
Hello, I have a problem with creating an identity matrix for glmnet by using the contrasts function. I have a factor with 4 levels. When I create dummy variables I think there should be n-1 variables (in this case 3) - so that the contrasts would be against the baseline level. This is also what is written in the help file for 'contrasts'. The problem is that the functi...
2007 Feb 14
1
se.contrast confusion
Hello, I've got what I'd expect to be a pretty simple issue: I fit an aov object using multiple error strata, and would like some significance tests for the contrasts I specified. In this contrived example, I model some test score as the interaction of a subject's gender and two emotion variables (angry, happy, neutral), measured at entry to the experiment (entry) and later manipulated (manip). This is a fully within-subjects design. Polynomial contrasts e...
2017 Oct 23
2
Syntax for fit.contrast (from package gmodels)
...te and SE for "general" and it SE without my having to work directly with the variance-covariance matrix. I tried doing this using the fit.contrast statements (from the gmodels package): I'm guessing that the second contrast you were hoping for was actually for "regional". Contrasts, hence the name, are for differences between two levels (or more accurately between the means on the scale specified by the link parameter. In the absence of another level the only other reference point would be a value of zero or perhaps the value you specified by your offset term. -- David &gt...
2012 Apr 23
0
Different results for sparse and dense version of model matrix using contrasts and interactions
Dear all, I've been getting different results from the sparse and dense version of model.Matrix when used with sparse contrasts and interactions between factors. The same happens when using model.matrix and sparse.model.matrix. When calculating list.contrasts I get the same results for sparse and dense contrasts (except the type of the matrix is different of course). However, when I use these contrasts to calculate a model....
2017 Oct 22
0
Syntax for fit.contrast (from package gmodels)
...te and SE for "general" and it SE without my having to work directly with the variance-covariance matrix. I tried doing this using the fit.contrast statements (from the gmodels package): I'm guessing that the second contrast you were hoping for was actually for "regional". Contrasts, hence the name, are for differences between two levels (or more accurately between the means on the scale specified by the link parameter. In the absence of another level the only other reference point would be a value of zero or perhaps the value you specified by your offset term. -- David &g...
2010 Apr 21
5
Bugs? when dealing with contrasts
...ural 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 between continuous and factor variables. The second case contrasts= was specified as an arg to lm. The second works ok if we set the contrasts through options but not if we set it through an lm argument. > &gt...
2002 May 30
0
se.contrast: matrix contrast.obj doesn't work as documented (PR#1613)
The man page for se.contrast, when describing the contrast.obj parameter, states that "Multiple contrasts should be specified by a matrix as returned by contrasts." When doing an unbalanced single factor ANOVA, using a contrast.obj as returned by contrasts results in the following error from qr.qty when se.contrast is called: Error in qr.qty(object$qr, contrast) : qr and y must have the same num...
2008 Mar 07
1
Finding Interaction and main effects contrasts for two-way ANOVA
I've tried without success to calculate interaction and main effects contrasts using R. I've found the functions C(), contrasts(), se.contrasts() and fit.contrasts() in package gmodels. Given the url for a small dataset and the two-way anova model below, I'd like to reproduce the results from appended SAS code. Thanks. --Dale. ## the dataset (from Montgomery) t...