search for: contrast

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

Did you mean: contract
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 c...
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 fac...
2005 Feb 20
1
Treatment-Contrast Interactions
Hello 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...
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 fac...
2017 Oct 22
2
Syntax for fit.contrast
I have a model (run with glm) that has a factor, type. Type has two levels, "general" and "regional". I am trying to get estimates (and SEs) for the model with type="general" and type ="regional" using fit.contrast but I can't get the syntax of the coefficients to use in fit.contrast correct. I hope someone can show me how to use fit.contrast, or some other method to get estimate with SEs. (I know I can use the variance co-variance matrix, but I would rather not have to code the linear contrast my self fr...
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 surpr...
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 so...
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 it s...
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 flummox...
2017 Oct 22
3
Syntax for fit.contrast (from package gmodels)
...", and the covariance of (intercept,"regional") which involves: var = var(intercept) + var(regional) +2*(covar(intercept,regional)), and then get the SE of the variance SE=sqrt(var) 95% CI = intercept + regional - 1.95*SE and intercept + regional + 1.95*SE. I was hoping that a contrast statement could be written that would give me the point estimate and SE for "general" and its SE and another contrast statement could be written that would give me the point estimate and SE for "general" and it SE without my having to work directly with the variance-covariance m...
2019 Feb 23
1
model.matrix.default() silently ignores bad contrasts.arg
...> Dear Martin and Ben, I agree that a warning is a good idea > (and perhaps that wasn'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...
2017 Oct 22
0
Syntax for fit.contrast
...lt;jsorkin at som.umaryland.edu> wrote: > > I have a model (run with glm) that has a factor, type. Type has two levels, "general" and "regional". I am trying to get estimates (and SEs) for the model with type="general" and type ="regional" using fit.contrast ?fit.contrast No documentation for ?fit.contrast? in specified packages and libraries: you could try ???fit.contrast? Perhaps the gmodels function of that name? > but I can't get the syntax of the coefficients to use in fit.contrast correct. I hope someone can show me how to use fit.cont...
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 funct...
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...
2017 Oct 23
2
Syntax for fit.contrast (from package gmodels)
David, Again you have my thanks!. You are correct. What I want is not technically a contrast. What I want is the estimate for "regional" and its SE. I don't mind if I get these on the log scale; I can get the anti-log. Can you suggest how I can get the point estimate and its SE for "regional"? The predict function will give the point estimate, but not (to my knowle...
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)
...e of (intercept,"regional") which involves: > var = var(intercept) + var(regional) +2*(covar(intercept,regional)), > and then get the SE of the variance > SE=sqrt(var) > 95% CI = intercept + regional - 1.95*SE and intercept + regional + 1.95*SE. > > I was hoping that a contrast statement could be written that would give me the point estimate and SE for "general" and its SE and another contrast statement could be written that would give me the point estimate and SE for "general" and it SE without my having to work directly with the variance-covariance m...
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. > &g...
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...
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)...