The following analysis requires the following packages to be loaded:

Exercise 1

rm(list = ls())
library(tidyverse) 
library(car)  
library(quantreg)  
library(ggplot2)  
library(dplyr)  
library(MASS)  
library(lmtest)  
library(sandwich)  
library(quantreg)

Step 1: Loading the dataset

df <- read.csv("~/Desktop/FAU /Semester 5/EMPIRICAL ECONOMICS/Exercise/Homework Assignment/5/rdchem.csv", stringsAsFactors = FALSE)
print(df)
##        rd   sales profits   rdintens     profmarg
## 1     1.7    42.0     8.0 0.04047619  0.190476190
## 2     2.5    93.9     0.9 0.02662407  0.009584664
## 3     3.0   292.2     6.4 0.01026694  0.021902805
## 4     3.5   133.6    -4.3 0.02619760 -0.032185629
## 5     3.7   150.0    32.6 0.02466667  0.217333320
## 6     6.1   502.2    18.4 0.01214655  0.036638789
## 7     8.4   390.0    47.3 0.02153846  0.121282050
## 8    10.4   201.5    23.0 0.05161290  0.114143920
## 9    11.0   906.6   154.8 0.01213325  0.170747860
## 10   15.6   921.6     4.1 0.01692708  0.004448784
## 11   19.4   509.7    83.8 0.03806160  0.164410440
## 12   20.3  1124.8    45.3 0.01804765  0.040273823
## 13   23.5   596.8   107.4 0.03937668  0.179959790
## 14   26.0  1631.5   105.8 0.01593625  0.064848304
## 15   29.2  1066.3   289.9 0.02738441  0.271874700
## 16   39.9   907.9    77.4 0.04394757  0.085251682
## 17   45.3  2936.5    93.7 0.01542653  0.031908736
## 18   45.3  1212.3   215.0 0.03736699  0.177348840
## 19   48.9  2617.8    60.5 0.01867981  0.023111008
## 20   59.0  2830.0   467.0 0.02084806  0.165017660
## 21   65.2  2513.8   355.4 0.02593683  0.141379580
## 22   66.0  2592.0   116.0 0.02546296  0.044753086
## 23   74.0  2432.6   132.4 0.03042012  0.054427356
## 24   74.4  1452.7   271.2 0.05121498  0.186686870
## 25   92.2  3199.9   163.2 0.02881340  0.051001593
## 26  147.5  6754.0   329.0 0.02183891  0.048711874
## 27  178.2  2824.0   313.0 0.06310198  0.110835690
## 28  191.0  7621.0   626.0 0.02506233  0.082141452
## 29  430.6  4570.2   186.9 0.09421907  0.040895361
## 30  612.0  8995.0   809.0 0.06803780  0.089938857
## 31 1136.0 19773.0  2563.0 0.05745208  0.129621210
## 32 1428.0 39709.0  4154.0 0.03596162  0.104611050

Extracting the list strings from the row column.The data is in a column “data” as a string representation of a list. Let’s inspect the first row:

print(df$data[1])
## NULL

It looks like the data is already in the correct format.Let’s examine the first few rows of the dataframe

head(df)
##    rd sales profits   rdintens     profmarg
## 1 1.7  42.0     8.0 0.04047619  0.190476190
## 2 2.5  93.9     0.9 0.02662407  0.009584664
## 3 3.0 292.2     6.4 0.01026694  0.021902805
## 4 3.5 133.6    -4.3 0.02619760 -0.032185629
## 5 3.7 150.0    32.6 0.02466667  0.217333320
## 6 6.1 502.2    18.4 0.01214655  0.036638789
str(df)
## 'data.frame':    32 obs. of  5 variables:
##  $ rd      : num  1.7 2.5 3 3.5 3.7 ...
##  $ sales   : num  42 93.9 292.2 133.6 150 ...
##  $ profits : num  8 0.9 6.4 -4.3 32.6 ...
##  $ rdintens: num  0.0405 0.0266 0.0103 0.0262 0.0247 ...
##  $ profmarg: num  0.19048 0.00958 0.0219 -0.03219 0.21733 ...

