简体   繁体   English

使用R中的拆分功能进行运行因素分析

[英]Running factor analysis using split function in R

I have the following dataset : 我有以下数据集:

MKT econ_unemp  econ_gas open
504 0.0743088   3.461    38
504 0.0740673   3.448    38
504 0.0740673   3.455    38
504 0.0740673   3.42     38
504 0.072682    3.391    38
505 0.0692244   3.345    38
505 0.0692244   3.381    38
505 0.0692244   3.484    38
505 0.0692244   3.488    38

I need to run factor analysis on the 3 variables by market so I used the split function in R to split the data: 我需要按市场对3个变量进行因子分析,因此我在R中使用了split函数来拆分数据:

  splitx<-split(data,data$DMA)

and then tried running factor analysis as follows: 然后尝试运行因素分析,如下所示:

for (i in 1:length(splitx)) {

 fa <- factanal(splitx[[i]],factors =1)
  }

But I am getting the following error: 但是我收到以下错误:

Error in optim(start, FAfn, FAgr, method = "L-BFGS-B", lower = lower,:non-finite value supplied by optim

I hope the information provided is sufficient. 我希望所提供的信息足够。 Can someone help me fix this. 有人可以帮我解决这个问题。

Regards 问候

by(data[, -1], data[, 1], factanal, factors = 1)

假设MKT是split变量,那应该可以解决问题。

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

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