* Comments;
* ESS data set;
* Analysis;
* 20 Sept. 2012;
* Please note semicolon;
options nocenter;
* List of variables in data set ESS;
proc contents data=ess position;
* position = variables in physical order;
title "List of variables in ESS data set";
run;
ods graphics on;
* ods = output delivery system;
* Tables and graphs;
proc freq data=ess;
title1 "Distributions";
tables gndr*(trstprl--trstun) / plots=all;
* Graphics: plots= option;
run;
* Are the differences between males and females significant
(statistically significant)?;
* Statistical tests;
* What test?;
proc freq data=ess;
title1 "Distributions";
tables gndr*(trstprl--trstun) / nocol nopercent chisq;
* chisq= chi-squared test statistic;
* nocol= suppressing column pct;
run;
*
Statistic DF Value Prob
Chi-Square 10 17.5044 0.0639
0.10
0.05
0.01
0.001
;
* Let us prepare a "general indicator of trust" variable
by using principal components = first PC explaining 60% of total
variation of 7 items;
* Principal components are similar to factors;
proc princomp data=ess out=ess2 prefix=PC plots=all;
* Note: New data set ess2;
* prefix = the names of prin. components start with PC;
* plots=all some graphical presentations;
var trstprl--trstun;
run;
* Linear modelling of the trust indicator;
* Gender differences?;
proc surveyreg data=ess2;
* Explanatory variable: gender;
* class = define gender as categorical variable;
class gndr;
model pc1=gndr;
* pc1 = response variable;
run;
*
Effect Num DF F Value Pr > F
Model 1 5.67 0.0173
Intercept 1 0.00 0.9765
gndr 1 5.67 0.0173
Inference: Because Pr(gndr)=0.0173 is less that 0.05 then we can
reject the null hypothesis of no gender difference with sign.level
less that 5%;
proc surveyreg data=ess2;
class gndr;
model pc1=gndr / solution;
* solution = estimated model coefficients;
run;
* Inference: Trust in males is smaller than in females;
* Let us take gender and age as predictors;
proc surveyreg data=ess2;
class gndr;
*model pc1=gndr agea / solution;
* test of interaction of gender and age: gndr*agea;
* results show that there are no interaction to be generalized;
* So, the regression lines are parallel for males and females;
model pc1=gndr agea gndr*agea;
*output out=ess pred=predicted;
run;
* Inference: Both gender and age are significant predictors of trust;
* Final model;
proc surveyreg data=ess2;
class gndr;
model pc1=gndr agea;
* calculate predicted values by the model and plot them;
* variable predicted;
output out=ess2 pred=predicted;
run;
proc gplot data=ess2;
plot predicted*agea=gndr;
run;
quit;