Let’s generate a summary of the key variables

desc_stats <- summary(df)
print(desc_stats)
##        rd              sales            profits           rdintens      
##  Min.   :   1.70   Min.   :   42.0   Min.   :  -4.30   Min.   :0.01027  
##  1st Qu.:  10.85   1st Qu.:  507.8   1st Qu.:  42.12   1st Qu.:0.02031  
##  Median :  42.60   Median : 1332.5   Median : 111.70   Median :0.02641  
##  Mean   : 153.68   Mean   : 3797.0   Mean   : 370.50   Mean   :0.03266  
##  3rd Qu.:  78.85   3rd Qu.: 2856.6   3rd Qu.: 295.68   3rd Qu.:0.03965  
##  Max.   :1428.00   Max.   :39709.0   Max.   :4154.00   Max.   :0.09422  
##     profmarg       
##  Min.   :-0.03219  
##  1st Qu.: 0.04074  
##  Median : 0.08760  
##  Mean   : 0.09823  
##  3rd Qu.: 0.16456  
##  Max.   : 0.27187

This output summarizes the research and development expenditures (rd), company sales (sales), and profits (profits) for 32 companies in the dataset from 1998.

Checking for missing values using an if-else statement

missing_vals <- sapply(df, function(x) sum(is.na(x)))

if(any(missing_vals > 0)){
  print('There are missing values in the dataset:')
  print(missing_vals)
} else {
  print('No missing values found in the dataset.')
}
## [1] "No missing values found in the dataset."

Interpretation

The variable \(\textbf{rd}\) (research and development expenditure in millions) has a minimum value of 1.70 and a maximum of 1428.00, with a mean of approximately 153.68. The spread indicates that while most companies invest modestly, some companies spend much more on R&D.

The variable \(\textbf{sales}\) shows a minimum of 42.0 and goes up to 39,709.0, with a median and quartiles suggesting that a few companies dominate in sales compared to the median levels.

The \(\textbf{profits}\) range from -4.30 (indicating a company with a loss) to 4154.00. The quartile breakdown indicates that while most companies are profitable, there are significant variations.

For \(\textbf{rdintens}\) and \(\textbf{profmarg}\), the summary statistics give an idea of the intensity of R&D relative to sales and profit margins, respectively. The values show moderate central tendencies and a controlled spread in general.

No missing values were found across any of the variables.

Exercise 2

Now I will create new variables:

df$rdintens_new <- with(df, (rd / sales) * 100)
df$profmarg_new <- with(df, (profits / sales) * 100)
df$sales_billion <- with(df, sales / 1000)

Printing the summary of new variables

print(summary(df[c('rdintens_new', 'profmarg_new', 'sales_billion')]))
##   rdintens_new    profmarg_new    sales_billion    
##  Min.   :1.027   Min.   :-3.219   Min.   : 0.0420  
##  1st Qu.:2.031   1st Qu.: 4.074   1st Qu.: 0.5078  
##  Median :2.641   Median : 8.760   Median : 1.3325  
##  Mean   :3.266   Mean   : 9.823   Mean   : 3.7970  
##  3rd Qu.:3.965   3rd Qu.:16.456   3rd Qu.: 2.8566  
##  Max.   :9.422   Max.   :27.187   Max.   :39.7090

Interpretation of New Variables

The new variables have been successfully created:

The data now includes both the original variables and the newly created ones, providing more ways to analyze the relationship between R&D expenditure, sales, and profitability.

Exercise 3

Scatterplots: Relationships between R&D Intensity, Sales, and Profit Margin

The scatterplots below illustrate the relationships between R&D intensity and sales, as well as R&D intensity and profit margin.

library(ggplot2)
p1 <- ggplot(df, aes(x = sales_billion, y = rdintens_new)) + 
  geom_point(color = 'blue', size = 3) + 
  labs(x = 'Sales (Billion $)', y = 'R&D Intensity (%)', title = 'R&D Intensity vs Sales') +
  theme_minimal()

