similar to: Turn categorical array into matrix with dummy variables

Displaying 20 results from an estimated 10000 matches similar to: "Turn categorical array into matrix with dummy variables"

2012 Aug 01
3
How to link two R packages together
Hi, I have built two R packages. One of them (PKG1) needs to use the functions of the other package (PKG2). So I need to link these two packages together, so that the functions of PKG2 can be available to PKG1. And when I load one package using 'library("PKG1")', PKG2 can be loaded at the same. Any ideas welcome. -- View this message in context:
2001 May 09
1
Coding categorical -> dummy
Dear R-Users, I have a data frame with several categorical variables. I want to create a new data frame with dummy variables (with all levels). I know the function model.matrix (see below) but it works only for one categorical variable : > tt <- c("a","a","b","a","c") > tt <- factor(tt) > model.matrix(~ tt - 1) is there anyone who
2013 Sep 22
2
Coding several dummy variables into a single categorical variable
Colleagues, I have generated several dummy variables: n$native0 <- 1 * (n$re=="white" & n$usborn=="yes") n$native1 <- 1 * (n$re=="afam" & n$usborn=="yes") n$native2 <- 1 * (n$re=="carib" & n$usborn=="yes") n$native3 <- 1 * (n$re=="carib" & n$usborn=="no") I would now like to combine these
2009 Dec 01
0
coding negative effects in categorical dummy variables
Hello, I have a problem with categorical variables and dummy encoding. I've a factor and for each pair (i,j) with i != j, I'd like to fit res ~ a*x[i] - b*x[j]. A brief example with 3 variables: a - b = 2 b - c = -1 c - a = 0 Thus I fitted the following model: fit <- lm(result ~ X + Y) where Y is just the negative of X, means y[i] = -x[i]. But I don't want to double the
2003 Oct 15
2
aov and non-categorical variables
It is unclear to me how aov() handles non-categorical variables. I mean it works and produces results that I would expect, but I was under impression that ANOVA is only defined for categorical variables. In addition, help(aov) says that it "call to 'lm' for each stratum", which I presume means that it calls to lm() for every group of the categorical variable, however I
2003 Sep 08
1
problems with categorical variables
Hi All: I am working on a dataset of a study on healthcare workers. One of the variables I am studying is a categorical variable (variable name:EDUC, indicates educational achievement, with 6 levels: "illiterate", "primary", "junior high school", "high school completed", "undergraduate", and "postgraduate"). I want to collapse the
2011 Jul 29
1
R, ctree and categorical variables
I am running the ctree function in R. My data has about 10 variables, many of which are categorical. 2 of the categorical variables have many levels (one has 900 levels, another has 1,000 levels). As an example, 1 of these variables is disease code and is structured as A, B, C, ...., AA, AB, AC.... Each time i've tried to run the ctree function, including these 2
2003 Apr 14
2
categorical variables
Dear helpers I constructed a data frame with this structure > str(dados1) `data.frame': 485 obs. of 16 variables: $ Emissor : int 1 1 1 1 1 1 1 1 1 1 ... $ Marisca.Rio : int 1 1 1 1 1 1 1 1 1 1 ... $ Per?odo : int 1 1 1 1 1 1 1 1 1 1 ... $ Reproducao : int 3 3 3 3 3 3 3 3 3 3 ... $ Estacao : int 2 2 2 2 2 2 2 2 2 2 ... $ X30cm : int
2007 Jun 12
3
Appropriate regression model for categorical variables
Dear users, In my psychometric test i have applied logistic regression on my data. My data consists of 50 predictors (22 continuous and 28 categorical) plus a binary response. Using glm(), stepAIC() i didn't get satisfactory result as misclassification rate is too high. I think categorical variables are responsible for this debacle. Some of them have more than 6 level (one has 10 level).
2017 Aug 18
1
Meta-regression of categorical variables
Dear metafor users, I am working on a meta-analysis of reliability and the correlation associations. I need some help about conducting categorical moderators variables. Questions 1: How to conduct the weighted ANOVAs assuming a mixed-effects model on the tranformed alpha coefficients/the tranformes correlation coefficients for the categorical moderator variables? Questions 2: How to
2009 Aug 03
1
min frequencies of categorical predictor variables in GLM
Hi, Suppose a binomial GLM with both continuous as well as categorical predictors (sometimes referred to as GLM-ANCOVA, if I remember correctly). For the categorical predictors = indicator variables, is then there a suggested minimum frequency of each level ? Would such a rule/ recommendation be dependent on the y-side too ? Example: N is quite large, a bit > 100. Observed however are
2012 Oct 17
1
Random Forest for multiple categorical variables
Dear all, I have the following data set. V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 alpha beta 1 11 1 11 1 11 1 11 1 11 alpha beta1 2 12 2 12 2 12 2 12 2 12 alpha beta1 3 13 3 13 3 13 3 13 3 13 alpha beta1 4 14 4 14 4 14 4 14 4 14 alpha beta1 5 15 5 15 5 15 5 15 5
2010 Mar 28
6
Coding of categorical variables for logistic regression?
Hello, I am trying to do a logistic regression and have one predictor variable (x) that is ratio and two predictor variables (y and z) that are categorical. These have three levels each which I have called "High", "Medium" and "Low". My question: do I need to use a numerical coding scheme for the categorical variables as required by some statistical software
2006 Sep 11
1
summary(glm) for categorical variables
Dear list people Suppose we have a data.frame where variables are categorical and the response is categorical eg: my.df=NULL for(i in LETTERS[1:3]){my.df[[i]]=sample(letters, size=10)} my.df=data.frame(my.df) my.df$class=factor(rep(c("pos", "neg"), times=5)) my.glm=glm(class ~ ., data=my.df, family=binomial) summary(my.glm) .... Estimate Std. Error z
2011 Dec 12
1
categorical variables
I am doing a logistic regression, and by accident I included a field which has the 2digit abbreviation for all 50 states labeled "st". I was surprised to see that the glm did not come up with an error message but instead appears to have automatically broken down this field into individual fields (stAK and stAL). Does R really know to turn all categorical variables in binary dummy
2008 Apr 03
2
coding for categorical variables with unequal observations
Hi, I am doing multiple regression, and have several X variables that are categorical. I read that I can use dummy or contrast codes for that, but are there any special rules when there're unequal #observations in each groups (4 females vs 7 males in a "gender" variable)? Also, can R generate these codes for me? THanks.
2012 Aug 02
1
Metafor package: Including multiple (categorical) predictors
Dear Metafor users, I''d like to test a model with 2 continuous and 2 categorical moderators in a meta regression. One categorical parameter has 2 levels and the other has 4 levels. If I understand correctly, when I include all moderators in the model, Metafor returns main effects of the continuous parameters and contrasts of each level of categorical moderators with the intercept (which
2010 Jun 14
2
Which is the easiest (most elegant) way to force "aov" to treat numerical variables as categorical ?
Hi R help, Hi R help, Which is the easiest (most elegant) way to force "aov" to treat numerical variables as categorical ? Sincerely, Andrea Bernasconi DG PROBLEM EXAMPLE I consider the latin squares example described at page 157 of the book: Statistics for Experimenters: Design, Innovation, and Discovery by George E. P. Box, J. Stuart Hunter, William G. Hunter. This example use
2012 May 08
1
Regression with very high number of categorical variables
Dear all, I would like to run a simple regression model y~x1+x2+x3+... The problem is that I have a lot of independent variables (xi) -- around one hundred -- and that some of them are categorical with a lot of categories (like, for example, ZIP code). One straightforward way would be to (a) transform all categorical variables into 1/0 dummies and (b) enter all the variables into an lm model.
2011 Jun 12
2
using categorical variable in multiple regression
Hello, I wanted to do the multiple regression on categorical predictor data there's variable x1,x2,x3 and x3 is categorical one. so i just used as.factor(x3) and then ran multiple regression is it a good way to do the multiple regression on categorical predictor data? and how can I interpret the estimates? also if using as.factor is a good way, is there any difference with doing dummy coding