简体   繁体   English

创建一个函数以沿多列xts对象运行回归

[英]Create a function to run a regression along a multi-column xts object

I'm trying to create a function in R to use in a separate function such as apply.monthly/apply.quarterly. 我正在尝试在R中创建一个函数,以便在另一个函数中使用,例如apply.monthly / apply.quarterly。 The function I'd like to create looks at a specified xts (or data frame etc) object and runs a regression and extracts the outputs using the first column of data in the xts file as the dependent variable and each additional column of data as its independent variable. 我想要创建的函数查看指定的xts(或数据框等)对象并运行回归并使用xts文件中的第一列数据作为因变量和每个附加数据列作为其提取输出自变量。 I then want to reconstitute the summary results into a new finished table. 然后,我想将摘要结果重新组合成一个新的完成表。

Any help solving would be much appreciated. 任何帮助解决将非常感激。

Your question is vague and solid runnable example not provided. 您的问题是模糊且固定的可运行示例未提供。 So, you will have the same type of answer as your question. 因此,您将获得与您的问题相同类型的答案。 Try lapply and pass xts files as first argument of lapply finction. 尝试lapply并传递xts文件作为lapply finction的第一个参数。 Then aggregate results with do.call() 然后使用do.call()汇总结果

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

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