I want to simulate some data to use for the estimation of the elasticities of the linearized cobb douglas production function. I only have a problem when plotting my results. After adding the line of regression the scatterplot seems to change. I fixed the ranges of the x and y axis so this cannot be a result of changing the scales.
On the left the plot before adding abline, on the right after adding abline
# Set the true values of the parameters and number of simulations
alpha <- 0.7
beta <- 0.3
n <- 1000
# Generate random values for the inputs (capital and labor)
K <- runif(n, min = 1, max = 10)
L <- runif(n, min = 1, max = 10)
Y <- alpha*log(K) + beta*log(L)
# Add some normally distributed noise to the output
epsilon <- rnorm(n, mean = 0, sd = 0.2)
Y <- Y + epsilon
# Fit a linear regression model to the simulated data and plot
model <- lm(Y ~ log(K) + log(L)+0)
plot(Y ~ log(K) + log(L), main = "Simulated Data and Regression Line",
xlab = "log(K)", ylab = "log(L)", pch = 20, col = Y, xlim = range(0,2.5), ylim = range(0.5,2.5))
abline(model, col = "blue")
summary(model)