Hi All,
I have data that looks like the following:
In the above data, I have a regressand y, which I regress on covariates x1 and x2. In the data construction, I need to work with the projections of y on x1 and x2 (as I will be using these fitted values as a regressor for an auxiliary regression). However, the constraint I face is the usual one- the prediction (y hat) is not generated for row 3, where the datapoint for x2 is missing. While I understand why this is reasonable, I still need to obtain data on that fitted value. As such, I would still like to compute the predicted value, despite the missing var3. One way to do this would be to for instance:
This would indeed generate a predicted value, as the product between 0 and beta(hat) is going to be 0. I was wondering if there is any prebuilt command that would calculate the predicted values, even for rows wherein 1 or more regressor value is missing.
Thanks!
Chinmay
I have data that looks like the following:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(y x1 x2) 23 23 42 123 3 324 3 23 . 21 32 32 3 4 3 212 32 2 2 3 32 end
In the above data, I have a regressand y, which I regress on covariates x1 and x2. In the data construction, I need to work with the projections of y on x1 and x2 (as I will be using these fitted values as a regressor for an auxiliary regression). However, the constraint I face is the usual one- the prediction (y hat) is not generated for row 3, where the datapoint for x2 is missing. While I understand why this is reasonable, I still need to obtain data on that fitted value. As such, I would still like to compute the predicted value, despite the missing var3. One way to do this would be to for instance:
Code:
replace x2=0 if missing(x2) predict, xb
Thanks!
Chinmay
Comment