# Scatterplot for rdintens_new vs profmarg_new
p2 <- ggplot(df, aes(x = rdintens_new, y = profmarg_new)) + 
  geom_point(color = 'darkgreen', size = 3) + 
  labs(x = 'R&D Intensity (%)', y = 'Profit Margin (%)', title = 'R&D Intensity vs Profit Margin') +
  theme_minimal()

# Plot both plots in one graphic using gridExtra
library(gridExtra)
grid.arrange(p1, p2, ncol=2)

Interpretation of Scatterplots

R&D Intensity vs Sales (Left Plot) - There appears to be a negative relationship between R&D intensity and company size (measured by sales). - Smaller companies (with lower sales) tend to have higher R&D intensity percentages. - Larger companies (with higher sales in billions) generally allocate a smaller percentage of their revenue to R&D. - This suggests that while larger companies may spend more on R&D in absolute terms, they dedicate a smaller fraction of their revenue to R&D compared to smaller companies.

R&D Intensity vs Profit Margin (Right Plot) - The relationship between R&D intensity and profit margin is less clear. - There is considerable scatter in the data, indicating that high R&D intensity does not necessarily translate to higher or lower profit margins. - Some companies with moderate R&D intensity have high profit margins, while others with similar R&D intensity have lower profit margins. - These visualizations help us understand how R&D investment strategies vary based on company size and how they may or may not relate to profitability in the chemical industry.

Exercise 4

Estimating the Regression Model

We estimate the following model using ordinary least squares (OLS):

\[ \text{rdintens_new} = \beta_0 + \beta_1 \cdot \text{sales_billion} + \beta_2 \cdot \text{profmarg_new} + u \]

The estimated model is obtained as follows:

model <- lm(rdintens_new ~ sales_billion + profmarg_new, data = df)

summary(model)
## 
## Call:
## lm(formula = rdintens_new ~ sales_billion + profmarg_new, data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.2221 -1.1414 -0.6068  0.5008  6.3702 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    2.62526    0.58553   4.484 0.000106 ***
## sales_billion  0.05338    0.04407   1.211 0.235638    
## profmarg_new   0.04462    0.04618   0.966 0.341966    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.862 on 29 degrees of freedom
## Multiple R-squared:  0.07612,    Adjusted R-squared:  0.0124 
## F-statistic: 1.195 on 2 and 29 DF,  p-value: 0.3173

Statistical and Economic Interpretation

Statistical Interpretation

Model Fit:
The model has a low R-squared value of 0.07612 (adjusted R-squared of 0.0124), indicating that only about 7.6% of the variation in R&D intensity is explained by sales and profit margin. This suggests that other factors not included in the model likely influence R&D intensity decisions.

Coefficients:

Overall Model Significance:
The F-statistic is 1.195 with a \(p\)-value of 0.3173, indicating that the model as a whole is not statistically significant at conventional levels (e.g., 0.05).

Economic Interpretation

Conclusion

In summary, this model suggests that neither company size (measured by sales) nor profitability (measured by profit margin) has a statistically significant impact on R&D intensity in this sample of chemical companies. The decisions about what percentage of revenue to invest in R&D appear to be driven by factors other than these two variables.

Exercise 5

Examining the Evidence: Outliers in Sales

Based on the analysis, there are indeed outliers in the sales data that appear to be influencing the relationship between sales and R&D intensity. Let’s examine the evidence:

Boxplot of Sales

First, let’s look at the boxplot of sales_billion to visualize the distribution and identify the presence of any outliers.

boxplot(df$sales_billion, main="Boxplot of Sales (Billion $)", ylab="Sales (Billion $)")

The boxplot clearly shows several outliers in the sales data, with some companies having significantly higher sales than the majority.

Let’s also look at a histogram: The histogram further illustrates this skewed distribution:

hist(df$sales_billion, breaks=10, main="Histogram of Sales (Billion $)", 
     xlab="Sales (Billion $)", col="lightblue")

Most companies have sales below 5 billion dollars, with only a few companies having much higher sales.

Here are the identified outliers:

Let’s identify potential outliers in sales. A common rule is to consider values beyond 1.5 * IQR from the quartiles as outliers

