You are on page 1of 9

Assignment 2 HUL 215 Econometric Methods

Baranidharan Mohan 2010PH10833


(Dated: February 18, 2013) Worked with Deependra Mehalawat and Shefali Chandolia.

Question 1

Consider the following linear regression, yt = 1 + 2 x2t + 3 x3t + t. where t = 1, 2, ..., N and N is the sample size, or number of observations made. And, the equation can be correspondingly written in a matrix form as y = X + While reconstructing the code from the working paper, the following assumptions are retained. x2 is a trend variable which takes the values (1,2, . . . 30) x3 is a random variable with uniform distribution on [3, 5] t are independent identically distributed normal random variables with zero mean and constant variance 2 . 1 = 5, 2 = 1 and 3 = 0.1 and t are N (0, .04) ,( 2 = 0.04) The MATLAB code is attached below. The code can be viewed in three parts: All the variables in the problem are initialized and assigned to their values, according to their specications given above. The number of observations n is taken to be 100, and can be comfortably modied by changing its value in the code.

2 In this section, various values and parameters are calculated using the relations derived using multiple regression = (X X)1 X y; y = X ; ui = yi y i ;
n

u = y y;

SSR =
i=1

u2 i = u u = y y;

2 = SSR ; Estimate of V ariance nk 2 (X X)1 ; Covariance M atrix = Standard Deviation V ector of Beta = Diagonal V ector of Covariance M atrix; SSR ; R2 = 1 SST
n

SST =
i=1

(yi y )2 ;

In the last part of the code, all the results are printed. The code used is given below.
% % % % % % % % % % Initaliztion and Assignment % % % % % % % % % % beta =[5 ,1 ,.1] ; n = 100; k = 3; x1 = ones (n ,1); x2 = [1: n ] ; x3 = rand (n ,1)*2 +3; e = randn (n ,1)*0.2; X = [ x1 , x2 , x3 ]; y = X * beta + e ; % % % % % % % % Calculation of different values % % % % % % % % % % % Please refer the pdf file for the detailed explanation how each % % % % % % % %of the following lines of code was arrived at. % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %

betahat = (X * X )\ X * y ; yhat = X * betahat ; residuals = y - yhat ; SSR = residuals * residuals ; variance = SSR /( n - k ); cov_of_beta = variance * inv (X * X ); stdev_of_beta = s q r t ( diag ( cov_of_beta )); ybar = y - mean( y ); rsqr = 1 - SSR /( ybar * ybar ); % % % % % % % % % % % Printing the values % % % % % % % % % % % % % f p r i n t f ( - - - - - - - - - - - - - - - - - Overall Statistics - - - - - - - - - - - - - - - - - - -\ n ) f p r i n t f ( No . of Observations = %4 d \ n ,n ); f p r i n t f ( No . of variables f p r i n t f ( SSR . f p r i n t f ( R - squared f p r i n t f ( Variance = %4 d \ n ,k ); = %6.6 f \ n , SSR ); = %6.6 f \ n , rsqr ); = %6.6 f \ n , variance );

f p r i n t f ( - - - - - - - - - - - Statistics of the coefficients - - - - - - - - - - - - -\ n ) f p r i n t f ( Variances of Beta diag ( cov_of_beta )); f p r i n t f ( St . Dev . of Beta stdev_of_beta ); f p r i n t f ( Betahat = %6.6 f %6.6 f %6.6 f \ n , betahat ); = %6.6 f %6.6 f %6.6 f \ n , ... = %6.6 f %6.6 f %6.6 f \ n , ...

f p r i n t f ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\ n ) % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %

4
Question 2

i) Given the equation to be estimated is gif t = 0 + 1 mailsyear + 2 gif tlast + 3 propresp + u; we can use the program used in the above exercise to solve this question, after importing the necessary values. After regressing on the three variables we get the following results, 0 1 = 2.166259 2 = 0.005927 3 = 15.358605; = 4.551519

