From 581b422f64522d8120511446a5ba1b58d7f45c69 Mon Sep 17 00:00:00 2001 From: dileksahin33 <54910779+dileksahin33@users.noreply.github.com> Date: Mon, 16 Sep 2019 01:53:44 -0400 Subject: [PATCH] Add files via upload --- Homeworks/hw1/HW1.m | 46 ++++++++++++++++++++++++++++ Homeworks/hw1/diaryHW1 | 68 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 Homeworks/hw1/HW1.m create mode 100644 Homeworks/hw1/diaryHW1 diff --git a/Homeworks/hw1/HW1.m b/Homeworks/hw1/HW1.m new file mode 100644 index 0000000..ae73c6c --- /dev/null +++ b/Homeworks/hw1/HW1.m @@ -0,0 +1,46 @@ +%% Homework 1 +%% Dilek Sahin +%% Q1 +X=[1,1.5,3,4,5,7,9,10]; +Y1=-2+.5*X; +Y2=-2+0.5*(X.^2); +hold on; +plot (X, Y1,'b-'); +plot(X,Y2,'r--'); +xlabel ('X'); +ylabel ('Y1 and Y2'); +legend({'Y1 = -2+.5X','Y2 = -2+0.5X^2'},'Location','northwest'); +hold off; + +%% Q2 +X2=linspace(-10,20,200)'; +sumX2=sum(X2); +%% Q3 +A=[2 4 6; 1 7 5; 3 12 4]; +b=[-2, 3, 10]'; +C=A'*b; +D=inv(A.'*A)*b; +E=sum(A.*repmat(b,1,3), 'all'); +F = A([1, 3:end], [1, 2]); +x=linsolve(A,b); + +%% Q4 +B=blkdiag(A,A,A,A,A); + +%% Q5 +A= normrnd(10,5,[5,3]); +A(A<10)=0; +A(A>=10)=1; + +%% Q6 +hw1data = csvread('hw1data.csv'); +Data=array2table(hw1data, 'VariableNames',{'firmid','year','export','rd','prod','cap'}); +fitlm(Data,'prod~export+rd+cap') + +%point estimates and standard errors respectively +%for Export +%\beta_{1} = 0.12013 and SE = 0.0063242 +%for R&D +%\beta_{2} = 0.13993 and SE = 0.0085393 +%for Capital Stock +%\beta_{3} = 0.029492 and SE = 0.0017839 \ No newline at end of file diff --git a/Homeworks/hw1/diaryHW1 b/Homeworks/hw1/diaryHW1 new file mode 100644 index 0000000..4a161bb --- /dev/null +++ b/Homeworks/hw1/diaryHW1 @@ -0,0 +1,68 @@ +%% Homework 1 +%% Dilek Sahin +%% Q1 +X=[1,1.5,3,4,5,7,9,10]; +Y1=-2+.5*X; +Y2=-2+0.5*(X.^2); +hold on; +plot (X, Y1,'b-'); +plot(X,Y2,'r--'); +xlabel ('X'); +ylabel ('Y1 and Y2'); +legend({'Y1 = -2+.5X','Y2 = -2+0.5X^2'},'Location','northwest'); +hold off; + +%% Q2 +X2=linspace(-10,20,200)'; +sumX2=sum(X2); +%% Q3 +A=[2 4 6; 1 7 5; 3 12 4]; +b=[-2, 3, 10]'; +C=A'*b; +D=inv(A.'*A)*b; +E=sum(A.*repmat(b,1,3), 'all'); +F = A([1, 3:end], [1, 2]); +x=linsolve(A,b); + +%% Q4 +B=blkdiag(A,A,A,A,A); + +%% Q5 +A= normrnd(10,5,[5,3]); +A(A<10)=0; +A(A>=10)=1; + +%% Q6 +hw1data = csvread('hw1data.csv'); +Data=array2table(hw1data, 'VariableNames',{'firmid','year','export','rd','prod','cap'}); +fitlm(Data,'prod~export+rd+cap') + +ans = + + +Linear regression model: + prod ~ 1 + export + rd + cap + +Estimated Coefficients: + Estimate SE tStat pValue + ________ _________ ______ __________ + + (Intercept) 0.081731 0.016729 4.8858 1.067e-06 + export 0.12013 0.0063242 18.996 2.1895e-77 + rd 0.13993 0.0085393 16.386 1.2832e-58 + cap 0.029492 0.0017839 16.532 1.3211e-59 + + +Number of observations: 4392, Error degrees of freedom: 4388 +Root Mean Squared Error: 0.179 +R-squared: 0.353, Adjusted R-Squared 0.353 +F-statistic vs. constant model: 799, p-value = 0 + +%point estimates and standard errors respectively +%for Export +%\beta_{1} = 0.12013 and SE = 0.0063242 +%for R&D +%\beta_{2} = 0.13993 and SE = 0.0085393 +%for Capital Stock +%\beta_{3} = 0.029492 and SE = 0.0017839 +diary off