similar to: Understanding custom contrasts

Displaying 20 results from an estimated 5000 matches similar to: "Understanding custom contrasts"

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
2004 May 03
1
Setting up contrasts
I am using the following model: lm <- lm(mydata[[variableName]] ~ Age + Gender + Group, data=mydata) There are 5 groups in "Group": nonc (the control), c1,c2,c3 and c4. How do I contrast nonc vs the others? and How do I contrast c1 vs other c's (ie c2,c3,c4 as a subgroup)? I have looked at the contrasts option in lm and model.matrix and am really none the wiser. Though it
2011 Aug 03
1
Coefficient names when using lm() with contrasts
Dear R Users, Am using lm() with contrasts as below. If I skip the contrasts() statement, I get the coefficient names to be > names(results$coef) [1] "(Intercept)" "VarAcat" "VarArat" "VarB" which are much more meaningful than ones based on integers. Can anyone tell me how to get R to keep the coefficient names based on the factor levels
2006 Aug 16
0
confusing about contrasts concept [long]
Tian It appears the attachment might not have worked so I'll embed Bill's message at the end. Peter Alspach > -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Peter Alspach > Sent: Thursday, 17 August 2006 8:02 a.m. > To: T Mu; R-Help > Subject: Re: [R] confusing about contrasts concept
2010 Sep 29
1
Understanding linear contrasts in Anova using R
#I am trying to understand how R fits models for contrasts in a #simple one-way anova. This is an example, I am not stupid enough to want #to simultaneously apply all of these contrasts to real data. With a few #exceptions, the tests that I would compute by hand (or by other software) #will give the same t or F statistics. It is the contrast estimates that R produces #that I can't seem to
2007 Jul 06
1
maintaining specified factor contrasts when subsetting in lmer
All, I'm using lmer for some repeated measures data and have specified the contrasts for a time factor such that say time 3 is the base. This works fine. However, when I next use the subset argument to remove the last two time values, the output indicates that the specified contrast is not maintained (see below). I can solve this by creating a new dataframe for the subset of interest
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
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 =
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
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
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.
2008 Sep 09
1
puzzle about contrasts
Hi, I'm trying to redefine the contrasts for a linear model. With a 2 level factor, x, with levels A and B, a two level factor outputs A and B - A from an lm fit, say lm(y ~ x). I would like to set the contrasts so that the coefficients output are -0.5 (A + B) and B - A, but I can't get the sign correct for the first coefficient (Intercept). Here is a toy example, set.seed(12161952) y
2011 Sep 29
1
F and Wald chi-square tests in mixed-effects models
I have a doubt about the calculation of tests for fixed effects in mixed-effects models. I have read that, except in well-balanced designs, the F statistic that is usually calculated for ANOVA tables may be far from being distributed as an exact F distribution, and that's the reason why the anova method on "mer" objects (calculated by lmer) do not calculate the denominator df nor a
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
2002 Jan 26
1
Trouble with contrasts
Greetings, I have a nagging problem with contrasts and I can't seem to resolve it. A factor exists with four levels (lib1, lib2, con1, con2) and when I check the contrasts or set the contrasts to any of the prespecified ones, I do not get the exact contrasts necessary to test the theoretically relevant ones. I need orthogonal contrasts that look just like this matrix: con1 con2
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
2006 Dec 14
2
Asymmetrical ANOVA / contrasts
Dear all, I have problems to code contrasts for performing an asymmetrical anova with aov(). I am using aov() because I want to get the Mean Squares for further analyses. I didn't find any solution to my problem in the help files of functions aov(), contrasts(), C(), etc. Let's say I have three locations, one with treatment P, and two with treatment C: >
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) twoway <-
2010 Aug 29
2
glm prb (Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") : )
glm(A~B+C+D+E+F,family = binomial(link = "logit"),data=tre,na.action=na.omit) Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") : contrasts can be applied only to factors with 2 or more levels however, glm(A~B+C+D+E,family = binomial(link = "logit"),data=tre,na.action=na.omit) runs fine glm(A~B+C+D+F,family = binomial(link =
2007 Oct 11
2
Type III sum of squares and appropriate contrasts
I am running a two-way anova with Type III sums of squares and would like to be able to understand what the different SS mean when I use different contrasts, e.g. treatment contrasts vs helmert contrasts. I have read John Fox's "An R and S-Plus Companion to Applied Regression" approach -p. 140- suggesting that treatment contrasts do not usually result in meaningful results with Type