SST = 968099.839503 SSE = 80700.705716 SSR = 887399.133787 and R2 = 0.083360. On simple regression by taking only one dependent variable we get the following equation, gif t = 0 + 1 mailsyear + u; and the following results, 0 1 = 2.649546 = 2.014080

SST = 968099.839503 SSE = 13349.725136 SSR = 954750.114367 and R2 = 0.013790. We nd that the two values of R2 are pretty low to consider the t a good t. However, the value of R2 decreases when we omit the other two variables. Hence this shows that the t is a better t when more variables are taken into account. ii) 1 = 2.649546) with that of the multiple of By comparing the simple regression coecient ( 1 = 2.166259), we can nd that the coecient increases when we are omitting regression ( the other two variables showing that there is greater dependence on the mailsyear. iii) Given that propresp is the response rate of the mailings, it can be interpreted as the probability of the person responding to the current mail. Hence, it has a value between 0 and 3 = 15.358605 we nd 1. Further, from the corresponding coecient of regression which is

5 that there is a strong dependence of the amount of gifts on the probability of the person responding to the mail. iv) Consider the new equation by adding the avggif t term to the regression, gif t = 0 + 1 mailsyear + 2 gif tlast + 3 propresp + 4 avggif t + u; Summarizing the values we obtained from the regression of the above equation we get, 0 1 = 1.201168 2 = 0.260857 3 = 16.204642 4 = 0.526947; = 7.327763

SST = 968099.839503 SSE = 194137.376747 SSR = 773962.462756 and R2 = 0.200534. 1 has After adding avggif t to the equation we get that the coecient of the mailsyear ie., decreased considerable. Hence, there is a decreased dependence of gif t on mailsyear. v) 2 ) has decreased from the a positive We can see that three is the coecient of gif tlast ( value (0.005927) to a negative value (-0.260857) on including avggif t into the equation. This is because of the correlation between the two sets of dependent variables. ie., the term avggif t depends on the value of gif tlast. And they are negatively correlated, which can be easily referred getting the value of Corr(avggif t, gif tlast) = 2.2500 104 which is the element (3,5) or (5,3) of the cov of beta matrix. The code used for this question is similar to the one used for Question 1, and is given below. The values listed above have been calculated by using the following code.
% % % % % % % % % % Initalization and Assignment % % % % % % % % % % Data = importdata ( charity . xls ); respond = Data (: ,1); gift = Data (: ,2); resplast = Data (: ,3); weekslast = Data (: ,4); propresp = Data (: ,5); mailsyear = Data (: ,6); giftlast = Data (: ,7);

avggift = Data (: ,8); x1 = ones (4268 ,1); X = [ x1 , mailsyear , giftlast , propresp ]; y = gift ; [ n , k ] = s i z e ( X ); % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % Regression with three variables % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % betahat = (X * X )\ X * y ; yhat = X * betahat ; residuals = y - yhat ; SSR = residuals * residuals ; variance = SSR /( n - k ); cov_of_beta = variance * inv (X * X ); stdev_of_beta = s q r t ( diag ( cov_of_beta )); ym = y - mean( y ); ye = yhat - mean( yhat ); SST SSE = ym * ym ; = ye * ye ;

rsqr = 1 - SSR / SST ; % % % % % % % % % % % Printing the values % % % % % % % % % % % % % f p r i n t f ( - - - - - - - - - - - - Regression with three variables - - - - - - - - - - -\ n ) f p r i n t f ( No . of Observations = %4 d \ n ,n ); f p r i n t f ( No . of variables f p r i n t f ( SSR . f p r i n t f ( SSE . f p r i n t f ( SST . f p r i n t f ( R - squared f p r i n t f ( Variance = %4 d \ n ,k ); = %6.6 f \ n , SSR ); = %6.6 f \ n , SSE ); = %6.6 f \ n , SST ); = %6.6 f \ n , rsqr ); = %6.6 f \ n , variance );

f p r i n t f ( - - - - - - - - - - - Statistics of the coefficients - - - - - - - - - - - - -\ n )

f p r i n t f ( Variances of Beta diag ( cov_of_beta )); f p r i n t f ( St . Dev . of Beta stdev_of_beta ); f p r i n t f ( Betahat betahat );

= %6.6 f

%6.6 f

%6.6 f

%6.6 f \ n , ...

= %6.6 f

%6.6 f

%6.6 f

%6.6 f \ n , ...

= %6.6 f

%6.6 f

%6.6 f

%6.6 f \ n , ...

f p r i n t f ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\ n ) % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % Simple Regression on one variable % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % X = [ x1 , mailsyear ]; y = gift ; [ n , k ] = s i z e ( X ); betahat = (X * X )\ X * y ; yhat = X * betahat ; residuals = y - yhat ; SSR = residuals * residuals ; variance = SSR /( n - k ); cov_of_beta = variance * inv (X * X ); stdev_of_beta = s q r t ( diag ( cov_of_beta )); ym = y - mean( y ); ye = yhat - mean( yhat ); SST SSE = ym * ym ; = ye * ye ;

