线性模型与广义线性混合模型的关系类

Relationship between LinearModel & GeneralizedLinearMixedModel classes

Matlab 定义了 LinearModelGeneralizedLinearMixedModel 类。浏览文档表明要么 (i) 一个派生自另一个,要么 (ii) 存在自动转换。这些都是复杂的对象,我才刚刚开始探索它们,如果它们之间的关系很明显,我很抱歉,但它们到底是什么关系?

另请注意,我在上面的 (i) 和 (ii) 中表达了我的面向对象背景 (C++),并且我知道可能与 Matlab 范式存在差异。

出现这个问题是因为函数 coefTest 接受一个 GeneralizedLinearMixedModel 对象,而计量经济学工具箱示例 "Time Series Regression IX: Lag Order Selection" 提交一个 LinearModel 对象。

请注意,此问题与特定于 Matlab 的 类 和 Matlab 命令 coefTest 有关。因此,它不属于 "Cross Validated" Stack Exchange 论坛。我将此发布到:

http://groups.google.com/forum/#!topic/comp.soft-sys.matlab/OHLajBEuPU0

要确定这一点,您可以使用 superclasses 函数:

superclasses('LinearModel')
superclasses('GeneralizedLinearMixedModel')

这将 return 每个案例的 可见 超级 class 的名称。正如您将看到的,两者都继承自 abstract superclass classreg.regr.ParametricRegression.

您还可以查看实际classdef files and look at the inheritances。在您的命令 Window 中,键入 edit LinearModeledit GeneralizedLinearMixedModel。你会分别看到:

classdef (Sealed = true) LinearModel < classreg.regr.TermsRegression

classdef (Sealed = true) GeneralizedLinearMixedModel < classreg.regr.LinearLikeMixedModel

等等。 LinearModelGeneralizedLinearMixedModel 都是 Sealed,这意味着它们不允许被 subclassed。


为什么 coefTest "accept" 对象同时 LinearModelGeneralizedLinearMixedModel class 对象?

LinearModelGeneralizedLinearMixedModel 都有称为 coefTest 的方法:LinearModel/coefTest and GeneralizedLinearMixedModel/coefTest. Despite the name, these are entirely separate functions. Which method gets called is determined by the class of the object you pass to it. The methods of each of these classes are listed in their respective documentation, however, you can also use the methods 作用于 class 的对象以列出其 public方法。