## Residuals and predicted/fitted values of logit do not coincide

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

tho_mi
Posts: 61
Joined: Sat May 12, 2012 2:41 am

### Residuals and predicted/fitted values of logit do not coincide

Hey,

I calculate residuals and predicted/fitted values from a logit equation. I saw that the observations do not coincide, i.e. some observations have NA as residual, but a non-NA predicted value. What's the reason behind this behaviour? Shouldn't be both values either NA or non-NA?

My question kinda has to do with this thread where Glenn wrote some code for AUROC and used the residuals to find "valid observations":
http://forums.eviews.com/viewtopic.php?t=10614

In what sense are these observations "valid"?

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 11981
Joined: Tue Sep 16, 2008 5:38 pm

### Re: Residuals and predicted/fitted values of logit do not coincide

Could you provide an example?

tho_mi
Posts: 61
Joined: Sat May 12, 2012 2:41 am

### Re: Residuals and predicted/fitted values of logit do not coincide

Workfile attached. Thanks, I just found out where the problem lies (and that I forgot some things, but these are not related to the example).

I have an additional variable that indicates the "valid" observations and only these are used to estimate the model. The fitted values are calculated for all observations (that are "complete"), while the residuals are only calculated for the "valid" observations (= subsample specified in the equation).

The workfile consists of the following variables:
- binary_indicator: Dependent variable
- indep1/indep2: Two independent variables
- sample_indicator: Indicator for the subsample to be used

The model logit_model is based on these variables and fitted values and residuals are estimated using:
logit_model.forecast _xxf
logit_model.makeresid _xxr

Can you confirm my "suspicion"?
Attachments
logit_example.wf1

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 11981
Joined: Tue Sep 16, 2008 5:38 pm

### Re: Residuals and predicted/fitted values of logit do not coincide

When you perform the forecast, it will forecast all observations in the sample you tell it to forecast over. If the forecast cannot be computed due to missing data in the regressors, the forecast will have an NA for that observation.

When you produce the residuals, the residuals will be produced for all observations in the estimation sample (which may or may not be the same sample you decided to forecast over). If the residuals cannot be computed due to missing data in the regressors or the dependent variable, the residuals will have an NA for that observation.

tho_mi
Posts: 61
Joined: Sat May 12, 2012 2:41 am

### Re: Residuals and predicted/fitted values of logit do not coincide

So one has to subsample the valid observations first. Thanks!