Computer LAB Week#3 - Questions
Computer LAB Week#3 - Questions
matrix(7,4) stats
stats(1,1)=@mean(salary)
stats(1,2)=@mean(roe)
stats(1,3)=@mean(ros)
stats(1,4)=@mean(sales)
stats(2,1)=@var(salary)
stats(2,2)=@var(roe)
stats(2,3)=@var(ros)
stats(2,4)=@var(sales)
2
stats(3,1)=@max(salary)
stats(3,2)=@max(roe)
stats(3,3)=@max(ros)
stats(3,4)=@max(sales)
stats(4,1)=@min(salary)
stats(4,2)=@min(roe)
stats(4,3)=@min(ros)
stats(4,4)=@min(sales)
stats(5,1)=@skew(salary)
stats(5,2)=@skew(roe)
stats(5,3)=@skew(ros)
stats(5,4)=@skew(sales)
stats(6,1)=@kurt(salary)
stats(6,2)=@kurt(roe)
stats(6,3)=@kurt(ros)
stats(6,4)=@kurt(sales)
For all four random variables, the skewness coefficient is larger than 0 (positive) which suggests a
long right tail. For instance, for the variable salary the positive skewness arises from a few firms
that are paying very large CEO salaries.
For all four random variables, the tails are thicker than those of the Normal distribution,
particularly for salary.
stats(7,1)=@obs(salary)
stats(7,2)=@obs(roe)
stats(7,3)=@obs(ros)
stats(7,4)=@obs(sales)
The number of observations for salary and roe is 209 (one observation per firm), but for roe
it is 207 (two ros observations missing(, and for sales it is 208 (one observation missing).
We create four scalar objects (cov1, cov2, corr1, corr2) to store the results:
The covariance cannot be interpreted in isolation as it is not bounded and is not unit free;
we can see that for observations for same variables expressed in different units give
different results. We cannot conclude that the dependence between salary and roe is larger
than the dependence between salary and roed since the random variable return-of-equity is
only one but the measures roe and roed have been stated in percentages and decimal
format, respectively. The correlation is a rescaled version of the covariance that is now
bounded between -1 and 1, and is unit free. The degree of dependence between CEO salary
and the roe (return of investment of the firm) is low at 11.48%.
group variables salary roe ros sales ‘creates a group object named variables
variables.cor corr stat prob ‘the group command cor generates the statistics
specified in the subsequent keywords (corr = correlations
stat = significance t-statistics; prob= p-values) the
keyword cov (instead of corr) would generate
4
covariances instead
Correlation
t-Statistic
Probability SALARY ROE ROS SALES
SALARY 1.000000
-----
-----
Alternatively the following code declares a 4x4 matrix object named corrmat, then stores
the correlation matrix in this object
matrix(4,4) corrmat ‘constructs a matrix object named corrmat
corrmat=@cor(@convert(variables)) ‘calculates the correlations using the @cor function; since the
input of this function are column vectors we turn the variables in
the group variables into vectors using @convert
The p-value 0.0895 (8.95%) is smaller than the significance level 10% so Ho is rejected, and we
conclude that salary and roe are significantly positively correlated.
By contrast the p-value 0.6234 (62.34%) of salary and ros is larger than the significance level 10%, so
we cannot reject Ho and conclude that salary and roe are no significantly related.
variables.distplot hist
About 40 of the 209 firms have achieved roe larger than 15% and smaller than 17% (that is,
40/209=19% of the firms).
5
The histogram of roe shows that the distribution is right-skewed, that is, there are various firms with
very large roe.
Now we plot for the variable salary the empirical distribution alongside the Normal and
Student’s t theoretical distribution:
salary.distplot kernel theory(dist=norm)
salary.distplot kernel theory(dist=tdist)
6
Unsurprisingly, the Student’s t distribution provides a better approximation to the true probability
distribution of the random variable salary (the right graph shows a theoretical distribution that lies
closer to the empirical distribution) because, as shown earlier, the kurtosis of salary at K=60.54 is
well in excess of 3, which implies much thicker tails than those of the Normal distribution.
A scatterplot graph plots the observations of one variable against another. In the case of salary and
roe, the first point in the scatterplot is the salary of the CEO in firm number one in the sample against
the roe for firm number, the second point pertains for firm number two, and so on.
Using the group object variables that contains salary roe ros sales, we can use this code:
variables.scat(m) ‘displays the same scatterplots in multiple frames (roe versus salary,
ros versus salary, sales versus salary)
variables.scat(m) linefit ‘displays the same scatterplots in multiple frames alongside the
OLS regression line
scat(m) salary roe ros sales ‘displays the same scatterplots as the first command above but this
code does not allow adding the OLS regression line
7
The scatterplot and regression line for salary vs roe is positively sloped which suggests a positive
relation between salary and roe; that is, firms with higher roe pay higher salaries to their CEO.
However, the suggested relationship might not be statistically significant. The graph for salary versus
ros suggests instead a negative relationship. The scatterplot does not tell us whether the relationship is
statistically significant or not, we need to conduct a formal test for that.
equation model1.ls salary c roe ‘estimates a linear regression of salary on roe with
an intercept, and creates an equation object called
model1 where all the estimation output is stored; the
intercept is saved in C(1) and the slope in C(2)
OR
Hint: create two scalar objects to store each of the two predictions.
9
model3.cinterval 0.95 ‘obtain 95% confidence intervals for the model parameters
model5.wald c(2)=c(3) ‘conducts a test for the null hypothesis specified using exact tests (t-
test/F-test) and asymptotic tests (Wald test)