简体   繁体   English

特征误差(Sigma,对称 = TRUE):'x' 中的无限或缺失值与 zelig 逻辑回归

[英]Error in eigen(Sigma, symmetric = TRUE) : infinite or missing values in 'x' with zelig logistic regression

So I am trying to do propensity score matching and then utilize Zelig to perform a logistic regression on the matched data.所以我试图做倾向得分匹配,然后利用 Zelig 对匹配的数据执行逻辑回归。

Here is an example of what my data looks like: DATA这是我的数据的示例: DATA

So I am trying to match the patients based on Dementia, Stroke, and Age.所以我试图根据痴呆症、中风和年龄来匹配患者。 I am then trying to see whether or not Drug X is associated with an increased risk of falling once the patients have been matched.然后我试图看看一旦患者匹配,药物 X 是否会增加跌倒的风险。 I would then like to go through the same process for Drug Y and Drug Z to see if each individual drug has an association.然后,我想对药物 Y 和药物 Z 进行相同的过程,以查看每种药物是否有关联。

Here is the code I have used so far to perform the matching and the logistic regression analysis:这是我迄今为止用于执行匹配和逻辑回归分析的代码:

data <- read_csv("Desktop/data.csv")
View(data)
attach(data)
data[1:10,]

m.out = matchit(Fall ~ Dementia + Stroke + Age, method = "exact", data = data)

m.data = match.data(m.out)
library(Zelig)
z.out = zelig(Fall ~ Drug X + Dementia + Stroke + Age, model = "logit", data = m.data)

x.out0 <- setx(z.out, Drug X = 0)
x1.out0 <- setx(z.out, Drug X = 1)

s.out0 <- sim(z.out, x = x.out0, x1 = x1.out0)

Everything seems to be going smoothly until this last line.一切似乎都很顺利,直到最后一行。 Here is the error message I keep getting.这是我不断收到的错误消息。

Error in eigen(Sigma, symmetric = TRUE) : 
  infinite or missing values in 'x'

Any ideas what I'm doing wrong?任何想法我做错了什么? I've been stuck here for a while now and decided to reach out for help.我已经被困在这里一段时间了,决定寻求帮助。

Thanks in advance.提前致谢。

At this time, Zelig has not been updated in a few years and appears to have some bugs that are unaddressed.此时,Zelig 已经有几年没有更新了,并且似乎存在一些未解决的错误。 One issue is that the sim command seems to be very sensitive to variable names and data types.一个问题是 sim 命令似乎对变量名称和数据类型非常敏感。 For anyone getting this error, try the following:对于任何收到此错误的人,请尝试以下操作:

  • the variable Drug X has a space which Zelig probably can't handle.变量Drug X有一个 Zelig 可能无法处理的空间。 Try renaming it to something like Drug_X尝试将其重命名为Drug_X类的Drug_X

  • If there's a variable that's dropping from the regression model due to collinearity, it needs to be dropped from the model entirely before going to sim()如果有一个变量由于共线性而从回归模型中删除,则需要在转到sim()之前将其完全从模型中删除

  • Before running the model, also check that any character variables are converted to factors or you might get the following error:在运行模型之前,还要检查所有字符变量是否已转换为因子,否则您可能会收到以下错误:

    Error in contrasts<-(tmp, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels对比误差<-(tmp, value = contr.funs[1 + isOF[nn]]) :对比只能应用于具有 2 个或更多级别的因素

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

相关问题 你如何处理“特征错误(a,对称=真):&#39;x&#39;中的无限或缺失值”? - How do you deal with an "Error in eigen(a, symmetric = TRUE) : infinite or missing values in 'x'"? 特征误差(Sigma,对称 = TRUE):MetRology uncertMC 中的 0 x 0 矩阵,具有 2x2 相关矩阵 - Error in eigen(Sigma, symmetric = TRUE) : 0 x 0 matrix in MetRology uncertMC with 2x2 correlation matrix 逻辑回归的误差Zelig R - Error from logistic regression Zelig R 在log(eigen(sigma,symmetric = TRUE,only.values = TRUE)$ values):产生的NaN - In log(eigen(sigma, symmetric = TRUE, only.values = TRUE)$values) : NaNs produced 特征(x)中的错误:“x”中的无限值或缺失值 &gt; 在 robumeta 中 - Error in eigen(x) : infinite or missing values in 'x' > in robumeta 使用Zelig进行Logistic回归[R] - Logistic Regression Using Zelig [R] 用Stargazer或其他包装在Knitr中呈现Zelig Logistic回归 - Presenting Zelig Logistic Regression in Knitr with Stargazer or Other Package R:需要 TRUE/FALSE 的缺失值:逻辑回归的解决方案 - R: missing value where TRUE/FALSE needed: solution for logistic regression 逻辑回归错误:y 值必须为 0 &lt;= y &lt;= 1 - Logistic Regression Error: y values must be 0 <= y <= 1 GLM Logistic回归的有效起始值错误 - Valid starting values error for GLM logistic regression
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM