Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions Homeworks/hw1/HW1.m
Original file line number Diff line number Diff line change
@@ -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
68 changes: 68 additions & 0 deletions Homeworks/hw1/diaryHW1
Original file line number Diff line number Diff line change
@@ -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:
<strong>Estimate</strong> <strong>SE</strong> <strong>tStat</strong> <strong>pValue</strong>
<strong>________</strong> <strong>_________</strong> <strong>______</strong> <strong>__________</strong>

<strong>(Intercept)</strong> 0.081731 0.016729 4.8858 1.067e-06
<strong>export </strong> 0.12013 0.0063242 18.996 2.1895e-77
<strong>rd </strong> 0.13993 0.0085393 16.386 1.2832e-58
<strong>cap </strong> 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