r的相关语法

发布于 2025-01-31 20:00:47 字数 103 浏览 1 评论 0原文

非常基本的问题,这是我第一次在R中编写语法。试图编写基本的相关语法。假设如下:x1(预测变量)和x2(潜在预测变量)将与y(结果变量)呈正相关,而不是x3(潜在的预测变量)。我该如何在r中写?

Very basic question, it's my first time writing syntax in R. Trying to write basic correlation syntax. Hypothesis is as follows: X1 (Predictor variable) and X2 (latent predictor variable) will be positively associated with Y (outcome variable), over and above X3 (latent predictor variable). How can I write this in R?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

阳光下慵懒的猫 2025-02-07 20:00:47

不确定您的统计排骨是什么,但是由R平方值衡量的纯粹相关将严格增加模型的添加变量。因此,如果这些变量存储在数据框架df中,

model_full <- lm(Y ~ X1 + X2 + X3, data = df)

则适合完整模型。使用摘要(model_full)查看模型的摘要统计信息。

model_reduced <- lm(Y ~ X3, data = df)

适合还原模型。这是更复杂的东西来的。要测试x1x2的值,您可能想要一个 f-Test 测试x1x2的系数在统计上是否显着不同零(这是我解释“超越x3”的方式)。要计算该测试,请使用

lmtest::waldtest(model_full, model_reduced, test = "F")

Hope这会有所帮助!

Not sure what your statistics chops are, but pure the correlation as measured by the r-squared value will strictly increase with added variables to your model. So, if these variables are stored in data frame df,

model_full <- lm(Y ~ X1 + X2 + X3, data = df)

fits the full model. Use summary(model_full) to view summary statistics of the model.

model_reduced <- lm(Y ~ X3, data = df)

fits the reduced model. Here's where the more complicated stuff comes in. To test the value of X1 and X2, you probably want an F-test to test whether the coefficients on X1 and X2 are jointly statistically significantly different from zero (this is how I interpret 'above and beyond X3'). To compute that test, use

lmtest::waldtest(model_full, model_reduced, test = "F")

Hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文