Q1 <- quantile(df$sales_billion, 0.25)
Q3 <- quantile(df$sales_billion, 0.75)
IQR <- Q3 - Q1
lower_bound <- Q1 - 1.5 * IQR
upper_bound <- Q3 + 1.5 * IQR

Identifying the outliers:

outliers <- df[df$sales_billion < lower_bound | df$sales_billion > upper_bound, ]

Potential outliers in sales_billion:

print(outliers[, c("sales_billion", "rdintens_new")])
##    sales_billion rdintens_new
## 26         6.754     2.183891
## 28         7.621     2.506233
## 30         8.995     6.803780
## 31        19.773     5.745208
## 32        39.709     3.596162

These five companies have sales ranging from 6.754 to 39.709 billion dollars, which are significantly higher than the rest of the sample.

The scatterplot with outliers highlighted in red shows how these observations relate to R&D intensity:

plot(df$sales_billion, df$rdintens_new, 
     main="R&D Intensity vs Sales with Outliers Highlighted",
     xlab="Sales (Billion $)", ylab="R&D Intensity (%)",
     pch=19, col="blue")

# Highlight outliers in red
points(outliers$sales_billion, outliers$rdintens_new, col="red", pch=19)

#Adding a legend
if(nrow(outliers) > 0) {
  legend("topright", legend=c("Regular observations", "Outliers"), 
         col=c("blue", "red"), pch=19)
}

# Let's also run the regression model without the outliers to see if the results change
if(nrow(outliers) > 0) {
  df_no_outliers <- df[!(df$sales_billion < lower_bound | df$sales_billion > upper_bound), ]
  model_no_outliers <- lm(rdintens_new ~ sales_billion + profmarg_new, data = df_no_outliers)
  print("Regression model without outliers:")
  print(summary(model_no_outliers))
}
## [1] "Regression model without outliers:"
## 
## Call:
## lm(formula = rdintens_new ~ sales_billion + profmarg_new, data = df_no_outliers)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.2258 -1.0610 -0.5258  0.9706  4.7642 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)  
## (Intercept)    1.67567    0.73354   2.284   0.0315 *
## sales_billion  0.60199    0.28376   2.121   0.0444 *
## profmarg_new   0.05644    0.04422   1.276   0.2141  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.729 on 24 degrees of freedom
## Multiple R-squared:  0.1805, Adjusted R-squared:  0.1122 
## F-statistic: 2.643 on 2 and 24 DF,  p-value: 0.09173

Key Findings After Removing Outliers

Statistical Changes:

Conclusion:

Circumstances Under Which Individual Observations Have a Large Influence on OLS Coefficients

Individual observations can have a large influence on the OLS coefficients when they exhibit both:

High Leverage

Observations with extreme or unusual predictor values (i.e., values far from the mean of the explanatory variables) can disproportionately pull the fitted regression line. Formally, the leverage of an observation is given by the diagonal elements of the hat matrix:

\[ h_{ii} = \mathbf{x}_i^T (\mathbf{X}^T\mathbf{X})^{-1} \mathbf{x}_i \]

An observation with a high $ h_{ii} $ value is far from the centroid of the predictor space and has the potential to significantly influence the regression coefficients.

Large Residuals (Outliers)

When an observation’s actual response value deviates substantially from the predicted value, it contributes a large residual:

\[ e_i = y_i - \hat{y}_i \]

If this observation also has high leverage, it can disproportionately affect the coefficient estimates.

Influence Combined

The combined effect of leverage and residual size determines the observation’s influence on the estimated coefficients. A common measure that captures this is Cook’s distance:

\[ D_i = \frac{e_i^2}{p \cdot MSE} \frac{h_{ii}}{(1 - h_{ii})^2} \]

where $ p $ is the number of parameters in the model and $ MSE $ is the mean squared error. High values of Cook’s distance indicate observations that are highly influential.

Summary

In conclusion, individual observations can have a large impact on OLS estimates if they: 1. Are outliers in the response variable, 2. Have unusual predictor values (high leverage), or 3. Exhibit both characteristics simultaneously (high leverage & large residuals).

Checking graphically whether you find evidence for such influential outliers and explaining.

