如何在线性判别分析中获得常数项

时间:2018-09-02 16:07:32

标签: r linear-discriminant

考虑dput

structure(list(REAÇÃO = structure(c(0, 1, 0, 0, 1, 0, 1, 1, 
0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 
1, 0, 1, 1, 0, 1, 1), format.spss = "F11.0"), IDADE = structure(c(22, 
38, 36, 58, 37, 31, 32, 54, 60, 34, 45, 27, 30, 20, 30, 30, 22, 
26, 19, 18, 22, 23, 24, 50, 20, 47, 34, 31, 43, 35, 23, 34, 51, 
63, 22, 29), format.spss = "F11.0"), ESCOLARIDADE = structure(c(6, 
12, 12, 8, 12, 12, 10, 12, 8, 12, 12, 12, 8, 4, 8, 8, 12, 8, 
9, 4, 12, 6, 12, 12, 12, 12, 12, 12, 12, 8, 8, 12, 16, 12, 12, 
12), format.spss = "F11.0"), SEXO = structure(c(1, 1, 0, 0, 1, 
0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 
0, 1, 0, 1, 0, 0, 0, 1, 1, 1), format.spss = "F11.0")), .Names = c("REAÇÃO", 
"IDADE", "ESCOLARIDADE", "SEXO"), row.names = c(NA, -36L), class = "data.frame")

其中:REAÇÃO是模型中的因变量。

常量:-4.438

如何使用R中的简单函数获取该值?

1 个答案:

答案 0 :(得分:0)

要在R的判别分析中获得常数项(使用库MASS):

groupmean<-(model$prior%*%model$means)
constant<-(groupmean%*%model$scaling)
constant

其中modellda的判别式:

model<-lda(y~x1+x2+xn,data=mydata)
model