I have a vector A, which comprises predefined revenue values of 1000 companies. Now I want to generate another vector B, which comprises the companies' revenue of the previous year. The intention is to model B by taking A as the expected value and a standard deviation that increases with the size of A: That is, larger companies have larger absolute differences between A and B than smaller companies. The purpose is to achieve a relation so that a linear regression of the predictor B on the dependent variable A would yield a line with a slope of close to 1. Hence, the relation should look as follows:
lm(A~B)$coefficients # should yield
#(Intercept) B
# 0 1
plot(B,A)
abline(lm(A~B)$coefficients, col = "red")`
I tried it as follows:
set.seed(123)
A <- 1:1000
B <- rnorm(n=1000, mean = A, sd=0.4*A)
However, for lm(A~B)
:
Coefficients:
(Intercept) A
197.5979 0.6013
Do you have any idea how I can fix the generation of vector B from A, so that a linear regression of B on A would yield a slope of 1?