From: "Tom Lane" <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Multiple regression with dummy variable
Date: Wed, 6 Nov 2013 12:25:59 -0500
Organization: MathWorks
Lines: 32
Message-ID: <l5du38$6hk$>
Reply-To: "Tom Lane" <>
Mime-Version: 1.0
Content-Type: text/plain;
Content-Transfer-Encoding: 8bit
X-Trace: 1383758760 6708 (6 Nov 2013 17:26:00 GMT)
NNTP-Posting-Date: Wed, 6 Nov 2013 17:26:00 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 14.0.8089.726
X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8089.726
Xref: comp.soft-sys.matlab:804896

(Sorry for earlier incomplete reply.)

>> Im running a multiple linear regression that looks like (I have 
>> banks-year observations):
>> y = b1*x1+b2*x2+b3*x3+b4*x4+ error
>> where x4 is a dependent dummy variable that takes value of 1 (if the bank 
>> is audited by a big4 auditor firm) and 0 (if a bank isnt audited by a 
>> big4 auditor firm).
>> The question is: how I must define the dummy variable to run the 
>> regression (estimate the coefficients)? I think that I should use 
>> dummyvar, but I dont unterstand how it works.
> This depends on what you are starting with. Perhaps you can define x1 
> directly to have these 0/1 values. Suppose you have a variable named 
> auditor defined as a cell array of strings representing the auditor names. 
> Then you might try

>> auditor = {'PWC' 'Audits R Us' 'KPMG'}';
>> big4 = {'Deloitte' 'PWC' 'Ernst & Young' 'KPMG'}';
>> x1 = ismember(auditor,big4)
x1 =

The strcmp or similar function might also be useful in some cases.

-- Tom