登录
首页大数据时代SPSS广义线性模型GLM案例
SPSS广义线性模型GLM案例
2020-09-28
收藏

为了找出color、rarity、flower number、type of species对price的影响,由此,price为因变量,color、rarity、flower number、type 为自变量。

研究自变量对因变量的影响,可以选用的方法有两种,一种是传统的线性回归模型OLS,另一种是广义线性模型GLM(Generalized Linear Model)。传统模型(OLS)要求因变量服从正态分布,广义线性模型(GLM)则适用的范围更广,不要求因变量一定服从正态分布,并且方差也可以不稳定。

 第一步:考察因变量price的分布类型。

基于以上的分析,为了判断应该适用OLS还是使用GLM。需要先对因变量price的分布状况进行分析。首先,检验因变量price是否服从正态分布,检验的结果如下:

 Table 1 Tests of Normality

 Kolmogorov-Smirnova

 Shapiro-Wilk

 Statistic

 df

 Sig.

 Statistic

 df

 Sig.

 Price

 .149

 156

 .000

 .818

 156

 .000

 a. Lilliefors Significance Correction

上表是正态性检验的结果,K-S检验和S-W检验的SIG.全部小于0.05.由此可以知道,因变量price不服从正态分布。因此,研究color、rarity、flower number、type of species对price的影响不能选用传统线性模型(OLS)分析,必须选用GLM模型。

通过price不服从正态分布这一结论,得出必须选用GLM模型之后,还需要进一步找出因变量price到底服从哪种分布。经过尝试,得出因变量price服从Gamma分布。

 第二步:GLM分析

 确定选用GLM模型和因变量price是服从Gamma分布的,进行GLM分析,结果如下:

 Table 2

 Case Processing Summary

 N

 Percent

 Included

 156

 100.0%

 Excluded

 0

 0.0%

 Total

 156

 100.0%

 上表的结果陈述了,参与分析的案例个数为156。

 Table 3

 Categorical Variable Information

 N

 Percent

 Factor

 Color

 Green

 30

 19.2%

 Red

 30

 19.2%

 White

 29

 18.6%

 Black

 30

 19.2%

 Yellow

 22

 14.1%

 Blue

 15

 9.6%

 Total

 156

 100.0%

 Rarity

 Rare

 83

 53.2%

 Commom

 73

 46.8%

 Total

 156

 100.0%

 FlowerNumber

 Single flower

 72

 46.2%

 Multiple flowers

 84

 53.8%

 Total

 156

 100.0%

 TypeofSpecies

 Native species

 61

 39.1%

 First generation hybrids

 42

 26.9%

 Complex hybrids

 53

 34.0%

 Total

 156

 100.0%

上表的结果展现了4个自变量中每个类别的选择的人数及其占比。

 Table 4

 Goodness of Fita

 Value

 df

 Value/df

 Deviance

 68.838

 146

 .471

 Scaled Deviance

 166.574

 146

 Pearson Chi-Square

 68.353

 146

 .468

 Scaled Pearson Chi-Square

 165.400

 146

 Log Likelihoodb

 -767.832

 Akaike's Information Criterion (AIC)

 1557.665

 Finite Sample Corrected AIC (AICC)

 1559.498

 Bayesian Information Criterion (BIC)

 1591.213

 Consistent AIC (CAIC)

 1602.213

 Dependent Variable: Price

 Model: (Intercept), Color, Rarity, FlowerNumber, TypeofSpecies

 a. Information criteria are in small-is-better form.

b. The full log likelihood function is displayed and used in computing information criteria.

 上表是GLM模型的拟合优度分析结果,拟合优度分析是用于反映模型总体上对数据信息的表达是否充分。Deviance拟合优度检验法和Pearson Chi-Square拟合优度检验法计算出的显著性水平分别为0.471和0.468,均大于0.05,由此可以知道,模型的拟合情况良好,即模型能够比较真实可靠地反映出数据。


来CDA学业务数据分析师,SPSS理论结合实战进行项目数据分析,助你成为从事数据采集、清洗、处理、分析并能制作业务报告、提供决策的新型数据分析人才,点击了解课程详情!

数据分析咨询请扫描二维码

客服在线
立即咨询