Skip to content

Matrix of dummy variables from a factor

5 messages · Liaw, Andy, Bert Gunter, (Ted Harding) +2 more

#
See ?model.matrix.

HTH,
Andy

From: Charles H. Franklin
#
But note: There are (almost?) no situations in R where the dummy variables
coding is needed. The coding is (almost?) always handled properly by the
modeling functions themselves.

Question: Can someone provide a "straightforward" example where the dummy
variable coding **is** explicitly needed?

-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 
"The business of the statistician is to catalyze the scientific learning
process."  - George E. P. Box
#
On 06-Dec-05 Berton Gunter wrote:
Perhaps not particularly straightforward, but if you are using
package 'mix' for multiple imputation where some variables are
categorical and some continuous, the functions

  ecm.mix

  dabipf.mix

both take a paremeter "design" which is a design matrix expressing
dependency of the continuous variables on the categoricals.

The R function 'model.matrix' is useful for obtaining this matrix.

Best wishes,
Ted.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 06-Dec-05                                       Time: 22:39:44
------------------------------ XFMail ------------------------------
#
On Dec 6, 2005, at 3:27 PM, Berton Gunter wrote:

            
Bert's  question offers an opportunity for me to mention (again) my  
long standing wish
for someone to write a version of model.matrix that directly produced  
a matrix
in one of the common  sparse matrix formats.   This could be a good   
project for one of
you who like using ";" ?

Roger

url:    www.econ.uiuc.edu/~roger            Roger Koenker
email    rkoenker at uiuc.edu            Department of Economics
vox:     217-333-4558                University of Illinois
fax:       217-244-6678                Champaign, IL 61820