Let’s run the diagnostic plots correctly:

Refitting the original mode:

library(car)
model <- lm(rdintens_new ~ sales_billion + profmarg_new, data = df)
  1. Leverage plots for each predictor

The leverage plots for sales_billion and profmarg_new show that some observations have considerably higher leverage. These points correspond to extreme predictor values:

leveragePlot(model, term.name = "sales_billion")

## [1] 29 30 32 31
leveragePlot(model, term.name = "profmarg_new")

## [1] 29 30 15  4
  1. Cook’s distance plot:

Indicates that a few observations (those with Cook’s distance far beyond the threshold of 4/n) are exerting a large influence on the OLS estimates.

plot(model, which = 4, main = "Cook's Distance Plot")

  1. Added variable plots

The influence plot which overlays influence measures (leverage and studentized residuals), clearly identifies a couple of points with significantly larger Cook’s distance and leverage. These are also detailed in the printed output.

avPlots(model)

  1. Influence plot - combines leverage and studentized residuals
influencePlot(model, id.method = "identify", main = "Influence Plot")

##       StudRes        Hat      CookD
## 15 -0.6974242 0.22063130 0.04672587
## 29  4.5550338 0.05178072 0.22467745
## 30  1.8926444 0.04678718 0.05381592
## 32 -1.8180393 0.75418395 3.13135929
  1. Let’s identify the most influential observations

Get Cook’s distances

cooks_d <- cooks.distance(model)
influential <- cooks_d > (4/nrow(df))  # A common threshold is 4/n

# Print the influential observations
print("Influential observations based on Cook's distance:")
## [1] "Influential observations based on Cook's distance:"
print(df[influential, c("sales_billion", "rdintens_new", "profmarg_new")])
##    sales_billion rdintens_new profmarg_new
## 29        4.5702     9.421907     4.089536
## 32       39.7090     3.596162    10.461105
# Let's also get the actual values of leverage and Cook's distance
influential_data <- data.frame(
  Observation = which(influential),
  Sales = df$sales_billion[influential],
  RD_Intensity = df$rdintens_new[influential],
  Profit_Margin = df$profmarg_new[influential],
  Leverage = hatvalues(model)[influential],
  Cooks_Distance = cooks_d[influential]
)
print(influential_data[order(influential_data$Cooks_Distance, decreasing = TRUE), ])
##    Observation   Sales RD_Intensity Profit_Margin   Leverage Cooks_Distance
## 32          32 39.7090     3.596162     10.461105 0.75418395      3.1313593
## 29          29  4.5702     9.421907      4.089536 0.05178072      0.2246774

Influence of Observations

Notable Observations

For example, the observations with Cook’s distances of 3.1314 and 0.2247 are flagged as influential.

Interpretation

Overall, these plots and the numerical summary of influential observations confirm that certain companies—especially those with very high sales—are driving the results. These companies have both high leverage and large residuals, meaning they exert a disproportionate influence on the model.

Implications

This underscores the fact that individual extreme observations can meaningfully alter the estimated coefficients in the OLS model. Such observations should be carefully examined or treated in any substantive analysis.

#Exercise 6

Least Absolute Deviation (LAD) Estimation

Least Absolute Deviation (LAD) estimation, also known as L1 regression or median regression, is an alternative to Ordinary Least Squares (OLS) that minimizes the sum of the absolute values of the residuals rather than the sum of squared residuals.

How LAD Works

  1. Objective Function:

    • OLS minimizes: \[ \sum_{i=1}^n (y_i - \hat{y}_i)^2 \]
    • LAD minimizes: \[ \sum_{i=1}^n |y_i - \hat{y}_i| \]
  2. Estimation Process:

    LAD finds the regression line that minimizes the sum of absolute deviations between observed and predicted values. This typically requires numerical optimization methods since there’s no closed-form solution like in OLS.

  3. Central Tendency:

    While OLS estimates conditional means, LAD estimates conditional medians. This is why LAD is also called median regression.

