我想为两个级别的组获取mancova
,我有两个变量,但是在输入数据和变量后出现错误,我不知道如何解决。
library(jmv)
Data=read.csv(file.choose())
Data
attach(Data)
names(Data)
y1 = mancova(
data = Data,
deps = vars(postTotalcorrecttrial, postmemoryspan),
covs = vars(preTotalcorrecttrail, preMemoryspan),
factors = group,
multivar ="wilks")
summary.manova(model,test =“ Pillai”)中的错误: 残差的等级为1 <2
> Data4=read.csv(file.choose())
> Data4
group ` preTotalcorrecttrail` preMemoryspan `postTotalcorrecttrial `postmemoryspan
1 2 7 4.5 12 7.0
2 2 5 3.5 6 4.0
3 2 4 3.0 7 4.5
4 2 10 6.0 9 5.5
5 2 4 3.0 6 4.0
6 2 5 3.5 8 5.0
7 2 8 5.0 7 4.5
8 2 5 3.5 6 4.0
9 2 5 3.5 6 4.0
10 2 3 2.5 5 3.5
11 2 7 4.5 6 4.0
12 2 4 3.0 6 4.0
13 2 3 2.5 5 3.5
14 2 4 3.0 5 3.5
15 3 4 3.0 5 3.5
16 3 3 2.5 4 3.0
17 3 5 3.5 6 4.0
18 3 8 5.0 8 5.0
19 3 9 5.5 7 4.5
20 3 5 3.5 4 3.0
21 3 6 4.0 5 3.5
22 3 4 3.0 5 3.5
23 3 4 3.0 4 3.0
24 3 6 4.0 6 4.0
25 3 3 2.5 5 3.5
26 3 4 3.0 5 3.5
27 3 4 3.0 5 3.5
答案 0 :(得分:1)
您会收到该错误,因为您的变量完全相关。
您从示例中获得的数据:
structure(list(group = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L), .Label = c("2", "3"), class = "factor"), preTotalcorrecttrail = c(7L,
5L, 4L, 10L, 4L, 5L, 8L, 5L, 5L, 3L, 7L, 4L, 3L, 4L, 4L, 3L,
5L, 8L, 9L, 5L, 6L, 4L, 4L, 6L, 3L, 4L, 4L), preMemoryspan = c(4.5,
3.5, 3, 6, 3, 3.5, 5, 3.5, 3.5, 2.5, 4.5, 3, 2.5, 3, 3, 2.5,
3.5, 5, 5.5, 3.5, 4, 3, 3, 4, 2.5, 3, 3), postTotalcorrecttrial = c(12L,
6L, 7L, 9L, 6L, 8L, 7L, 6L, 6L, 5L, 6L, 6L, 5L, 5L, 5L, 4L, 6L,
8L, 7L, 4L, 5L, 5L, 4L, 6L, 5L, 5L, 5L), postmemoryspan = c(7,
4, 4.5, 5.5, 4, 5, 4.5, 4, 4, 3.5, 4, 4, 3.5, 3.5, 3.5, 3, 4,
5, 4.5, 3, 3.5, 3.5, 3, 4, 3.5, 3.5, 3.5)), row.names = c(NA,
-27L), class = "data.frame")
我们检查相关性:
cor(Data[,-1])
preTotalcorrecttrail preMemoryspan
preTotalcorrecttrail 1.0000000 1.0000000
preMemoryspan 1.0000000 1.0000000
postTotalcorrecttrial 0.6469337 0.6469337
postmemoryspan 0.6469337 0.6469337
postTotalcorrecttrial postmemoryspan
preTotalcorrecttrail 0.6469337 0.6469337
preMemoryspan 0.6469337 0.6469337
postTotalcorrecttrial 1.0000000 1.0000000
postmemoryspan 1.0000000 1.0000000
据我所知,postmemoryspan = 1 + 0.5 * postTotalcorrecttrial。做mancova没有意义。您只需进行线性回归即可。