简体   繁体   English

R 中的多结果逻辑回归

[英]Multiple outcome logistic regression in R

I have a large dataset with multiple binary dependent variables (eg y1, y2, y3, y4).我有一个包含多个二进制因变量(例如 y1、y2、y3、y4)的大型数据集。 yi variables are people's response to their decision making behaviour in different situations. yi 变量是人们在不同情况下对其决策行为的反应。 There are many explanatory variables (eg x1, x2, ...) which are mainly sociodemographic variables.有很多解释变量(例如x1,x2,...),主要是社会人口变量。

I can model each y based on the explanatory variables (eg y1~x).我可以 model 基于解释变量(例如 y1~x)的每个 y。

But, all binary dependent variables are correlated and I would like their correlations to be considered in my model. In other words, I would like to model yi ~ xj for all i simultaneously.但是,所有二元因变量都是相关的,我希望在我的 model 中考虑它们的相关性。换句话说,我想同时为所有 i 计算 model yi ~ xj。 It can be called a multiple outcome logistic regression model.它可以称为多结果逻辑回归 model。

I have already tried looking up on the.net, glm, and brms packages.我已经尝试查找 .net、glm 和 brms 包。 None worked for me.没有一个对我有用。

Does anybody know a package that is capable of performing such model?有人知道能够执行此类 model 的 package 吗?

I think I've figured it out: 我想我已经弄明白了:

Make sure that the installer project includes the Content Files for the web app. 确保安装程序项目包含Web应用程序的内容文件。 Then go into the web app's csproj file with a text editor and find the ItemGroup where the static Content files are listed. 然后使用文本编辑器进入Web应用程序的csproj文件,找到列出静态内容文件的ItemGroup。 Then add an entry with a wildcard in it and the installer will package them in. 然后添加一个带有通配符的条目,安装程序将其打包。

<ItemGroup>
    <Content Include="Content\test.html" />
    <Content Include="Content\*.html" />
        <Content Include="Content\*.gif" />
       <Content Include="Content\*.css" />
       <Content Include="Content\*.jpg" />
       <Content Include="Content\*\*.js" />

Right click on the folder in the File System view of the Web Setup project, and select Add, File... 右键单击Web Setup项目的File System视图中的文件夹,然后选择Add,File ...

It doesn't look like you can add an entire folder this way though, so you would have to add every file individually to the Setup program. 看起来您不能以这种方式添加整个文件夹,因此您必须将每个文件单独添加到安装程序中。

EDIT: 编辑:

Aren't all files from your project folder included in a WebSite project in Visual Studio? 您的项目文件夹中的所有文件都不包含在Visual Studio中的WebSite项目中吗? Then it's just a case of having your WebSite project and Web Setup project in the same solution, then right-click on the Web Application Folder in the Web Setup project, select Add, Project Output... and then select the WebSite Project in the drop down and Content Files from the list box and click OK. 然后,只需将WebSite项目和Web Setup项目放在同一解决方案中,然后右键单击Web Setup项目中的Web Application Folder,选择Add,Project Output ...然后选择WebSite Project中的WebSite项目。从列表框中下拉内容文件,然后单击“确定”。

Maybe .net::multinom for multinominal logistic regression fits your problem.多项逻辑回归的.net::multinom可能适合您的问题。

If your dichotomous dependent variables are not from a categorical one, perhaps a structural equation model with correlated dichotomous dependent variables is a solution.如果您的二分因变量不是来自分类因变量,那么具有相关二分因变量的结构方程 model 可能是一个解决方案。 That would work with lavaan .这将适用于lavaan

There are two techniques I would like to suggest.我想推荐两种技术。 When you have a matrix $Y$ of outcomes and one of predictors $X$ , you can use the Canonical Correlation Analysis, implemented in the CCA package in R. This technique searches for new columns that represent the best linear combinations between $Y$ and $X$ .当您有结果矩阵$Y$和预测变量之一$X$时,您可以使用典型相关分析,在 R 中的CCA package 中实施。此技术搜索表示$Y$之间最佳线性组合的新列和$X$ Imagine, you can compute the correlation between two variables and that tells you something about their relationship, but you can't compute the correlation between two sets of columns*!想象一下,您可以计算两个变量之间的相关性并告诉您它们之间的关系,但您无法计算两组列之间的相关性*! The CCA finds new columns $a_{Y}$ and $b_{X}$ that express the highest correlation between $X$ and $Y$ , accounting for the variability within and between the two matrices. CCA 发现新列$a_{Y}$$b_{X}$表示$X$$Y$之间的最高相关性,说明两个矩阵内部和之间的可变性。 Here there is not really a relationship outcomes-predictors, because $X$ and $Y$ are considered at the "same level".这里并没有真正的关系结果预测因子,因为$X$$Y$被认为处于“同一水平”。 You can also use the Partial Least Square (PLS) analysis, implemented in the pls package. This technique is intimately linked to the CCA, but in this case formally you are looking for the best approximations of $X$ based on their correlation with $Y$ .您还可以使用偏最小二乘法 (PLS) 分析,在pls package 中实现。此技术与 CCA 密切相关,但在这种情况下,形式上您要根据 $X$ 与$的相关性寻找$X$的最佳近似值美元 I won't get in further details for now, but if you need more clarifications please ask.我现在不会提供更多详细信息,但如果您需要更多说明,请询问。

Here is a tutorial for the CCA. 是CCA的教程。 Here another one.这里是另一个。

Here is a tutorial for the PLS.是 PLS 的教程。 Here another one. 这里是另一个。

*You can compute the correlation of one variable with each of the other ones (pair-wise correlations), but this doesn't take in account the correlation with the other variables! *您可以计算一个变量与其他变量的相关性(成对相关性),但这并没有考虑与其他变量的相关性!

Unfortunately I don't think there is an out of the box way to do this, as projects maintains references to the files individually. 不幸的是,我认为没有开箱即用的方法,因为项目会单独维护对文件的引用。

You could achieve what you need via a custom macro, or asking your other team to edit the .csproj XML file (perhaps simpler or riskier, depending on their background). 您可以通过自定义宏实现所需,或者让其他团队编辑.csproj XML文件(可能更简单或更具风险,具体取决于他们的背景)。

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

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