rsqr = 1 - SSR / SST ; % % % % % % % % % % % Printing the values % % % % % % % % % % % % % f p r i n t f ( - - - - - - - - - - Simple Regression on one variable - - - - - - - - - - - -\ n ) f p r i n t f ( No . of Observations = %4 d \ n ,n ); f p r i n t f ( No . of variables f p r i n t f ( SSR . = %4 d \ n ,k ); = %6.6 f \ n , SSR );

f p r i n t f ( SSE . f p r i n t f ( SST . f p r i n t f ( R - squared f p r i n t f ( Variance

= %6.6 f \ n , SSE ); = %6.6 f \ n , SST ); = %6.6 f \ n , rsqr ); = %6.6 f \ n , variance );

f p r i n t f ( - - - - - - - - - - - Statistics of the coefficients - - - - - - - - - - - - -\ n ) f p r i n t f ( Variances of Beta diag ( cov_of_beta )); f p r i n t f ( St . Dev . of Beta stdev_of_beta ); f p r i n t f ( Betahat = %6.6 f %6.6 f \ n , betahat ); = %6.6 f %6.6 f \ n , ... = %6.6 f %6.6 f \ n , ...

f p r i n t f ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\ n ) % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % Regression on four variables% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % X = [ x1 , mailsyear , giftlast , propresp , avggift ]; y = gift ; [ n , k ] = s i z e ( X ); betahat = (X * X )\ X * y ; yhat = X * betahat ; residuals = y - yhat ; SSR = residuals * residuals ; variance = SSR /( n - k ); cov_of_beta = variance * inv (X * X ); stdev_of_beta = s q r t ( diag ( cov_of_beta )); ym = y - mean( y ); ye = yhat - mean( yhat ); SST SSE = ym * ym ; = ye * ye ;

rsqr = 1 - SSR / SST ; % % % % % % % % % % % Printing the values % % % % % % % % % % % % %

f p r i n t f ( - - - - - - - - - - - - Regression on four variables - - - - - - - - - - - - - -\ n ) f p r i n t f ( No . of Observations = %4 d \ n ,n ); f p r i n t f ( No . of variables f p r i n t f ( SSR . f p r i n t f ( SSE . f p r i n t f ( SST . f p r i n t f ( R - squared f p r i n t f ( Variance = %4 d \ n ,k ); = %6.6 f \ n , SSR ); = %6.6 f \ n , SSE ); = %6.6 f \ n , SST ); = %6.6 f \ n , rsqr ); = %6.6 f \ n , variance );

f p r i n t f ( - - - - - - - - - - - Statistics of the coefficients - - - - - - - - - - - - -\ n ) f p r i n t f ( Variances of Beta = %6.6 f %6.6 f %6.6 f

%6.6 f %6.6 f \ n , diag ( cov_of_beta )); f p r i n t f ( St . Dev . of Beta = %6.6 f %6.6 f %6.6 f

%6.6 f %6.6 f \ n , stdev_of_beta ); f p r i n t f ( Betahat %6.6 f %6.6 f \ n , betahat ); f p r i n t f ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\ n ) % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % = %6.6 f %6.6 f %6.6 f