简体   繁体   English

使用flexmix混合线性回归模型

[英]Mixture of Linear Regression Models using flexmix

I have a data set with response variable ADA, and independent variables LEV, ROA, and ROAL. 我有一个数据集,其中包含响应变量ADA和自变量LEV,ROA和ROAL。 The data is called dt. 该数据称为dt。 I used the following code to get coefficients for latent classes. 我使用以下代码来获取潜在类的系数。

m1 <- stepFlexmix(ADA ~ LEV+ROA+ROAL,data=dt,control= list(verbose=0), 
k=1:5,nrep= 10);  

m1 <- getModel(m1, "BIC");

All was fine until I read the following from http://rss.acs.unt.edu/Rdoc/library/flexmix/html/flexmix.html 一切都很好,直到我从http://rss.acs.unt.edu/Rdoc/library/flexmix/html/flexmix.html阅读了以下内容

model Object of FLXM of list of FLXM objects. Default is the object returned by calling FLXMRglm().

Which I think says that default model call is generalized linear model, while I am interested in linear model. 我认为默认模型调用是广义线性模型,而我对线性模型感兴趣。 How can I use linear model rather than GLM? 如何使用线性模型而不是GLM? I searched for it for quite a while, bit could't get it except this example from http://www.inside-r.org/packages/cran/flexmix/docs/flexmix , which I couldn't make sense of: 我搜索了好一阵子,除了http://www.inside-r.org/packages/cran/flexmix/docs/flexmix的此示例外,一点都找不到它,我无法理解:

data("NPreg", package = "flexmix")

## mixture of two linear regression models. Note that control parameters
## can be specified as named list and abbreviated if unique.
ex1 <- flexmix(yn~x+I(x^2), data=NPreg, k=2,
                   control=list(verb=5, iter=100))

ex1
summary(ex1)
plot(ex1)

## now we fit a model with one Gaussian response and one Poisson
## response. Note that the formulas inside the call to FLXMRglm are
## relative to the overall model formula.
ex2 <- flexmix(yn~x, data=NPreg, k=2,
               model=list(FLXMRglm(yn~.+I(x^2)), 
                          FLXMRglm(yp~., family="poisson")))
plot(ex2)

Someone please let me know how to use linear regression instead of GLM. 有人请让我知道如何使用线性回归代替GLM。 Or am I already using LM and just got confused because of the "default model line"? 还是我已经在使用LM并且由于“默认模型行”而感到困惑? Please explain. 请解释。 Thanks. 谢谢。

I did a numerical analysis to understand if 我进行了数值分析,以了解是否

m1 <- stepFlexmix(ADA ~ LEV+ROA+ROAL,data=dt,control= list(verbose=0)

does produce results from linear regression. 确实会产生线性回归结果。 To do the experiment, I ran the following code and found that yes the estimated parameters are indeed from linear regression. 为了进行实验,我运行了以下代码,发现估计的参数确实来自线性回归。 Experiment helped me to allay my reservations. 实验帮助我减轻了我的保留。

  x1 <- c(1:200);
  x2 <- x1*x1;
  x3 <- x1*x2;
  e1 <- rnorm(200,0,1);
  e2 <- rnorm(200,0,1);
  y1 <- 5+12*x1+20*x2+30*x3+e1;
  y2 <- 18+5*x1+10*x2+15*x3+e2;
  y <- c(y1,y2)
  x11 <- c(x1,x1)
  x22 <- c(x2,x2)
  x33 <- c(x3,x3)
  d <- data.frame(y,x11,x22,x33)

  m <- stepFlexmix(y ~ x11+x22+x33, data =d, control = list(verbose=0), k=1:5, nrep = 10);
  m <- getModel(m, "BIC");
  parameters(m);
  plotEll(m, data = d)
  m.refit <- refit(m);
  summary(m.refit)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM