Displaying 20 results from an estimated 7000 matches similar to: "model.matrix bug? Nested factor yields singular design matrix."
2007 May 17
1
Design matrix question
Hi useRs,
Perhaps I am having a senior moment?
I have a nested variable situation to model,
toy example:
> df <- data.frame(A = factor(c("a", "a", "x", "x"), levels = c("x", "a")),
+ B = factor(c("b", "x", "x", "x"), levels = c("x", "b")))
>
>
2007 Aug 03
4
FW: Selecting undefined column of a data frame (was [BioC] read.phenoData vs read.AnnotatedDataFrame)
Hi all,
What are current methods people use in R to identify
mis-spelled column names when selecting columns
from a data frame?
Alice Johnson recently tackled this issue
(see [BioC] posting below).
Due to a mis-spelled column name ("FileName"
instead of "Filename") which produced no warning,
Alice spent a fair amount of time tracking down
this bug. With my fumbling fingers
2007 Nov 29
1
Anova(car) SS digits
Hi,
When I use Anova(car) to produce type III SS, 'Sum Sq' is reported in
integers:
> Anova(bot.lm3, type ="III")
Anova Table (Type III tests)
Response: bottemp
Sum Sq Df F value Pr(>F)
(Intercept) 45295 1 29436.4440 < 2e-16
fungroup 3 2 0.8259 0.44006
numsp.fun 11 2
2009 May 26
1
Bug in "$<-.data.frame" yields corrupt data frame (PR#13724)
Full_Name: Steven McKinney
Version: 2.9.0
OS: Mac OS X 10.5.6
Submission from: (NULL) (142.103.207.10)
A corrupt data frame can be constructed as follows:
foo <- matrix(1:12, nrow = 3)
bar <- data.frame(foo)
bar$NewCol <- foo[foo[, 1] == 4, 4]
bar
lapply(bar, length)
> foo <- matrix(1:12, nrow = 3)
> bar <- data.frame(foo)
> bar$NewCol <- foo[foo[, 1] == 4, 4]
2009 Apr 29
1
Corrupt data frame construction - bug?
Hi useRs,
A recent coding infelicity along these lines
yielded a corrupt data frame.
foo <- matrix(1:12, nrow = 3)
bar <- data.frame(foo)
bar$NewCol <- foo[foo[, 1] == 4, 4]
bar
lapply(bar, length)
> foo <- matrix(1:12, nrow = 3)
> bar <- data.frame(foo)
> bar$NewCol <- foo[foo[, 1] == 4, 4]
> bar
X1 X2 X3 X4 NewCol
1 1 4 7 10 <NA>
2 2 5 8 11
2012 Jan 18
1
png cairo device problems on Mac 10.6.8
Hi all,
I have been having problems generating png files on a Mac running OS X 10.6.8.
Here's a simple example
> png("foo.png", type = "cairo"); plot(1:10); dev.off();
null device
1
libpng warning: Application built with libpng-1.2.26 but running with 1.5.2
The resultant file is of size 0 Kb.
Is this the proper place to report this issue? Or should
2010 Apr 21
5
Bugs? when dealing with contrasts
R version 2.10.1 (2009-12-14)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with
2002 Dec 01
1
generating contrast names
Dear R-devel list members,
I'd like to suggest a more flexible procedure for generating contrast
names. I apologise for a relatively long message -- I want my proposal to
be clear.
I've never liked the current approach. For example, the names generated by
contr.treatment paste factor to level names with no separation between the
two; contr.sum simply numbers contrasts (I recall an
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 Nov 29
4
rm() deletes 'c' if c('a','b') is the argument (PR#9399)
Full_Name: Lixin Han
Version: 2.4.0
OS: Windows 2000
Submission from: (NULL) (155.94.110.222)
A character vector c('a','b') is supplied to rm(). As a result, 'c' is deleted
unintentionally.
> a <- 1:5
> b <- 'abc'
> c <- letters
> ls()
[1] "a" "b" "c"
> rm(c('a','b'))
> ls()
character(0)
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
2007 Nov 23
4
help pleaseeeeeeeee
Dears Sirs
During my computational work I encountered unexpected behavior when calling
"ar" function, namely
# time series
x<-ts(c(-0.2052083,-0.3764986,-0.3762448,0.3740089,0.2737568,2.8235722,-
1.7783313,0.2728676,-0.3273164),start=c(1978,3),frequency=4,end=c(1980,3))
# ar function
res.ar<-ar(x,aic=TRUE,demean=F)
# call "ar" again and ............
2012 Oct 27
1
contr.sum() and contrast names
Hi!
I would like to suggest to make it possible, in one way or another, to
get meaningful contrast names when using contr.sum(). Currently, when
using contr.treatment(), one gets factor levels as contrast names; but
when using contr.sum(), contrasts are merely numbered, which is not
practical and can lead to mistakes (see code at the end of this
message).
This issue was discussed quickly in 2005
2011 May 18
1
Need expert help with model.matrix
Dear experts:
Is it possible to create a new function based
on stats:::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
1999 May 05
1
Ordered factors , was: surrogate poisson models
For ordered factor the natural contrast coding would be to parametrize by
the succsessive differences between levels, which does not assume equal
spacing
of factor levels as does the polynomial contrasts (implicitly at least).
This requires the contr.cum, which could be:
contr.cum <- function (n, contrasts = TRUE)
{
if (is.numeric(n) && length(n) == 1)
levs <- 1:n
2007 Oct 09
2
fit.contrast and interaction terms
Dear R-users,
I want to fit a linear model with Y as response variable and 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
2024 Sep 20
1
model.matrix() may be misleading for "lme" models
Dear r-devel list members,
I'm posting this message here because it concerns the nlme package,
which is maintained by R-core. The problem I'm about to describe is
somewhere between a bug and a feature request, and so I thought it a
good idea to ask here rather posting a bug report to the R bugzilla.
I was made aware (by Ben Bolker) that the car::Anova() method for "lme"
2009 Sep 17
2
What does model.matrix() return?
Hi,
I don't understand what the meaning of the following lines returned by
model.matrix(). Can somebody help me understand it? What can they be
used for?
attr(,"assign")
[1] 0 1 2 2
attr(,"contrasts")
attr(,"contrasts")$A
[1] "contr.treatment"
attr(,"contrasts")$B
[1] "contr.treatment"
Regards,
Peng
> a=2
> b=3
> n=4
2008 May 20
1
contr.treatments query
Hi Folks,
I'm a bit puzzled by the following (example):
N<-factor(sample(c(1,2,3),1000,replace=TRUE))
unique(N)
# [1] 3 2 1
# Levels: 1 2 3
So far so good. Now:
contrasts(N)<-contr.treatment(3, base=1, contrasts=FALSE)
contrasts(N)
# 1 2
# 1 1 0
# 2 0 1
# 3 0 0
whereas:
contr.treatment(3, base=1, contrasts=FALSE)
# 1 2 3
# 1 1 0 0
# 2 0 1 0
# 3 0 0 1
contr.treatment(3, base=1,
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