Displaying 20 results from an estimated 8000 matches similar to: "matching predictors and dummies"
2019 Aug 30
3
inconsistent handling of factor, character, and logical predictors in lm()
Dear R-devel list members,
I've discovered an inconsistency in how lm() and similar functions handle logical predictors as opposed to factor or character predictors. An "lm" object for a model that includes factor or character predictors includes the levels of a factor or unique values of a character predictor in the $xlevels component of the object, but not the FALSE/TRUE values
2019 Aug 31
2
inconsistent handling of factor, character, and logical predictors in lm()
Dear Abby,
> On Aug 30, 2019, at 8:20 PM, Abby Spurdle <spurdle.a at gmail.com> wrote:
>
>> I think that it would be better to handle factors, character predictors, and logical predictors consistently.
>
> "logical predictors" can be regarded as categorical or continuous (i.e. 0 or 1).
> And the model matrix should be the same, either way.
I think that
2008 Sep 03
1
test if all predictors in a glm object are factors
I'm trying to develop some graphic methods for glm objects, but they
only apply for models
where all predictors are discrete factors. How can I test for this in a
function, given the
glm model object?
That is, I want something that will serve as an equivalent of
is.discrete.glm() in the following
context:
myplot.glm <-
function(model, ...) {
if (!inherits(model,"glm"))
2012 Jul 09
1
Using the effects package
I've been looking into the effects package and it seems to be a great tool
for plotting the probabilities of the
response variable by the predictors. However, I'm wonder if I can use the
effects package to plot the probabilities
on the y axis and one predictor on the x axis, with the curve having the
info for another predictor.
So let's say our response variable is win, a binary
2019 Aug 31
0
inconsistent handling of factor, character, and logical predictors in lm()
Dear Bill,
Thanks for pointing this difference out -- I was unaware of it.
I think that the difference occurs in model.matrix.default(), which coerces character variables but not logical variables to factors. Later it treats both factors and logical variables as "factors" in that it applies contrasts to both, but unused factor levels are dropped while an unused logical level is not.
I
2008 Nov 11
1
simulate data with binary outcome and correlated predictors
Hi,
I would like to simulate data with a binary outcome and a set of predictors that are correlated. I want to be able to fix the number of event (Y=1) vs. non-event (Y=0). Thus, I fix this and then simulate the predictors. I have 2 questions:
1. When the predictors are continuous, I can use mvrnorm(). However, if I have continuous, ordinal and binary predictors, I'm not sure how to simulate
2011 Feb 01
2
Preparing dataset for glmnet: factors to dummies
Hello list.
For some reason, the makers of glmnet do not accept a dataframe as input.
They expect the input to be a matrix, where the dummies are already
precoded.
Now I have created a sample dataset with
. 11 factor columns with two levels
. 4 factor columns with three levels
. 135 continuous columns (from a standard normal)
. 100 observations (rows)
Say this dataframe is in dfrPredictors.
What
2010 Aug 07
3
plot the dependent variable against one of the predictors with other predictors as constant
Hi, folks,
Happy work in weekends >_<
My question is how to plot the dependent variable against one of the
predictors with other predictors as constant. Not for the original data, but
after prediction. It means y is the predicted value of the dependent
variables. The constane value of the other predictors may be the average or
some fixed value.
#######
y=1:10
x=10:1
z=2:11
2010 Mar 09
2
looping through predictors
Dear R-ers,
I have a data frame data with predictors x1 through x5 and the
response variable y.
I am running a simple regression:
reg<-lm(y~x1, data=data)
I would like to loop through all predictors. Something like:
predictors<-c("x1","x2",... "x10)
for(i in predictors){
reg<-lm(y~i)
etc.
}
But it's not working. I am getting an error:
Error in
2011 Mar 07
2
use "caret" to rank predictors by random forest model
Hi,
I'm using package "caret" to rank predictors using random forest model and draw predictors importance plot. I used below commands:
rf.fit<-randomForest(x,y,ntree=500,importance=TRUE)
## "x" is matrix whose columns are predictors, "y" is a binary resonse vector
## Then I got the ranked predictors by ranking
2008 May 27
1
lm() output with quantiative predictors not the same as SAS
I am trying to use R lm() with quantitative and qualitative predictors, but am
getting different results than those that I get in SAS.
In the R ANOVA table documentation I see that "Type-II tests corresponds to the
tests produced by SAS for analysis-of-variance models, where all of the
predictors are factors, but not more generally (i.e., when there are
quantitative predictors)." Is
2006 Mar 27
1
Glm poisson
Hello,
I am using the glm model with a poisson distribution. The model runs
just fine but when I try to get the null deviance for the model of the
null degrees of freedom I get the following errors:
> null.deviance(pAmeir_1)
Error: couldn't find function "null.deviance"
> df.null(pAmeir_1)
Error: couldn't find function "df.null"
When I do:
>
2012 Jul 05
2
Plotting the probability curve from a logit model with 10 predictors
I have a logit model with about 10 predictors and I am trying to plot the
probability curve for the model.
Y=1 = 1 / 1+e^-z where z=B0 + B1X1 + ... + BnXi
If the model had only one predictor, I know to do something like below.
mod1 = glm(factor(won) ~ as.numeric(bid), data=mydat,
family=binomial(link="logit"))
all.x <- expand.grid(won=unique(won), bid=unique(bid))
y.hat.new
2010 Jan 27
1
selecting significant predictors from ANOVA result
Dear all,
I did ANOVA for many response variables (Var1, Var2, ....Var75000), and i got the result of p-value like below. Now, I want to select those predictors, which have pvalue less than or equal to 0.05 for each response variable. For example, X1, X2, X3, X4, X5 and X6 in case of Var1, and similarly, X1, X2.......X5 in case of Var2, only X1 in case of Var3 and none of the predictors in case
2012 Aug 01
1
rpart package: why does predict.rpart require values for "unused" predictors?
After fitting and pruning an rpart model, it is often the case that one or
more of the original predictors is not used by any of the splits of the
final tree. It seems logical, therefore, that values for these "unused"
predictors would not be needed for prediction. But when predict() is called
on such models, all predictors seem to be required. Why is that, and can it
be easily
2011 Apr 15
1
GLM and normality of predictors
Hi,
I have found quite a few posts on normality checking of response variables, but I am still in doubt about that. As it is easy to understand I'm not a statistician so be patient please.
I want to estimate the possible effects of some predictors on my response variable that is nº of males and nº of females (cbind(males,females)), so, it would be:
2011 Dec 30
1
Fwd: Re: Poisson GLM using non-integer response/predictors?
Hi,
Use offset variables if count occurrences of an event and you want to
model the
observation time.
glm(count ~ predictors + offset(log(observation_time)), family=poisson)
If you want to compare durations, look at library(survival), ?coxph
If tnoise_sqrt is the square root of tourist noise, your example seems
incorrect, because it is a predictor, not the dependent variable
tnoise_sqrt ~
2009 Aug 19
2
Problem with predict.coxph
We occasionally utilize the coxph function in the survival library to fit multinomial logit models. (The breslow method produces the same likelihood function as the multinomial logit). We then utilize the predict function to create summary results for various combinations of covariates. For example:
2005 Nov 18
3
Fitting model with varying number of predictors
I need to fit a number of models with different number of predictors
in each model. Say for example, I have three predictors: x1, x2, x3
and I want to fit three models:
lm(y~x1+x2)
lm(y~x2+x3)
lm(y~x1+x2+x3)
Instead of typing all models, what I want is to create a variable
which can take the right hand side of the models. I tried this with
paste function.
2010 May 14
4
Categorical Predictors for SVM (e1071)
Dear all,
I have a question about using categorical predictors for SVM, using "svm"
from library(e1071). If I have multiple categorical predictors, should they
just be included as factors? Take a simple artificial data example:
x1<-rnorm(500)
x2<-rnorm(500)
#Categorical Predictor 1, with 5 levels
x3<-as.factor(rep(c(1,2,3,4,5),c(50,150,130,70,100)))
#Catgegorical Predictor