Why LAD is Useful for Handling Outliers

  1. Robustness:

    LAD is less sensitive to outliers because it penalizes deviations linearly rather than quadratically. In OLS, squaring the residuals amplifies the influence of large deviations, making the estimates highly sensitive to outliers.

  2. Resistance to Extreme Values:

    Since LAD focuses on the median (which is resistant to extreme values) rather than the mean (which is pulled by extreme values), it produces more stable estimates when the data contains outliers.

  3. Breakdown Point:

    LAD has a higher breakdown point than OLS, meaning it can handle a larger proportion of contaminated data before producing meaningless results.

  4. Preservation of Direction:

    While OLS might significantly shift the regression line to accommodate outliers, LAD maintains a more consistent direction that better represents the majority of the data.

Application to the Chemical Industry Dataset

In our chemical industry dataset, where we’ve identified influential outliers in sales that significantly affect the OLS estimates, LAD would likely provide more stable and representative estimates of the relationship between R&D intensity, sales, and profit margins by reducing the disproportionate influence of the largest companies.

Exercise 7

Estimating the LAD (quantile regression for the median) model

library(quantreg)
lad_model <- rq(rdintens_new ~ sales_billion + profmarg_new, data = df, tau = 0.5)

Let’s get more detailed information about the LAD model and compare it with the OLS model

Re-running the OLS model for comparison

ols_model <- lm(rdintens_new ~ sales_billion + profmarg_new, data = df)
summary_ols <- summary(ols_model)

Printing OLS results for comparison

print(summary_ols)
## 
## Call:
## lm(formula = rdintens_new ~ sales_billion + profmarg_new, data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.2221 -1.1414 -0.6068  0.5008  6.3702 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    2.62526    0.58553   4.484 0.000106 ***
## sales_billion  0.05338    0.04407   1.211 0.235638    
## profmarg_new   0.04462    0.04618   0.966 0.341966    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.862 on 29 degrees of freedom
## Multiple R-squared:  0.07612,    Adjusted R-squared:  0.0124 
## F-statistic: 1.195 on 2 and 29 DF,  p-value: 0.3173

Printing LAD results

print(summary(lad_model))
## 
## Call: rq(formula = rdintens_new ~ sales_billion + profmarg_new, tau = 0.5, 
##     data = df)
## 
## tau: [1] 0.5
## 
## Coefficients:
##               coefficients lower bd upper bd
## (Intercept)    1.62309      1.34386  2.66171
## sales_billion  0.01863     -0.11496  0.55193
## profmarg_new   0.11790     -0.00002  0.13495

Interpretation of the LAD Model

Intercept (β₀) The LAD model estimates an intercept of 1.62309, which is lower than the OLS estimate of 2.62526. This represents the median R&D intensity when both sales and profit margin are zero.

Sales Coefficient (β₁) The LAD estimate for the effect of sales is 0.01863, which is smaller than the OLS estimate of 0.05338. This suggests that for each additional billion dollars in sales, the median R&D intensity increases by about 0.019 percentage points, holding profit margin constant. The confidence interval (-0.11496 to 0.55193) includes zero, indicating that this effect is not statistically significant.

Profit Margin Coefficient (β₂) The LAD estimate for the effect of profit margin is 0.11790, which is substantially larger than the OLS estimate of 0.04462. This suggests that for each additional percentage point in profit margin, the median R&D intensity increases by about 0.118 percentage points, holding sales constant. The confidence interval (-0.00002 to 0.13495) just barely includes zero, suggesting this effect is marginally significant.

Let’s visualize the difference between OLS and LAD fits. Create a scatter plot with both regression lines

Comparison of OLS and LAD Results:

The visual comparison of OLS and LAD regression lines shows how they differ:

plot(df$sales_billion, df$rdintens_new, 
     main="OLS vs LAD Regression Lines",
     xlab="Sales (Billion $)", ylab="R&D Intensity (%)",
     pch=19, col="blue")

# Add OLS regression line
abline(ols_model, col="red", lwd=2)

# Add LAD regression line
abline(lad_model, col="green", lwd=2)

# Add a legend
legend("topright", legend=c("Data Points", "OLS Regression", "LAD Regression"), 
       col=c("blue", "red", "green"), pch=c(19, NA, NA), lty=c(NA, 1, 1), lwd=c(NA, 2, 2))

