last day (15 days later) » 

6:56 PM
0
Q: How to calculate bias when true population mean is unknown?

Dan WI'm working on a problem with a simulation that calculated a linear regression coefficient from some randomly generated data, which was performed 100 times. In other words, I've got 100 randomly generated $\hat\beta$ values. I'm being asked to compute the bias of the average of my estimates, i.e....

 
How did you randomly generate data without knowing $\beta$? It would be interesting to learn how you accomplished that.
 
@whuber - the code generates a set of random numbers, then randomly assigns some of them to be "NA". The assignment gave me a batch of code and told me to run it and interpret the results. I don't think the intent here is to modify the code so that I can record the values of the numbers prior to the random assignments of NA.
 
Please provide the details, because the code must contain all the information you need. And how do you deal with the NA values in your linear regression?
 
@whuber I will pass, since the correct approach here is not to modify the code. It should be enough to know that the data was generated with a random number generation function in R, that NA values were also independently generated and injected into the datasets, and imputation was then used to fill in these NA slots. It's a simulation problem that evaluates the effectiveness of the imputation process.
 
I am not suggesting modifying the code. I am suggesting that you look at it. Only then will you (or anyone else) be able to answer your question. At the very minimum, if you hope to get useful help you will need to explain what that code is trying to do.
 
6:56 PM
I have looked at the code and understand completely what it is doing. It is generating data and then being modified. Posting it here for you to see it for yourself won't change that.
Here is the code that generates predictor variables X1 through X5 and dependent variable Y:
X_123 <- rmvnorm(n, mean = rep(0, 3),
sigma = matrix(c(1, 0.6, 0.36, 0.6, 1, 0.6, 0.36, 0.6, 1),
nrow = 3, ncol = 3))
X1 <- X_123[, 1]
X2 <- X_123[, 2]
X3 <- X_123[, 3]
X4 <- rbinom(n, 1, expit(0.5*X1 + 0.5*X2 - 0.5*X3))
X5 <- rbinom(n, 1, expit(0.5*X1 - 0.5*X2 + 0.5*X3 - 0.5*X4))
Y <- 2 + X1 + X2 + X3 + 2*X4 + 2*X5 + rnorm(n, mean = 0, sd = 3)
# Add in some missing data
X1_obs <- rbinom(n, 1, expit(1 + 0.25*X2 + 0.25*X3 + 0.125*X4 + 0.125*X5))
X4_obs <- rbinom(n, 1, expit(1 + 0.25*X1 + 0.25*X2 + 0.25*X3 + 0.125*X5))
so all that's going on here is that the values are being randomly generated, and X1 and X4 will have missing values that will be put back with imputation. Again, this is a simulation assignment, so the purpose of doing this is simply to evaluate how well the imputation works. I can fit a regression and estimate beta after the imputation, but that still leaves me hanging on evaluating the true value of beta in order to calculate bias.
 
7:41 PM
Please post that code into your original question and include comments about this being an imputation problem.
 
It isn't necessary. Whatever it is that you think I can figure out from this code, you should be able to tell me, but you have yet to explain to me why I actually need to list the code in order to get an answer to the question. I posted it only to try and understand what you were getting at.
 
7:58 PM
That information is critical, and for the question to have future value, the question should contain such information.
In particular...you're supposed to calculate the bias of what?
 
Why? Why is it critical?
 
Because your question seems to be about imputation, but coefficient estimation
*not
 
Okay, and how does the code showing how the data is generated relate to coefficient estimation, beyond what I have already said?
 
8:13 PM
Including the code can help with answering specific questions, and it's also a courtesy to the professional statisticians on here who are giving free consultation time.
More important, however, is that you're doing an imputation problem. Please include that information in the problem, as that starts to get at what your beta is.
 
I already stated that my beta was formed from randomly generated data. The code is not needed to prove that point.
 
Where in the code is your beta generated?
 
Sorry, I mean that the beta is generated from a linear regression on Y dependent on X1 through X5. I stated this earlier.
You don't need to see the code of lm(Y ~ X1 + ... + X5) to prove this point, you can take my word on it, yeah?
 
So you have the estimated coefficients
From summary(lm(...)), right?
 
Correct
 
8:21 PM
So what do you want to calculate?
 
The difference between the estimated coefficient and the true coefficient, which, by definition, is the bias of the estimated coefficient.
 
Not quite
Bias is the expected value of that difference
 
Alright, and how would I go about finding the expected value of that difference?
 
But you already know the bias to be zero. Under decent conditions (which your simulation sure seems to satisfy), the Gauss-Markov theorem gives the coefficients are unbiased.
(Gauss-Markov gives us more than just unbiasedness, yes.)
 
No, the bias cannot be zero, I'm being asked a question to calculate this bias for each of the 5 different methods used to impute data, so it is highly unlikely I am just comparing five zeros to each other.
 
8:24 PM
So you're supposed to calculate the bias of the coefficient estimates or the imputation methods?
 
Calculate the bias of the coefficient estimates obtained with five different imputation methods.
 
So you would subtract the true value from the estimate and average this over many iterations, right?
 
right
 
What's stopping you from doing that?
 
Not knowing the true value
 
8:30 PM
But you have the true values.
 
Where?
 
In your code
 
My code erases some of the data and replaces it with NA. The true values are erased.
And as I said before, I do not think the intent is to modify my code and extract values from it in order to do this. I am explicitly told that, in a simulation, we can't "cheat" and allow ourselves to pull out a true population mean like this.
 
I do not have to modify the code to extract the true values.
They're given in the code.
The true values generate Y, right?
 
they don't "generate" Y, the Y data simply exists
i'm talking about the true value of the beta coefficient giving us Y
 
8:40 PM
You have to create Y somehow
You've chosen to create Y by calculating 2 + X1 + X2 + X3 + 2*X4 + 2*X5 + rnorm(n, mean = 0, sd = 3).
 
Y <- 2 + X1 + X2 + X3 + 2*X4 + 2*X5 + rnorm(n, mean = 0, sd = 3)
 
So that says what the true values are.
 
The true value of Y isn't the true value of the coefficients for X1 through X5
 
The true relationship is to have an intercept of 2, an X1 coefficient of 1, an X2 coefficient of 1, etc.
That is the model of the expected value. Then we add some noise.
 
Ah okay
So basically, you're just saying the true values come from Y <- 2 + X1 + X2 + X3 + 2*X4 + 2*X5 + rnorm(n, mean = 0, sd = 3)
 

last day (15 days later) »