Displaying 20 results from an estimated 20000 matches similar to: "releveling a numeric by factor interaction in a lm"
2010 Aug 03
1
releveling a numeric by factor interaction
Can anyone help me with the necessary code to relevel a numeric*factor
interaction term in a linear model? I would like to report the estimate,
std. error and t-value for the reference factor.
First, I estimated a linear model with dummy variables and was able to
retrieve model estimates for the reference factor using relevel.
for example:
> summary(update(mod.mod, . ~ . - dummy +
+
2018 Oct 02
1
Relevel confusing with numeric value
Something that bit me:
The function relevel takes a factor, and a reference level to be promoted to the first place.
If ?ref? is a character this level is promoted, if it?s a numeric the ?ref?-th level is promoted.
Which turns out to be very confusing if you have factor with numeric values (e.g. when reading in a csv with some dirty numeric columns and stringsAsFactors TRUE)
For example:
2010 Apr 12
2
Interpreting factor*numeric interaction coefficients
Dear all,
I am a relative novice with R, so please forgive any terrible errors...
I am working with a GLM that describes a response variable as a function of
a categorical variable with three levels and a continuous variable. These
two predictor variables are believed to interact.
An example of such a model follows at the bottom of this message, but here
is a section of its summary table:
2012 Jan 16
2
Relevel dynamically
Dear list,
I am running R code which produces a data.frame with variable rows. For
plotting purposes I need to relevel
the column called "names" but since the dimension of the data.frame can vary
I do not know how to dynamically
revel the data.frame.
Here is an example data.frame called df to illustrate what I try to achieve:
> df <-
2004 Dec 22
0
relevel expansion suggestion
To the R developers,
The discussion below reminded me that I think it might be a good idea
to take the Relevel function from the Lexis package and replace relevel
in stats with it. This is really nothing special for epidemiology.
It is fully compatible with the existing relevel (it actually contains
the
relevel code almost verbatim as a subset), but it has the extra
functionality
of combining
2006 Dec 15
1
Switching labels on a factor
Hi All,
I'm perplexed by the way the unclass function displays a factor whose
labels have been swapped with the relevel function. I realize it won't
affect any results and that the relevel did nothing useful in this
particular case. I'm just doing it to learn ways to manipulate factors.
The display of unclass leaves me feeling that the relevel had failed.
I've checked three books
2009 Jan 09
2
recursive relevel
Dear list,
I'm having second thoughts after solving a very trivial problem: I
want to extend the relevel() function to reorder an arbitrary number
of levels of a factor in one go. I could not find a trivial way of
using the code obtained by getS3method("relevel","factor"). Instead, I
thought of solving the problem in a recursive manner (possibly after
reading
2007 Aug 07
2
Interaction factor and numeric variable versus separate regressions
Dear list members,
I have problems to interpret the coefficients from a lm model involving
the interaction of a numeric and factor variable compared to separate lm
models for each level of the factor variable.
## data:
y1 <- rnorm(20) + 6.8
y2 <- rnorm(20) + (1:20*1.7 + 1)
y3 <- rnorm(20) + (1:20*6.7 + 3.7)
y <- c(y1,y2,y3)
x <- rep(1:20,3)
f <- gl(3,20,
2017 Oct 28
2
HELP relevel INTERCEPT-COMPARISONS
Dear colleagues,
How can I do to "relevel" the intercept?
I need that the treatment "Db" be the intercept, and have p-values for the comparisons with the others treatments.
I used the function "relevel" but it did not work out to have what I want.
Thanks for your help,
Xavier
T1 <- read.table(file.choose(), h=T)
> head(T1)
treatment replicate Time
2012 Oct 24
1
randomly select another observation with same grouping factor and year value, do for every record in dataframe
Hello,
I am trying to create a function that will move through each record of a data frame, find the value in the "HUC" column, then
randomly select another observation from the dataframe with the same value in "HUC" column, as well as the same value in "Yr" column as the first observation. I want the function to produce a list of the RchID of the first observation,
2008 Oct 29
0
reporting interactions of factors in linear mixed effects models
Hi,
I have a question about how I should report the results for a linear
mixed effects model where the model includes as predictors three
factors (facA, facB and facC), one of which (facA) interacts with the
other two. facA and facB have two levels and facC has 3 levels. There
are also several other continuous predictors (e.g. varA, varB, varC).
My mixed model is specified with the following
2018 May 08
0
Fitting problem for Cox model with Strata as interaction term
Dear All,
I got a warning message "X matrix deemed to be singular" in Cox model with
a time dependent coefficient. In my analysis, the variable "SEX" is a
categorical variable which violate the PH assumption in Cox. I first used
the survSplit() function to break the data set into different time
intervals, and then fit the model. The procedures can be described as
follows:
2012 Feb 03
1
ordering of factor levels in regression changes result
I was surprised to find that just changing the base level of a factor variable changed the number of significant coefficients in the solution.
I was surprised at this and want to know how I should choose the order of the factors, if the order affects the result.
Here is the small example. It is taken from 'The R Book', Crawley p. 365.
The data is at
2017 Oct 28
2
Function Relevel DOE NOT FOUND
Dear Forum,
Which functions and packages should be installed to make work the function "relevel"?
treatment<-revel(treatment,ref="Db")
Error: no se pudo encontrar la funci?n "revel"
Thank you very much for your help,
Xavier Chiriboga M.
PhD Candidate
Fundamental and Applied Research in Chemical Ecology Lab.
Institute of Biology
University of Neuchatel
2013 Jan 17
0
help with error: DV "converted to a factor"
I've spent several days compiling the following code (I apologize in advance
- this code is very inelegant, and I'm sure could be written much more
efficiently, but I've stuck with whatever method I could get to work -
sometimes the more efficient code I just couldn't get to work without an
error, because of my R inexperience).
My main motivation for writing the code is that
2002 Feb 15
2
Reordering factor levels
I would like to define the order of the levels of a factor.
The relevel function would work but since I have 20 levels I would prefer
to declare the order explicitly. Using a smaller example
levels(oldfactor)
"b1" "b2" "r1" "r2"
nufactor <- order(oldfactor,order=c("b1","r1","b2","r2")) # my fabricated function
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
2002 Sep 18
0
contrasts in lm~-1+(numeric.variable)/(factor) (PR#2037)
Full_Name: J. R. M. Hosking
Version: 1.5
OS: Windows 2000
Submission from: (NULL) (198.81.209.17)
Here is a test case:
# Some arbitrary data
#
v1<-1:12
v2<-cumsum(v1)
v3<-cumsum(v2)
f<-factor(rep(c("a","b","c"),4))
y<-c(1,4,2,7,5,8,7,9,6,10,12,10)
print(cbind(y,f,v1,v2,v3))
#
# Fit a regression model with no intercept, and different slopes
# for each
2012 Mar 21
3
Unable to specify order of a factor
Hi all:
I'm attempting to create a faceted plot with ggplot2 and I'm having issues
with a factor's order that is used to define the facet_grid().
The factor (named total.density) has three levels - 8, 16, and 32 - and I
would like them presented in that order. Running
order(levels(total.density)) yields the incorrect order of the facet grid -
2 3 1, corresponding with 16, 32, and 8.
2011 Jan 21
0
Marginality rule between powers and interaction terms in lm()
Dear all,
I have a model with simple terms, quadratic effects, and interactions.
I am wondering what to do when a variable is involved in a significant
interaction and in a non-significant quadratic effect. Here is an
example
d = data.frame(a=runif(20), b=runif(20))
d$y = d$a + d$b^2
So I create both an simple effect of a and a quadratic effect of b.
m = lm(y ~ a + b + I(a^2) + I(b^2) +