Regression Modelling in Practice (Week 4 : Testing a Logistic Regression Model)
The aim of this week is to test a logistic regression model. For my anaysis, I used the same response variable from the previous week, i.e., suicideper100th. My primary regressor was alcconsumption. Since the dataset from GapMinder comprises only quantitative variables, data management had to be done before carrying out the analysis. The following were done:
(i) Since the response variable is quantitative, I first binned it into two categories - low (=0) and high (=1), based on mean.
(ii) The next step was to bin a quantitative predictor variable into categories for which I chose income levels (incomeperperson variable). I binned it into 4 categories based on the quartiles.
(iii) The remaining predictors were centered based on their respective means and the means were checked to verify that the means had shifted close to 0.
NOTE: I have not chosen to bin the quantitative predictors for testing logistic regression and the interpretations for odds ratios have been done accordingly.
For the analysis, the SAS Code I used is as under:
libname mydata "/courses/d1406ae5ba27fe300/" access=readonly;
data new; set mydata.gapminder;
label suicidegroup = "Level of Suicides";
********************************************************************
DATA MANAGEMENT
********************************************************************;
* binning response variable;
if suicideper100th eq . then suicidegroup = .;
else if suicideper100th le 8 then suicidegroup = '0'; /* low */
else suicidegroup = '1'; /* high */
* binning predictor variable incomeperperson into 4 categories;
if incomeperperson eq . then incomegroup = .;
else if incomeperperson le 750 then incomegroup = 0;
else if incomeperperson le 3000 then incomegroup = 1;
else if incomeperperson le 10000 then incomegroup = 2;
else incomegroup = 3;
* centering quantitative predictors;
data new2; set new;
if suicidegroup ne . and internetuserate ne . and alcconsumption ne . and
urbanrate ne . and incomegroup ne .;
internetuserate_c=internetuserate - 34.0510892;
alcconsumption_c=alcconsumption - 6.8731395;
urbanrate_c=urbanrate - 55.2483721;
run;
proc means; var alcconsumption internetuserate urbanrate;
run;
* check means of centered variables;
proc means; var internetuserate_c alcconsumption_c urbanrate_c;
run;
*adding 4 category incomegroup variable with reference group as 0;
PROC GLM;
class incomegroup (ref="0");
model suicidegroup=alcconsumption_c internetuserate_c urbanrate_c incomegroup/solution;
run;
* change reference group to 1;
PROC GLM;
class incomegroup (ref="1");
model suicidegroup=alcconsumption_c internetuserate_c urbanrate_c incomegroup/solution;
run;
***********************************************************************
LOGISTIC REGRESSION
***********************************************************************;
PROC LOGISTIC descending; model suicidegroup=alcconsumption;
run;
PROC LOGISTIC descending; model suicidegroup=internetuserate;
run;
PROC LOGISTIC descending; model suicidegroup=urbanrate; run;
* adding internetuserate and urbanrate;
PROC LOGISTIC descending; model suicidegroup=alcconsumption internetuserate urbanrate;
run;
1) Centering the explanatory variables
The means procedure returned the means of the predictors before and after centering and it was seen that post centering, the means of the regressors shifted very close to 0.
2) Reference Group Coding/Parameterization for incomegroup variable
First the chosen predictor incomeperperson was binned into 4 categories to form a new variable incomegroup with levels 0 - low income, 1 - moderate income, 2 - high income and 3 - very high income.
The GLM procedure was used to examine the explanatory variable differences on the response variable after adjusting for other explanatory variables in the model.
The model predicted that alcconsumption_c and urbanrate_c were the predictors that significantly effected suicide levels. This was further verified on fitting a logistic regression model and observing the fit statistics, as shown later.
First each of the income groups was compared to the reference group = 0 to test whether low income has anything to do with high suicide (suicidegroup=1), after controlling for other predictors in the model. The ‘Estimate’ column in the table below depicts the comparison between a) incomegroup0 and incomegroup1, b) incomegroup0 and incomegroup2, and c) incomegroup0 and incomegroup3. All the three comparisons had non-significant p-values at 5% level of significance indicating that none of the income groups have a significant effect on high suicide levels, in comparison to the low income group (incomegroup=0).
Then income groups were compared to the reference group = 1 to test whether moderate income has anything to do with high suicide (suicidegroup=1), after controlling for other predictors in the model. The ‘Estimate’ column in the table below depicts the comparison between a) incomegroup1 and incomegroup0, b) incomegroup1 and incomegroup2, and c) incomegroup1 and incomegroup3. All the three comparisons had non-significant p-values at 5% level of significance indicating that none of the income groups have a significant effect on high suicide levels, in comparison to the moderate income group (incomegroup=1).
Note:The X'X matrix has been found to be singular, and a generalized inverse was used to solve the normal equations. Terms whose estimates are followed by the letter 'B' are not uniquely estimable.
A) alcconsumption as the only predictor
Alcohol consumption has a significant positive effect on the probability of having a high suicide level (Coeff. = 0.1542 and p-value < 0.05), when it is the only predictor being fitted.
The odds ratio estimate is 1.167 and there is a 95% chance that the predicted odds ratio will lie between 1.085 and 1.255 in subsequent samples drawn from the population. The coefficient of 1.167 (>1) indicates that for an increase of 1 litre in alcohol consumption, the odds of having a high level of suicide increases by a factor 1.167.
B) internetuserate as the only predictor
Internet use does not have a significant effect on the probability of having a high suicide level (Coeff. = 0.00872 and p-value(=0.1222) > 0.05), when it is the only predictor being fitted.
The odds ratio estimate is 1.009 and there is a 95% chance that the predicted odds ratio will lie between 0.998 and 1.020 in subsequent samples drawn from the population. The coefficient of 1.009 is almost equal to 1 and indicates that for an increase of 1 unit in internet use rate, the odds of having a high level of suicide remains the same. Also, the 95% confidence interval for the odds ratio is very close to 1 so internet use cannot be said to have a significant effect on suicide levels.
C) urbanrate as the only predictor
Urbanisation rate does not have a significant effect on the probability of having a high suicide level (Coeff. = -0.0125 and p-value(=0.0680) > 0.05), when it is the only predictor being fitted.
The odds ratio estimate is 0.998 and there is a 95% chance that the predicted odds ratio will lie between 0.974 and 1.001 in subsequent samples drawn from the population. The coefficient of 0.998 is almost equal to 1 and indicates that for an increase of 1 unit in rate of urbanisation, the odds of having a high level of suicide remains the same (slight decrease as parameter estimate is negative). Also, the 95% confidence interval for the odds ratio is very close to 1 so urbanisation cannot be said to have a significant effect on suicide levels.
D) Model based on alcconsumption, internetuserate and urbanrate
In the model consisting of all the above three predictors, the coefficients and the p-values obtained are:
> alcconsumption (coefficient = 0.1791, p-value = 0.0002)
> internetuserate (coefficient = 0.0124, p-value = 0.1933)
> urbanrate (coefficient = -0.0356, p-value = 0.0007)
So at 5% level of significance, alcconsumption and urbanrate are the predictors that are significantly associated with suicide level. There is thus a deviation in the estimates corresponding to the predictor urbanrate as can be seen from part C wherein it was observed that it does not have significant association with suicide level. This is indicative of a confounding effect of additional regressors on urbanrate.
The odds ratio estimates and the corresponding 95% confidence intervals are as under:
> alcconsumption (estimate = 1.196, CI = (1.089, 1.314))
The coefficient of 1.196 (>1) indicates that for an increase of 1 litre in alcohol consumption, the odds of having a high level of suicide increases by a factor 1.167. Subsequent samples will include the odds ratio estimate within the above CI in 95% of samples.
> internetuserate (estimate = 1.012, CI = (0.994, 1.032))
The coefficient of 1.012 is almost equal to 1 and indicates that for an increase of 1 unit in internet use rate, the odds of having a high level of suicide remains the same. Also, the 95% confidence interval for the odds ratio is very close to 1 so internet use cannot be said to have a significant effect on suicide levels.
> urbanrate (estimate = 0.965, CI = (0.945, 0.985))
We cannot not make any inference based on the above CI for urbanrate as its effect is getting confounded by inclusion of additional predictor in the model.
For my chosen response (suicidegroup) and primary regressor (alcconsumption) there appears to be a significant positive association between and addition of additional predictors, viz., internetuserate and urbanrate does not affect the relationship. So there is no evidence of confounding for the association between my response and primary predictor variable.
Among the three chosen predictors, only alcohol consumption appears to have a significant effect on suicide levels in a country and the effect is of positive nature, i.e., higher levels of alcohol consumption are associated with higher levels of suicide.