Displaying 20 results from an estimated 40000 matches similar to: "integer codes of factors"
2005 Nov 30
1
How to solve allocation problem in lme() analysis?
Hello!
I am running analysis on the data from 4 experiments, with approximately
4600 rows (cases). My working model is:
fitA1 = lme(RT~F1+F2+L,random=~1|Experiment/Subject,data=data)
Model works very fine, but if I try to check whether the effect of L
depends on Experiments/Subjects with:
fitA2 = lme(RT~F1+F2+L,random=~1+L|Experiment/Subject,data=data)
[with the idea to make: anova(fitA1,fitA2)]
2009 Oct 07
2
Plotting 1 covariate, 3 factors
I'm interested in plotting a y with an x factor as the combination of 2
factors and colour with respect to a third, which the code below does with
interaction.plot(). However, this is because I redefine the x to be 1
factor. Is there a way of getting it to plot without redefining it, and
ideally to not join up the lines BETWEEN levels a and b, but just join those
between after and before for
2009 Sep 04
3
Using anova(f1, f2) to compare lmer models yields seemingly erroneous Chisq = 0, p = 1
Hello,
I am using R to analyze a large multilevel data set, using
lmer() to model my data, and using anova() to compare the fit of various
models. When I run two models, the output of each model is generated
correctly as far as I can tell (e.g. summary(f1) and summary(f2) for the
multilevel model output look perfectly reasonable), and in this case (see
below) predictor.1 explains vastly more
2005 Feb 27
2
Help with constrained optimization
Dear all,
I need an advice in the following problem.
I have to maximize two functions of the form f1(x)=f(y1,x,alpha1,beta1) and f2(x)=(y2,x,alpha2,beta2), the maximization is with respect to alpha1, alpha2, beta1, beta2. I can maximize each function separately using nlm.
The problem is that I have to add the constraint of the form g(alpha1)=g(alpha2).
The total number of parameters is
2013 Oct 12
2
Order of factors with facets in ggplot2
Hello,
I'd like to produce a ggplot where the order of factors within facets is
based on the average of another variable.
Here's a reproducible example. My problem is that the factors are ordered
similarly in both facets. I would like to have, within each facet of `f1',
boxplots for 'x' within each factor `f2', where the boxplots are ordered
based on the average of x
2006 Nov 10
1
Combining factors
Hi
I know this is a basic question and I know I have done it before but I
can't find the answer any more.
I have a data set, say:
F1, F2, Value
F1 and F2 are Factors.
I would like to plot
plot(TheCombinationOf(F1, F2), Value)
I remember there was a function for TheCombinationOf() but I don't
remember the name.
I could create a new factor based on F1 and F2, but I would prefer the
2008 Nov 21
2
Basic question on concatenating factors
Hi all,
I hope it's not too trivial for the list - I'm trying to concatenate
two factor arrays, and obtain the following:
> f1<-factor(c("a","a","b"))
> f1
[1] a a b
Levels: a b
> f2<-factor(c("b","b","a"))
> f2
[1] b b a
Levels: a b
> c(f1,f2)
[1] 1 1 2 2 2 1
Instead of getting:
[1] a a b b b a
Levels: a
2003 Dec 08
1
aggregate and names of factors
Hello,
I use the function 'aggregate' a lot.
One small annoyance is that it is necessary to name the factors in the
'by' list to get the names in the resulting data.frame (else, they
appear as Group.1, Group.2...etc). For example, I am forced to
write:
aggregate(y,list(f1=f1,f2=f2),mean)
instead of aggregate(y,list(f1,f2),mean)
(for two factors with short names, it is not such
2009 Sep 16
3
apply function across two variables by mult factors
Greetings,
I am attempting to run a function, which produces a vector and
requires two input variables, across two nested factor levels. I can
do this using by(X, list(factor1, factor2), function), however I
haven't found a simple way to extract the list output into an
organized vector form. I can do this using nested loops but it isn't
exactly an optimal approach.
Thank you
1999 Mar 11
1
: for factors (PR#139)
The following example from the help page does not work:
> f1_ gl(2,3); f1
> f2_ gl(3,2); f2
> f1:f2 # a factor, the ``cross'' f1 x f2
yields
Warning in f1:f2 : Numerical expression has 6 elements: only the first used
[1] 1
whereas R-0.61.2 yields
> f1:f2 # a factor, the ``cross'' f1 x f2
[1] 1:1 1:1 1:2 2:2 2:3 2:3
Note that the new behavior is consistent with
2007 Feb 14
1
predict.lm point forecasts with factors
hello,
I am trying to use predict.lm to make point forecasts based on a model with
continuous and categorical independent variables
I have no problems fitting the model using lm, but when I try to use predict
to make point predictions. it reverts back to the original dataframe and
gives me the point predictions for the fitted data rather than for the new
data, I imagine that I am missing
2012 Nov 19
2
Performing gage R&R study in R w/more than 2 factors
Hi everyone,
I'm fairly new to R, and I don't have a background in statistics, so
please bear with me. ;-)
I'm dealing with 2^k factorial designs, and I was just wondering if
there's any way to analyze more than two factors of a gage R&R study in
R. For example, Minitab has an "expanded gage R&R" function that lets
you include up to eight additional factors
2009 Sep 19
2
Counting observations of a combined factor
#I have a dataset with two factor. I want to combine those factors into
a single factor and count the number of data values for each new factor.
The following gives a comparable dataframe:
a <- rep(c("a", "b"), c(6,6))
b <- rep(c("c", "d"), c(6,6))
df <- data.frame(f1=a, f2=b, d=rnorm(12))
df
# I use the 'interaction' function to combine
2005 Aug 23
1
how to (combine / recode / merge) two factor.
Hi,
I have a data frame with two factors, and I would like to create a new
one by "combining" them.
I have already a solution, but it is very "heavy", and I'm sure there is
a basic function which can do the same.
I tried to find it in the R-help, but without result.
See the example :
# just to create a dataframe
f1 <- factor(rep(c("A","B"),3))
f2
2009 Jun 20
1
how to apply the dummy coding rule in a dataframe with complete factor levels to another dataframe with incomplete factor levels?
Dear R helpers:
Sorry to bother for a basic question about model.matrix.
Basically, I want to apply the dummy coding rule in a dataframe with
complete factor levels to another dataframe with incomplete factor levels.
I used model.matrix, but could not get what I want.
The following is an example.
#Suppose I have two dataframe A and B
2006 Aug 16
1
Specifying Path Model in SEM for CFA
I'm using specify.model for the sem package. I can't figure out how to
represent the residual errors for the observed variables for a CFA
model. (Once I get this working I need to add some further constraints.)
Here is what I've tried:
model.sa <- specify.model()
F1 -> X1,l11, NA
F1 -> X2,l21, NA
F1 -> X3,l31, NA
F1 -> X4,l41, NA
F1 -> X5, NA, 0.20
2008 Aug 28
1
drop.unused.levels for two factors {lattice}
Hi,
Is there any way to suppress plotting of panels that don't actually contain
any information? I have tried using 'drop.unused.levels=TRUE', but there
doesn't seem to be any effect. Here is an example:
library(lattice)
# some fake data:
d <- data.frame(x=runif(20), x.class=rep(letters[1:5], each=4),
f1=rep(letters[1:2], each=10), f2=rep(letters[10:19], each=2) )
# plot
2003 Apr 23
1
Comparing formulas
Dear All,
I want to compare formulas resulting from using stepAIC() on glm() objects.
I have 2 different formulas, say F1 and F2, which consist of about 10
factors (Y~A+B+C+...) but one has an interaction term (A:B) while the other
doesn't. But when I perform F1==F2 it comes back as TRUE. Is there a proper
way to compare formulas?
-------------------------------------------
Jeffrey M
2008 Apr 18
3
Function redefinition - not urgent, but I am curious
This is just my curiousity working.
Suppose I write:
f1 <- function(x) x + 1
f2 <- function(x) 2 * f1(x)
f2(10)
# 22
f1 <- function(x) x - 1
f2(10)
# 18
This is quite obvious. But is there any way to define f2
in such a way that we "freeze" the definition of f1?
f1 <- function(x) x + 1
f2 <- function(x)
# put something here
2 * f1(x)
# probably put something else here
2007 Jul 12
1
sub-function default arguments
Hi.
I have defined a function, f1, that calls another function, f2. Inside f1
an intermediate variable called nm1 is created; it is a matrix. f2 takes a
matrix argument, and I defined f2 (schematically) as follows:
f2<-function(nmArg1=nm1,...){nC<-ncol(nmArg1); ... }
so that it expects nm1 as the default value of its argument. f1 is defined
(schematically) as: