similar to: Coding methods for factors

Displaying 20 results from an estimated 20000 matches similar to: "Coding methods for factors"

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 should be used? I guess it's helmert? here is an example
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
2005 Apr 23
2
ANOVA with both discreet and continuous variable
Hi all, I have dataset with 2 independent variable, one (x1) is continuous, the other (x2) is a categorical variable with 2 levels. The dependent variable (y) is continuous. When I run linear regression y~x1*x2, I found that the p value for the continuous independent variable x1 changes when different contrasts was used (helmert vs. treatment), while the p values for the categorical x2 and
2005 Jun 23
4
contrats hardcoded in aov()?
On 6/23/05, RenE J.V. Bertin <rjvbertin at gmail.com> wrote: > Hello, > > I was just having a look at the aov function source code, and see that when the model used does not have an Error term, Helmert contrasts are imposed: > > if (is.null(indError)) { > ... > } > else { > opcons <- options("contrasts") >
2005 Feb 23
1
model.matrix for a factor effect with no intercept
I was surprised by this (in R 2.0.1): > a <- ordered(-1:1) > a [1] -1 0 1 Levels: -1 < 0 < 1 > model.matrix(~ a) (Intercept) a.L a.Q 1 1 -7.071068e-01 0.4082483 2 1 -9.073800e-17 -0.8164966 3 1 7.071068e-01 0.4082483 attr(,"assign") [1] 0 1 1 attr(,"contrasts") attr(,"contrasts")$a [1]
2002 Nov 07
2
Qualitative factors
Hi, I have some doubt about how qualitative factors are coded in R. For instance, I consider a response y, a quantitative factor x and a qualitative factor m at 3 levels, generated as follow : y_c(6,4,2.3,5,3.5,4,1.,8.5,4.3,5.6,2.3,4.1,2.5,8.4,7.4) x_c(3,1,3,1,2,1,4,5,1,3,4,2,5,4,3) m_gl(3,5) lm(y~x+m) Coefficients: (Intercept) x m2 m3 3.96364 0.09818
2011 May 21
2
unbalanced anova with subsampling (Type III SS)
Hello R-users, I am trying to obtain Type III SS for an ANOVA with subsampling. My design is slightly unbalanced with either 3 or 4 subsamples per replicate. The basic aov model would be: fit <- aov(y~x+Error(subsample)) But this gives Type I SS and not Type III. But, using the drop() option: drop1(fit, test="F") I get an error message: "Error in
2008 Sep 26
1
Type I and Type III SS in anova
Hi all, I have been trying to calculate Type III SS in R for an unbalanced two-way anova. However, the Type III SS are lower for the first factor compared to type I but higher for the second factor (see below). I have the impression that Type III are always lower than Type I - is that right? And a clarification about how to fit Type III SS. Fitting model<-aov(y~a*b) in the base package and
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
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 Jun 16
1
contrasts using adonis function
Hi, Somebody knows how to make contrasts if i'm using the function adonis? Thanks.
2003 Aug 14
1
gnls - Step halving....
Hi all, I'm working with a dataset from 10 treatments, each treatment with 30 subjects, each subject measured 5 times. The plot of the dataset suggests that a 3-parameter logistic could be a reasonable function to describe the data. When I try to fit the model using gnls I got the message 'Step halving factor reduced below minimum in NLS step'. I´m using as the initial values of the
2004 Jun 23
1
nlme questions (e.g., specifying group membership, changing options)
I'm trying to better understand the nlme package and have a few questions. 1.) Other than using various coding strategies (e.g., dummy coding, effect coding), is there a way to identify group membership (i.e., treatment) directly? For example, the following code will fit a two group logistic growth curve (where 'Score' is repeatedly measured over 'Time' for each of the
2007 Jun 28
2
aov and lme differ with interaction in oats example of MASS?
Dear R-Community! The example "oats" in MASS (2nd edition, 10.3, p.309) is calculated for aov and lme without interaction term and the results are the same. But I have problems to reproduce the example aov with interaction in MASS (10.2, p.301) with lme. Here the script: library(MASS) library(nlme) options(contrasts = c("contr.treatment", "contr.poly")) # aov: Y ~
2005 Nov 24
2
type III sums of squares in R
Hi everyone, Can someone explain me how to calculate SAS type III sums of squares in R? Not that I would like to use them, I know they are problematic. I would like to know how to calculate them in order to demonstrate that strange things happen when you use them (for a course for example). I know you can use drop1(lm(), test="F") but for an lm(y~A+B+A:B), type III SSQs are only
2010 Mar 02
2
Strange behavior with poisosn and glm
Hi, I'm just learning about poison links for the glm function. One of the data sets I'm playing with has several of the variables as factors (i.e. month, group, etc.) When I call the glm function with a formula that has a factor variable, R automatically converts the variable to a series of variables with unique names and binary values. For example, with this pseudo data: y
2005 Aug 15
1
error in predict glm (new levels cause problems)
Dear R-helpers, I try to perform glm's with negative binomial distributed data. So I use the MASS library and the commands: model_1 = glm.nb(response ~ y1 + y2 + ...+ yi, data = data.frame) and predict(model_1, newdata = data.frame) So far, I think everything should be ok. But when I want to perform a glm with a subset of the data, I run into an error message as soon as I want to predict
2001 Jun 15
1
contrasts in lm and lme
I am using RW 1.2.3. on an IBM PC 300GL. Using the data bp.dat which accompanies Helen Brown and Robin Prescott 1999 Applied Mixed Models in Medicine. Statistics in Practice. John Wiley & Sons, Inc., New York, NY, USA which is also found at www.med.ed.ac.uk/phs/mixed. The data file was opened and initialized with > dat <- read.table("bp.dat") >
1999 Oct 22
1
factors in glm
Is there any logical reason why glm prints out the labels of factor levels after variable names when baseline contrasts (contr.treatment) are used but the codes for the levels when mean contrasts (contr.sum) are used? Jim -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info",
2000 Aug 01
1
Testing for parallel slopes
I'm running a series of simple bivariate linear regressions on grouped data. I want to test the slopes to see if they are parallel. I normally use analysis of covariance to do so, looking at interaction between the covariate and the factor to make this determination. VR3 pp.149 - 154 has a very nice example of an ANOCOVA, ending with a discussion of this very operation. My question has