tag:blogger.com,1999:blog-6710487119650146215.post8942017737289520969..comments2018-02-16T02:45:47.656-07:00Comments on R Tutorial Series: R Tutorial Series: Regression With Categorical VariablesJohnhttp://www.blogger.com/profile/05331039307550313006noreply@blogger.comBlogger20125tag:blogger.com,1999:blog-6710487119650146215.post-58627127977436925652015-02-25T18:02:13.504-07:002015-02-25T18:02:13.504-07:00Try ifelse(x =="yes", 1, 0)?Try ifelse(x =="yes", 1, 0)?Ram Dwivedihttps://www.blogger.com/profile/07586786008034674137noreply@blogger.comtag:blogger.com,1999:blog-6710487119650146215.post-59777361625939391212013-12-09T04:30:12.642-07:002013-12-09T04:30:12.642-07:00There is a tutorial for creating those Coding Syst...There is a tutorial for creating those Coding Systems for categorical variables<br /><br />http://www.ats.ucla.edu/stat/r/library/contrast_coding.htmKriztian Jhttps://www.blogger.com/profile/13060476465663010792noreply@blogger.comtag:blogger.com,1999:blog-6710487119650146215.post-16529686072170462552013-10-07T11:12:29.163-07:002013-10-07T11:12:29.163-07:00subtract 1 and take the square.subtract 1 and take the square.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6710487119650146215.post-28939874388520770732013-03-29T15:14:18.168-07:002013-03-29T15:14:18.168-07:00I have a data in which the binary response coded 0...I have a data in which the binary response coded 0 and 1 needs to be changed. For example: since I`m gonna run a logistic regression, the response in which I am interested in is coded 0. But the reference for the model in R is 1. So, I need to switch the coding, and the response encoded 1 turn out to be 0 and vice-versa. I´m sweating my pants here to try and change this. Does anyone know how to do it?Ariahttps://www.blogger.com/profile/09725218460506609445noreply@blogger.comtag:blogger.com,1999:blog-6710487119650146215.post-32689059136150306502013-01-14T03:01:34.035-07:002013-01-14T03:01:34.035-07:00what about the relationship between 2 categorical ...what about the relationship between 2 categorical variables<br /><br />say high blood pressure: yes/no<br />Obese : yes/no<br /><br />can box plot work there?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6710487119650146215.post-22635011865582656662012-11-27T13:11:20.871-07:002012-11-27T13:11:20.871-07:00try
est <- c("yes","no",&qu...try<br />est <- c("yes","no","no","no","no","yes","yes");<br />test <- as.factor(test)<br />dtest <- as.numeric(test)-1<br />test2 <- c(17256,23074,20666,24249,21992,19413,19545);<br />plot(as.factor(dtest),test2);<br /><br />By default R2.15 produces a boxplot when you plot a continuous variable against a categorical variable.Siva Sankaranarayananhttps://www.blogger.com/profile/15687335779179429100noreply@blogger.comtag:blogger.com,1999:blog-6710487119650146215.post-85073056139102095082012-10-09T14:59:30.400-07:002012-10-09T14:59:30.400-07:00This tutorial did not explore whether there is a s...This tutorial did not explore whether there is a statistically significant difference between the conferences, although that is something you could examine if you wanted to. Instead, the tutorial looked at how conference and QB salaries predicted the total team salaries. Ultimately, conference was not a good predictor of overall team salaries.John Quickhttps://www.blogger.com/profile/05331039307550313006noreply@blogger.comtag:blogger.com,1999:blog-6710487119650146215.post-17865971063439468742012-10-09T12:49:58.214-07:002012-10-09T12:49:58.214-07:00So, is there significant difference between salary...So, is there significant difference between salary in AFC and NFC? Since the p-value for dCONF is > 0.05 doesn't that means there is no significant difference between conference salaries?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6710487119650146215.post-53042374690444893982012-10-09T12:47:18.289-07:002012-10-09T12:47:18.289-07:00As it turned out, the following work. Still not su...As it turned out, the following work. Still not sure why plotting dtest doesn't work.<br />test <- c("yes","no","no","no","no","yes","yes");<br />test <- factor(test)<br />test2 <- c(17256,23074,20666,24249,21992,19413,19545);<br />plot(test,test2);<br /><br />Thanks for the tutorial. Didn't know you want generate boxplot this way. Very useful<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6710487119650146215.post-89601091776176357822012-10-09T09:16:40.612-07:002012-10-09T09:16:40.612-07:00There is a boxplot() function in R, so try using t...There is a boxplot() function in R, so try using that to see if you can get the intended graph. Something may have changed in R since I wrote this tutorial that prevents the plot() function from working as demonstrated.John Quickhttps://www.blogger.com/profile/05331039307550313006noreply@blogger.comtag:blogger.com,1999:blog-6710487119650146215.post-26681748038736586742012-10-09T07:10:34.159-07:002012-10-09T07:10:34.159-07:00Is there a trick to use plot() to generate boxplot...Is there a trick to use plot() to generate boxplot? When I tried to do plot() on my own dataset, I am still getting a scatterplot instead of boxplot.<br /><br />test <- c("yes","no","no","no","no","yes","yes");<br />test <- as.factor(test)<br />dtest <- as.numeric(test)-1<br />test2 <- c(17256,23074,20666,24249,21992,19413,19545);<br />plot(dtest,test2);<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6710487119650146215.post-65441777980430493462012-09-22T01:47:44.124-07:002012-09-22T01:47:44.124-07:00Nice tutorial, But how can i create n-1 dummy vari...Nice tutorial, But how can i create n-1 dummy variables?Vigneshnoreply@blogger.comtag:blogger.com,1999:blog-6710487119650146215.post-38919867968929264812012-06-16T10:57:12.842-07:002012-06-16T10:57:12.842-07:00There are usually a large number of ways to execut...There are usually a large number of ways to execute things in R, so my tutorials focus on demonstrating just one way of doing things.John Quickhttps://www.blogger.com/profile/05331039307550313006noreply@blogger.comtag:blogger.com,1999:blog-6710487119650146215.post-20746641350188122122012-06-16T10:54:59.951-07:002012-06-16T10:54:59.951-07:00Yes, that is correct. For more than two levels, yo...Yes, that is correct. For more than two levels, you need to create n-1 variables. Thanks for pointing that out. JohnJohn Quickhttps://www.blogger.com/profile/05331039307550313006noreply@blogger.comtag:blogger.com,1999:blog-6710487119650146215.post-53347118574735850152012-06-14T05:47:32.980-07:002012-06-14T05:47:32.980-07:00Hello,
While it is treu that as.numeric() is not ...Hello,<br /><br />While it is treu that as.numeric() is not limited to binary categories. However, you cannot use that be a categorical regression. You need to create n-1 variables and make them all 1s or 0s. You will have category 1 as 10 category 2 as 01, and category 3 as 00. This makes sure you don't have interference or implied relationships or order between variables.<br /><br />In short, the function works to create inputs, but is statistically NOT correct.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6710487119650146215.post-69933052529599152902012-05-18T13:50:46.521-07:002012-05-18T13:50:46.521-07:00Why not simply run lm(variable ~ factor(cat_variab...Why not simply run lm(variable ~ factor(cat_variable) + continous_var)?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6710487119650146215.post-13676957517661936722012-05-14T08:46:52.325-07:002012-05-14T08:46:52.325-07:00See the above question from Harry.See the above question from Harry.John M. Quickhttps://www.blogger.com/profile/05331039307550313006noreply@blogger.comtag:blogger.com,1999:blog-6710487119650146215.post-43437339640614302642012-05-14T02:14:16.698-07:002012-05-14T02:14:16.698-07:00How do u convert a variable into dummy variable ha...How do u convert a variable into dummy variable having more than two categories?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6710487119650146215.post-73335862297046845212012-04-22T12:55:32.374-07:002012-04-22T12:55:32.374-07:00Hi,
as.numeric() is not limited to binary catego...Hi, <br /><br />as.numeric() is not limited to binary categories<br /><br />JohnJohn M. Quickhttps://www.blogger.com/profile/05331039307550313006noreply@blogger.comtag:blogger.com,1999:blog-6710487119650146215.post-65421646720536580282012-04-21T05:38:13.558-07:002012-04-21T05:38:13.558-07:00What if you had more than two categories? The &quo...What if you had more than two categories? The "as.numeric" trick you are using only works for binary categories doesn't it?Harry Palmerhttps://www.blogger.com/profile/01237117210571168261noreply@blogger.com