similar to: contrasts in lm~-1+(numeric.variable)/(factor) (PR#2037)

Displaying 20 results from an estimated 3000 matches similar to: "contrasts in lm~-1+(numeric.variable)/(factor) (PR#2037)"

2011 Jul 21
0
gls yields much smaller std. errors with different base for contrasts
Dear List, After running a compound symmetric model using gls, I realized that the default contrasts were not the ones that made the most sense given the biological relationships among the factor levels. When I either changed the factor levels to re-arrange the order they occur in the gls model (not shown below) OR specifically change the contrasts I get the exact same estimates for the
2009 Oct 27
0
anova interaction contrasts: crossing helmert and linear contrasts
I am new to statistics, R, and this list, so apologies in advance for the errors etiquette I am certain to make (in spite of reading the posting guide, help on various commands, etc.). ?Any help is greatly appreciated. Here is my data: fatigue = c(3,2,2,3,2,3,4,3,2,4,5,3,3,2,4,5,4,5,5,6,4,6,9,8,4,3,5,5,6,6,6,7,9,10,12,9) n <- 3 train <- gl(3, 4*n, labels=c("6wks",
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 flummoxed, because I wanted to reparametrize a model by
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
2019 Feb 21
0
model.matrix.default() silently ignores bad contrasts.arg
An lme4 user pointed out <https://github.com/lme4/lme4/issues/491> that passing contrasts as a string or symbol to [g]lmer (which would work if we were using `contrasts<-` to set contrasts on a factor variable) is *silently ignored*. This goes back to model.matrix(), and seems bad (this is a very easy mistake to make, because of the multitude of ways to specify contrasts for factors in R
2008 Apr 17
0
linear contrasts in coxph?
Hello everyone, I was trying to calculate linear contrasts with coxph via the contrasts function, but I'm not sure if it is correct. First, all the statistics change, if I state 2 contrasts instead of 3. Second, stipulating common linear contrasts does not even nearly produce an expected result (i.e. -1,1,0,0 should lead to nonsignificatn result, as group A and B are not differing very much)
2019 Feb 21
0
model.matrix.default() silently ignores bad contrasts.arg
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
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
2011 Oct 21
1
droplevels: drops contrasts as well
Dear all, Today I figured out that there is a neat function called droplevels, which, well, drops unused levels in a data frame. I tried the function with some of my data sets and it turned out that not only the unused levels were dropped but also the contrasts I set via "C". I had a look into the code, and this behaviour arises from the fact that droplevels uses simply factor to drop
2019 Feb 22
0
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 > -----Original
2006 Aug 17
1
Setting contrasts for polr() to get same result of SAS
Hi all, I am trying to do a ordered probit regression using polr(), replicating a result from SAS. >polr(y ~ x, dat, method='probit') suppose the model is y ~ x, where y is a factor with 3 levels and x is a factor with 5 levels, To get coefficients, SAS by default use the last level as reference, R by default use the first level (correct me if I was wrong), The result I got is a
2009 Nov 14
1
setting contrasts for a logistic regression
Hi everyone, I'm doing a logistic regression with an ordinal variable. I'd like to set the contrasts on the ordinal variable. However, when I set the contrasts, they work for ordinary linear regression (lm), but not logistic regression (lrm): ddist = datadist(bin.time, exp.loc) options(datadist='ddist') contrasts(exp.loc) = contr.treatment(3, base = 3, contrasts = TRUE) lrm.loc =
2004 Mar 03
1
Confusion about coxph and Helmert contrasts
Hi, perhaps this is a stupid question, but i need some help about Helmert contrasts in the Cox model. I have a survival data frame with an unordered factor `group' with levels 0 ... 5. Calculating the Cox model with Helmert contrasts, i expected that the first coefficient would be the same as if i had used treatment contrasts, but this is not true. I this a error in reasoning, or is it
2008 Apr 29
0
Looking for Post-hoc tests (a la TukeyHSD) or interaction-level independent contrasts for survival analysis.
Hello all R-helpers, I've performed an experiment to test for differential effects of elevated temperatures on three different groups of corals. I'm currently performing a cox proportional hazards regression with censoring on the survivorship (days to mortality) of each individual in the experiment with two factors: Temperature Treatment (2 levels: ambient and elevated) and
2012 May 11
1
set specific contrasts using lapply
I have the following data set > data A B X1 X2 Y 1 A1 B1 1.1 2.9 1.2 2 A1 B2 1.0 3.2 2.3 3 A2 B1 1.0 3.3 1.6 4 A2 B2 0.5 2.6 3.1 > sapply(data, class) A B X1 X2 Y "factor" "factor" "numeric" "numeric" "numeric" I'd like to set a specific type of contrasts to all the categorical factors
1997 Dec 04
1
R-alpha: model.matrix(.) does not allow `contrasts' ..
and this breaks multinom from the nnet library [yes, Kurt, I'm working on that and I'll send you patches..] Is this a bug or an (half-)intentional difference to S ? --------------------- In R (0.50-0.60) model.matrix(formula =, data =) Arguments: formula: A model formula or terms object data: A data frame created with `model.frame' In S-plus USAGE:
2004 Apr 20
0
strange result with contrasts
Hello, I'm trying to reproduce some SAS result wit R (after I got suspicious with the result in R). I struggle with the contrasts in a linear model. I've got three factors > d$dose <- as.factor(d$dose) # 5 levels > d$time <- as.factor(d$time) # 2 levels > d$batch <- as.factor(d$batch) # 3 levels the data frame d contains 82 rows. There are 2 to 4 replicates of
2010 Oct 15
1
creating 'all' sum contrasts
OK, my last question didn't get any replies so I am going to try and ask a different way. When I generate contrasts with contr.sum() for a 3 level categorical variable I get the 2 orthogonal contrasts: > contr.sum( c(1,2,3) ) [,1] [,2] 1 1 0 2 0 1 3 -1 -1 This provides the contrasts <1-3> and <2-3> as expected. But I also want it to create <1-2> (i.e.
2007 Sep 15
1
Cannot get contrasts to work with aov.
I have been trying for hours now to perform an orthogonal contrast through an ANOVA in R. I have done a two-factor factorial experiment, each factor having three levels. I converted this dataset to a dataframe with one factor with nine treatments, as I couldn't work out what else to do. I have set up a matrix with the eight orthogonal contrasts that I wish to perform, but despite
2012 May 06
1
Understanding custom contrasts
I have a question regarding customising contrasts for linear models I read the section in Fox/Weisberg's CAR (2nd ed.) and was thinking--apparently erroneously--that the following two snippets would do the same: # approach 1: default treatment contrasts # generate data set.seed(1111) y <- c(rnorm(1000, -1), rnorm(1000, 0), rnorm(1000, 1)) x <- factor(rep(letters[1:3], each=1000)) #