# Let's also create a similar plot for profmarg_new
# Create a new data frame with a range of profmarg_new values and mean sales_billion
prof_range <- seq(min(df$profmarg_new), max(df$profmarg_new), length.out=100)
mean_sales <- mean(df$sales_billion)
new_data <- data.frame(sales_billion=rep(mean_sales, 100), profmarg_new=prof_range)

# Predict using both models
ols_pred <- predict(ols_model, newdata=new_data)
lad_pred <- predict(lad_model, newdata=new_data)

# Plot
plot(df$profmarg_new, df$rdintens_new, 
     main="OLS vs LAD: Effect of Profit Margin on R&D Intensity",
     xlab="Profit Margin (%)", ylab="R&D Intensity (%)",
     pch=19, col="blue")

# Add lines
lines(prof_range, ols_pred, col="red", lwd=2)
lines(prof_range, lad_pred, col="green", lwd=2)

# Add a legend
legend("topright", legend=c("Data Points", "OLS Regression", "LAD Regression"), 
       col=c("blue", "red", "green"), pch=c(19, NA, NA), lty=c(NA, 1, 1), lwd=c(NA, 2, 2))

Key Differences and Implications

Robustness to Outliers The LAD regression line is less influenced by the outliers we identified earlier. This is evident in the different slopes of the regression lines, particularly in the sales plot.

Coefficient Magnitudes

The LAD model gives a smaller coefficient for sales but a larger coefficient for profit margin compared to OLS. This suggests that when we reduce the influence of outliers, the relationship between sales and R&D intensity weakens, while the relationship between profit margin and R&D intensity strengthens.

Economic Interpretation

The LAD results suggest that profit margin may be a more important determinant of R&D intensity than sales when we focus on the typical (median) firm rather than being influenced by extreme cases. This makes economic sense: firms with higher profit margins may have more resources available to invest in R&D regardless of their size.

Practical Implications

For policymakers or industry analysts interested in understanding R&D investment patterns in the chemical industry, the LAD results provide a more robust picture of how the typical firm behaves, rather than being skewed by a few very large companies.

Summary

The LAD estimation provides a more robust analysis that is less affected by outliers. It suggests that profit margin may have a stronger relationship with R&D intensity than was apparent in the OLS model, while the effect of sales appears to be weaker when we reduce the influence of outlier observations.

Exercise 8

Unbiased and Consistent Estimates under Classical Measurement Error

Classical Measurement Error in the Dependent Variable

If the measurement error in R&D expenditure (or in this case, rdintens) is random, has a mean of zero, and is uncorrelated with both the true value and the regressors (sales and profit margin), then:

Thus, for unbiased estimation, the measurement errors in rdintens must be classical—uncorrelated with both the true values and the regressors, and with a zero conditional mean.

Consequences of Classical Measurement Error

  1. Increased Standard Errors:
    • Measurement error inflates the variance of the error term.
    • This leads to larger standard errors for coefficient estimates, making statistical significance harder to detect.
  2. Reduced Statistical Power:
    • The increase in variance reduces the power of hypothesis tests.
    • This raises the likelihood of Type II errors, where true relationships are not detected.
  3. Lower R-squared:
    • Additional noise in rdintens lowers the proportion of explained variance.
    • The model may appear to fit worse than it actually does.
  4. Inefficient Estimates:
    • OLS estimates remain unbiased but are no longer the most efficient.
    • Alternative estimation methods may provide lower variance.
  5. Misleading Predictions:
    • Predictions based on the model will have larger prediction errors.
    • This reduces the reliability of forecasts for R&D intensity.
  6. Difficulty in Model Selection:
    • The added noise complicates correct model specification.
    • Incorrect inclusion or exclusion of variables may occur.
  7. Attenuation Bias in Related Analyses:
    • If the measured rdintens is later used as an explanatory variable in another regression, it can cause attenuation bias.

Summary

While measurement error in the dependent variable does not bias coefficient estimates, it has serious implications for:

These factors must be considered in any substantive analysis to ensure robust and meaningful results.