我想在R中找到一个命令,以便计算给定变量集的所有可能模型。 例如,对于三个变量x1,x2和x3,有8种可能的模型:
"dependencies": {
"react": "16.0.0",
"react-native": "0.51.0"
},
"devDependencies": {
"@types/jest": "^22.0.1",
"@types/react": "^16.0.34",
"@types/react-native": "^0.51.9",
"babel-jest": "22.0.4",
"babel-preset-react-native": "4.0.0",
"concurrently": "^3.5.1",
"jest": "22.0.4",
"react-test-renderer": "16.0.0",
"rimraf": "^2.6.2",
"tslint": "^5.8.0",
"typescript": "^2.6.2"
},
如果我有5个变量,则有6894个不同的模型(包括所有可能的交互),但我想用R确认。
答案 0 :(得分:1)
答案是here
options(na.action = "na.fail") # avoid getting an error
library(MuMIn)
fullmodel <- lm(y ~ x1 * x2 * x3)
dredge(fullmodel, fixed = ~ x1 + x2 + x3)