Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Efficient creation of regression design matrix

  • To: mathgroup at
  • Subject: [mg82235] Efficient creation of regression design matrix
  • From: "Coleman, Mark" <Mark.Coleman at>
  • Date: Tue, 16 Oct 2007 03:20:21 -0400 (EDT)


I'm searching for an efficient bit of code to create a design matrix of
1's and 0's computed from  categorical (non-numeric) variables, suitable
for use in regression problems. More precisely, imagine one has an n x 1
vector of k different non-numeric values. For argument sakes, let
k={Red,Blue,Green,Yellow}. I would like to create an n x k matrix
consisting of 1's and 0's, where a '1' appears in the row and column
location corresponding to the presence of an element of k. For example,
say the original data is


  • Prev by Date: Re: InverseFourierTransform strange behaviour
  • Next by Date: Re: Applying Additive Gaussian Noise with standard deviation
  • Previous by thread: Re: Is this normal for Limit?
  • Next by thread: Re: Efficient creation of regression design matrix