多元线性回归模型:因子数据问题

时间:2018-11-12 08:37:19

标签: r

我想建立一个多元线性回归模型,以邻苯二甲酸盐浓度作为响应变量,年龄,体重和身高作为预测变量。 我将数据加载到R中:

data <- read.dta("merge_BQ_TOX_all.dta", convert.dates = TRUE, convert.factors = TRUE,
                 missing.type = FALSE,
                 convert.underscore = FALSE, warn.missing.labels = TRUE)
UMdata <- read.dta("UM_za_BPA.dta")
M <- read.csv2("results_Mcrea.csv", header = T, blank.lines.skip = TRUE)

然后我合并所需的列

personal <- dplyr::select(UMdata, UMA08, UMA09)
age <- dplyr::select(data_sorted, BQF05M2)
P <- data.frame(cbind(M,personal, age))

然后我尝试模型。 “ M_5OH.MEHP_µg.gCrea”是“ M”数据集的第一列,其中包含5OH_MEHP的邻苯二甲酸盐浓度

mod1 <- lm(M_5OH.MEHP_µg.gCrea ~ UMA08 + UMA09 + BQF05M2, P)

,我收到以下警告消息: 警告消息:

1: In model.response(mf, "numeric") :
  using type="numeric" with a factor response will be ignored
2: In Ops.factor(y, z$residuals) : ‘-’ not meaningful for factors

我发现问题出在浓度数据集“ M”上 看起来像这样:

> head(M)
       ID M_MEHP_µg.gCrea M_5OH.MEHP_µg.gCrea M_5oxo.MEHP_µg.gCrea M_MEP_µg.gCrea M_MBzP_µg.gCrea M_MiBP_µg.gCrea M_MnBP_µg.gCrea
1 SIU001M            0.29                0.06                 0.10           0.02            0.47            0.03            0.04
2 SIU005M            0.39                0.07                 0.14           0.00            0.42            0.01            0.02
3 SIU008M            0.46                0.12                 0.19           0.04            0.13            0.03            0.04
4 SIU009M            0.73                0.08                 0.16           0.03            0.27            0.04            0.07
5 SIU017M            0.17                0.05                 0.11           0.01            0.35            0.02            0.03
6 SIU021M            0.33                0.08                 0.17           0.06            0.51            0.05            0.04

> str(P)
'data.frame':   155 obs. of  11 variables:
 $ ID                  : Factor w/ 155 levels "SIR001M","SIR002M",..: 78 80 83 84 85 87 88 89 91 92 ...
 $ M_MEHP_µg.gCrea     : Factor w/ 82 levels "","0.01","0.02",..: 25 35 40 54 13 29 62 30 72 40 ...
 $ M_5OH.MEHP_µg.gCrea : Factor w/ 26 levels "0.01","0.02",..: 6 7 12 8 5 8 8 15 13 11 ...
 $ M_5oxo.MEHP_µg.gCrea: Factor w/ 43 levels "0.01","0.02",..: 10 14 19 16 11 17 9 28 23 19 ...
 $ M_MEP_µg.gCrea      : Factor w/ 19 levels "0.00","0.01",..: 3 1 5 4 2 7 5 3 2 4 ...
 $ M_MBzP_µg.gCrea     : Factor w/ 60 levels "0.01","0.03",..: 39 34 9 23 28 41 13 13 12 40 ...
 $ M_MiBP_µg.gCrea     : Factor w/ 9 levels "0.00","0.01",..: 4 2 4 5 3 6 3 6 4 3 ...
 $ M_MnBP_µg.gCrea     : Factor w/ 18 levels "0.00","0.01",..: 5 3 5 8 4 5 3 9 3 2 ...
 $ UMA08               : int  56 60 55 67 61 60 85 61 65 65 ...
 $ UMA09               : int  163 165 162 175 175 168 168 159 160 166 ...
 $ BQF05M2             : int  35 37 38 30 34 33 39 40 42 45 ...
> 

dput(P)给了我这个:

> dput(P)
structure(list(ID = structure(c(78L, 80L, 83L, 84L, 85L, 87L, 
88L, 89L, 91L, 92L, 93L, 94L, 95L, 96L, 97L, 99L, 100L, 103L, 
104L, 105L, 106L, 107L, 109L, 110L, 111L, 113L, 114L, 115L, 116L, 
117L, 118L, 119L, 120L, 121L, 122L, 127L, 128L, 129L, 130L, 131L, 
134L, 135L, 136L, 137L, 138L, 139L, 140L, 141L, 142L, 143L, 145L, 
146L, 147L, 148L, 149L, 150L, 151L, 153L, 154L, 155L, 1L, 2L, 
3L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 
18L, 19L, 20L, 21L, 22L, 24L, 25L, 28L, 29L, 30L, 31L, 32L, 33L, 
34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 44L, 45L, 46L, 47L, 
48L, 49L, 50L, 51L, 52L, 54L, 55L, 56L, 57L, 58L, 59L, 63L, 65L, 
66L, 68L, 70L, 74L, 77L, 79L, 81L, 82L, 86L, 90L, 98L, 101L, 
102L, 108L, 112L, 123L, 124L, 125L, 126L, 132L, 133L, 144L, 152L, 
4L, 23L, 26L, 27L, 43L, 53L, 60L, 61L, 62L, 64L, 67L, 69L, 71L, 
72L, 73L, 75L, 76L), .Label = c("SIR001M", "SIR002M", "SIR004M", 
"SIR006M", "SIR007M", "SIR010M", "SIR012M", "SIR015M", "SIR020M", 
"SIR022M", "SIR023M", "SIR027M", "SIR030M", "SIR033M", "SIR034M", 
"SIR036M", "SIR037M", "SIR038M", "SIR040M", "SIR046M", "SIR047M", 
"SIR049M", "SIR051M", "SIR052M", "SIR053M", "SIR054M", "SIR055M", 
"SIR057M", "SIR059M", "SIR060M", "SIR061M", "SIR062M", "SIR063M", 
"SIR068M", "SIR071M", "SIR072M", "SIR074M", "SIR076M", "SIR077M", 
"SIR078M", "SIR079M", "SIR081M", "SIR082M", "SIR086M", "SIR088M", 
"SIR096M", "SIR100M", "SIR105M", "SIR106M", "SIR108M", "SIR109M", 
"SIR110M", "SIR114M", "SIR116M", "SIR117M", "SIR118M", "SIR121M", 
"SIR131M", "SIR138M", "SIR139M", "SIR141M", "SIR142M", "SIR146M", 
"SIR147M", "SIR150M", "SIR151M", "SIR152M", "SIR153M", "SIR154M", 
"SIR155M", "SIR156M", "SIR157M", "SIR158M", "SIR159M", "SIR160M", 
"SIR161M", "SIR162M", "SIU001M", "SIU003M", "SIU005M", "SIU006M", 
"SIU007M", "SIU008M", "SIU009M", "SIU017M", "SIU018M", "SIU021M", 
"SIU022M", "SIU024M", "SIU025M", "SIU026M", "SIU028M", "SIU029M", 
"SIU031M", "SIU032M", "SIU034M", "SIU036M", "SIU038M", "SIU039M", 
"SIU040M", "SIU041M", "SIU042M", "SIU043M", "SIU045M", "SIU046M", 
"SIU050M", "SIU051M", "SIU054M", "SIU055M", "SIU058M", "SIU059M", 
"SIU061M", "SIU062M", "SIU063M", "SIU064M", "SIU065M", "SIU067M", 
"SIU068M", "SIU070M", "SIU071M", "SIU072M", "SIU074M", "SIU075M", 
"SIU076M", "SIU078M", "SIU079M", "SIU080M", "SIU081M", "SIU082M", 
"SIU083M", "SIU084M", "SIU086M", "SIU087M", "SIU088M", "SIU089M", 
"SIU090M", "SIU092M", "SIU093M", "SIU094M", "SIU095M", "SIU096M", 
"SIU097M", "SIU099M", "SIU100M", "SIU101M", "SIU103M", "SIU104M", 
"SIU108M", "SIU110M", "SIU111M", "SIU112M", "SIU113M", "SIU114M", 
"SIU115M", "SIU116M"), class = "factor"), M_MEHP_µg.gCrea = structure(c(25L, 
35L, 40L, 54L, 13L, 29L, 62L, 30L, 72L, 40L, 17L, 46L, 20L, 7L, 
81L, 34L, 18L, 69L, 69L, 29L, 58L, 37L, 37L, 13L, 47L, 18L, 6L, 
56L, 66L, 64L, 67L, 9L, 35L, 53L, 30L, 10L, 18L, 78L, 19L, 8L, 
10L, 29L, 70L, 33L, 31L, 52L, 48L, 29L, 61L, 76L, 77L, 28L, 8L, 
67L, 8L, 43L, 28L, 73L, 79L, 68L, 5L, 8L, 11L, 34L, 8L, 66L, 
57L, 16L, 21L, 74L, 59L, 35L, 60L, 16L, 22L, 32L, 24L, 15L, 40L, 
46L, 25L, 49L, 38L, 24L, 24L, 12L, 15L, 7L, 24L, 40L, 13L, 3L, 
30L, 15L, 32L, 75L, 21L, 4L, 15L, 17L, 45L, 25L, 5L, 15L, 51L, 
18L, 41L, 64L, 80L, 8L, 19L, 29L, 82L, 17L, 16L, 65L, 6L, 11L, 
23L, 44L, 64L, 29L, 1L, 36L, 18L, 2L, 21L, 55L, 50L, 66L, 9L, 
39L, 30L, 46L, 42L, 63L, 32L, 45L, 22L, 18L, 20L, 37L, 71L, 43L, 
24L, 32L, 14L, 28L, 27L, 9L, 17L, 45L, 42L, 26L, 17L), .Label = c("", 
"0.01", "0.02", "0.06", "0.07", "0.08", "0.09", "0.11", "0.12", 
"0.13", "0.14", "0.15", "0.17", "0.18", "0.19", "0.20", "0.21", 
"0.22", "0.23", "0.24", "0.25", "0.26", "0.27", "0.28", "0.29", 
"0.30", "0.31", "0.32", "0.33", "0.34", "0.35", "0.36", "0.37", 
"0.38", "0.39", "0.40", "0.41", "0.43", "0.45", "0.46", "0.47", 
"0.49", "0.50", "0.51", "0.53", "0.56", "0.61", "0.62", "0.64", 
"0.65", "0.67", "0.70", "0.71", "0.73", "0.77", "0.80", "0.81", 
"0.85", "0.86", "0.87", "0.88", "0.89", "0.91", "0.99", "1.02", 
"1.03", "1.07", "1.10", "1.14", "1.19", "1.27", "1.28", "1.29", 
"1.46", "1.49", "1.56", "1.67", "1.92", "2.07", "2.10", "2.24", 
"2.88"), class = "factor"), M_5OH.MEHP_µg.gCrea = structure(c(6L, 
7L, 12L, 8L, 5L, 8L, 8L, 15L, 13L, 11L, 7L, 8L, 6L, 2L, 17L, 
9L, 6L, 10L, 21L, 9L, 18L, 13L, 6L, 3L, 24L, 11L, 4L, 8L, 25L, 
8L, 16L, 4L, 10L, 11L, 7L, 5L, 6L, 20L, 8L, 3L, 4L, 8L, 6L, 9L, 
7L, 12L, 6L, 15L, 8L, 12L, 25L, 5L, 9L, 11L, 3L, 12L, 7L, 13L, 
23L, 16L, 1L, 2L, 3L, 9L, 7L, 19L, 12L, 7L, 9L, 5L, 13L, 6L, 
9L, 3L, 10L, 11L, 15L, 10L, 15L, 14L, 6L, 7L, 10L, 6L, 8L, 8L, 
7L, 3L, 7L, 4L, 5L, 1L, 8L, 6L, 10L, 8L, 11L, 2L, 6L, 5L, 22L, 
5L, 2L, 6L, 13L, 5L, 7L, 10L, 6L, 3L, 4L, 9L, 16L, 5L, 5L, 17L, 
2L, 7L, 9L, 4L, 10L, 10L, 4L, 8L, 3L, 1L, 2L, 26L, 4L, 20L, 3L, 
6L, 4L, 4L, 8L, 10L, 2L, 5L, 12L, 5L, 6L, 8L, 16L, 8L, 5L, 9L, 
4L, 2L, 6L, 6L, 6L, 10L, 6L, 2L, 5L), .Label = c("0.01", "0.02", 
"0.03", "0.04", "0.05", "0.06", "0.07", "0.08", "0.09", "0.10", 
"0.11", "0.12", "0.13", "0.14", "0.15", "0.16", "0.18", "0.19", 
"0.21", "0.22", "0.23", "0.25", "0.26", "0.29", "0.30", "0.31"
), class = "factor"), M_5oxo.MEHP_µg.gCrea = structure(c(10L, 
14L, 19L, 16L, 11L, 17L, 9L, 28L, 23L, 19L, 13L, 13L, 11L, 6L, 
31L, 19L, 9L, 24L, 36L, 22L, 42L, 23L, 11L, 4L, 29L, 15L, 7L, 
17L, 37L, 16L, 25L, 7L, 15L, 20L, 11L, 10L, 9L, 40L, 12L, 5L, 
6L, 18L, 17L, 18L, 10L, 31L, 17L, 30L, 19L, 26L, 41L, 9L, 14L, 
21L, 5L, 31L, 15L, 33L, 43L, 27L, 3L, 4L, 8L, 14L, 9L, 32L, 26L, 
14L, 15L, 11L, 30L, 11L, 19L, 5L, 29L, 17L, 35L, 18L, 26L, 30L, 
11L, 18L, 20L, 12L, 21L, 9L, 12L, 6L, 9L, 17L, 9L, 1L, 11L, 11L, 
17L, 16L, 17L, 4L, 16L, 5L, 39L, 11L, 4L, 12L, 16L, 9L, 13L, 
23L, 14L, 6L, 6L, 15L, 25L, 13L, 9L, 34L, 4L, 14L, 18L, 8L, 28L, 
18L, 5L, 16L, 7L, 2L, 5L, 38L, 7L, 30L, 6L, 13L, 7L, 6L, 16L, 
19L, 4L, 19L, 16L, 11L, 10L, 14L, 22L, 14L, 10L, 20L, 6L, 6L, 
9L, 14L, 9L, 15L, 12L, 5L, 9L), .Label = c("0.01", "0.02", "0.03", 
"0.04", "0.05", "0.06", "0.07", "0.08", "0.09", "0.10", "0.11", 
"0.12", "0.13", "0.14", "0.15", "0.16", "0.17", "0.18", "0.19", 
"0.20", "0.21", "0.22", "0.23", "0.24", "0.25", "0.26", "0.27", 
"0.28", "0.29", "0.30", "0.31", "0.34", "0.35", "0.36", "0.39", 
"0.42", "0.43", "0.44", "0.49", "0.53", "0.56", "0.62", "0.68"
), class = "factor"), M_MEP_µg.gCrea = structure(c(3L, 1L, 5L, 
4L, 2L, 7L, 5L, 3L, 2L, 4L, 3L, 2L, 10L, 2L, 3L, 16L, 5L, 2L, 
9L, 4L, 15L, 2L, 3L, 4L, 8L, 7L, 9L, 3L, 11L, 6L, 12L, 1L, 11L, 
4L, 1L, 6L, 4L, 3L, 6L, 2L, 14L, 14L, 5L, 8L, 2L, 3L, 1L, 4L, 
4L, 2L, 2L, 8L, 8L, 17L, 3L, 17L, 5L, 10L, 7L, 2L, 2L, 2L, 7L, 
1L, 3L, 6L, 1L, 2L, 8L, 3L, 2L, 2L, 7L, 2L, 2L, 6L, 2L, 2L, 3L, 
4L, 2L, 3L, 1L, 5L, 4L, 6L, 2L, 2L, 3L, 2L, 2L, 4L, 2L, 4L, 3L, 
2L, 7L, 1L, 2L, 12L, 6L, 9L, 3L, 18L, 3L, 8L, 11L, 2L, 19L, 10L, 
4L, 7L, 7L, 1L, 4L, 2L, 2L, 2L, 11L, 2L, 5L, 5L, 5L, 1L, 1L, 
2L, 3L, 2L, 3L, 7L, 5L, 2L, 4L, 3L, 4L, 2L, 1L, 2L, 6L, 2L, 5L, 
5L, 3L, 17L, 4L, 2L, 13L, 8L, 3L, 5L, 4L, 3L, 1L, 9L, 3L), .Label = c("0.00", 
"0.01", "0.02", "0.03", "0.04", "0.05", "0.06", "0.07", "0.08", 
"0.09", "0.10", "0.11", "0.14", "0.16", "0.17", "0.18", "0.19", 
"0.21", "0.23"), class = "factor"), M_MBzP_µg.gCrea = structure(c(39L, 
34L, 9L, 23L, 28L, 41L, 13L, 13L, 12L, 40L, 3L, 18L, 44L, 6L, 
57L, 44L, 5L, 32L, 39L, 29L, 10L, 40L, 60L, 19L, 39L, 19L, 7L, 
23L, 17L, 37L, 4L, 27L, 15L, 35L, 4L, 14L, 9L, 52L, 12L, 17L, 
29L, 20L, 10L, 20L, 7L, 38L, 7L, 11L, 50L, 18L, 46L, 2L, 22L, 
23L, 31L, 26L, 14L, 8L, 58L, 43L, 12L, 23L, 10L, 39L, 31L, 42L, 
4L, 21L, 23L, 14L, 53L, 27L, 34L, 16L, 20L, 40L, 48L, 32L, 4L, 
38L, 45L, 29L, 12L, 19L, 20L, 14L, 22L, 25L, 33L, 13L, 4L, 26L, 
18L, 6L, 44L, 13L, 45L, 4L, 42L, 30L, 20L, 15L, 15L, 16L, 36L, 
32L, 11L, 25L, 12L, 20L, 17L, 51L, 29L, 21L, 11L, 56L, 35L, 8L, 
40L, 28L, 33L, 17L, 49L, 14L, 13L, 1L, 17L, 59L, 14L, 47L, 22L, 
8L, 10L, 27L, 54L, 55L, 3L, 18L, 20L, 31L, 11L, 6L, 24L, 10L, 
9L, 10L, 26L, 7L, 3L, 7L, 29L, 14L, 18L, 4L, 16L), .Label = c("0.01", 
"0.03", "0.05", "0.06", "0.08", "0.09", "0.10", "0.11", "0.13", 
"0.14", "0.15", "0.16", "0.17", "0.18", "0.19", "0.20", "0.21", 
"0.22", "0.23", "0.24", "0.25", "0.26", "0.27", "0.28", "0.29", 
"0.30", "0.34", "0.35", "0.36", "0.37", "0.39", "0.40", "0.41", 
"0.42", "0.43", "0.44", "0.45", "0.46", "0.47", "0.50", "0.51", 
"0.52", "0.53", "0.55", "0.56", "0.57", "0.59", "0.62", "0.66", 
"0.75", "0.76", "0.77", "0.79", "0.80", "0.82", "0.86", "0.90", 
"0.99", "1.04", "1.23"), class = "factor"), M_MiBP_µg.gCrea = structure(c(4L, 
2L, 4L, 5L, 3L, 6L, 3L, 6L, 4L, 3L, 2L, 4L, 8L, 4L, 7L, 8L, 3L, 
6L, 4L, 4L, 2L, 6L, 2L, 3L, 5L, 6L, 6L, 2L, 7L, 2L, 4L, 3L, 6L, 
5L, 8L, 9L, 7L, 3L, 3L, 4L, 3L, 5L, 4L, 2L, 4L, 5L, 4L, 3L, 4L, 
3L, 4L, 4L, 3L, 5L, 5L, 3L, 3L, 5L, 6L, 4L, 4L, 5L, 8L, 2L, 5L, 
5L, 5L, 4L, 5L, 5L, 5L, 4L, 6L, 7L, 8L, 3L, 6L, 8L, 5L, 6L, 7L, 
6L, 4L, 5L, 4L, 7L, 4L, 4L, 5L, 4L, 2L, 5L, 5L, 6L, 7L, 4L, 6L, 
6L, 8L, 4L, 4L, 2L, 2L, 7L, 6L, 4L, 3L, 7L, 6L, 4L, 6L, 7L, 5L, 
8L, 8L, 6L, 5L, 5L, 4L, 2L, 3L, 4L, 5L, 4L, 3L, 1L, 3L, 5L, 4L, 
3L, 4L, 2L, 2L, 3L, 3L, 6L, 3L, 3L, 7L, 4L, 2L, 5L, 4L, 7L, 4L, 
2L, 3L, 3L, 7L, 5L, 5L, 5L, 5L, 2L, 5L), .Label = c("0.00", "0.01", 
"0.02", "0.03", "0.04", "0.05", "0.06", "0.07", "0.08"), class = "factor"), 
    M_MnBP_µg.gCrea = structure(c(5L, 3L, 5L, 8L, 4L, 5L, 3L, 
    9L, 3L, 2L, 2L, 4L, 9L, 3L, 18L, 9L, 2L, 6L, 4L, 8L, 4L, 
    4L, 4L, 1L, 8L, 5L, 7L, 2L, 7L, 5L, 5L, 5L, 4L, 11L, 4L, 
    10L, 8L, 6L, 3L, 5L, 3L, 9L, 7L, 4L, 3L, 9L, 2L, 2L, 7L, 
    3L, 4L, 4L, 4L, 8L, 5L, 3L, 5L, 4L, 15L, 5L, 4L, 5L, 11L, 
    5L, 10L, 9L, 9L, 5L, 5L, 7L, 12L, 8L, 7L, 6L, 16L, 7L, 10L, 
    10L, 7L, 13L, 11L, 9L, 6L, 10L, 9L, 4L, 8L, 7L, 8L, 5L, 5L, 
    9L, 5L, 13L, 8L, 5L, 10L, 11L, 13L, 8L, 3L, 7L, 3L, 12L, 
    10L, 11L, 6L, 14L, 9L, 5L, 9L, 13L, 11L, 15L, 12L, 17L, 11L, 
    9L, 8L, 2L, 6L, 5L, 6L, 4L, 4L, 1L, 6L, 14L, 3L, 8L, 6L, 
    2L, 4L, 4L, 12L, 10L, 2L, 3L, 13L, 6L, 9L, 7L, 6L, 11L, 6L, 
    5L, 5L, 9L, 5L, 14L, 8L, 10L, 4L, 8L, 10L), .Label = c("0.00", 
    "0.01", "0.02", "0.03", "0.04", "0.05", "0.06", "0.07", "0.08", 
    "0.09", "0.10", "0.11", "0.12", "0.13", "0.14", "0.16", "0.18", 
    "0.20"), class = "factor"), UMA08 = c(56L, 60L, 55L, 67L, 
    61L, 60L, 85L, 61L, 65L, 65L, 74L, 45L, 66L, 67L, 50L, 100L, 
    80L, 68L, 82L, 66L, 62L, 56L, 60L, 70L, 57L, 66L, 69L, 68L, 
    58L, 90L, 52L, 92L, 60L, 78L, 70L, 73L, 68L, 80L, 53L, 65L, 
    56L, 61L, 59L, 52L, 58L, 70L, 65L, 61L, 79L, 50L, 105L, 65L, 
    69L, 90L, 85L, 99L, 74L, 62L, 80L, 63L, 60L, 73L, 82L, 58L, 
    80L, 51L, 69L, 105L, 62L, 95L, 60L, 90L, 64L, 70L, 96L, 63L, 
    53L, 70L, 52L, 70L, 58L, 63L, 62L, 87L, 62L, 87L, 60L, 54L, 
    65L, 76L, 56L, 65L, 46L, 60L, 67L, 65L, 66L, 50L, 60L, 58L, 
    52L, 55L, 65L, 68L, 55L, 73L, 64L, 63L, 61L, 59L, 60L, 74L, 
    73L, 90L, 57L, 68L, 55L, 59L, 64L, 78L, 110L, 84L, 58L, 50L, 
    72L, 68L, 65L, 88L, 66L, 75L, 57L, 70L, 65L, 60L, 65L, 73L, 
    58L, 83L, 75L, 60L, 60L, NA, 70L, 85L, 56L, 55L, 58L, 64L, 
    53L, 80L, 69L, 59L, 50L, 53L, 56L), UMA09 = c(163L, 165L, 
    162L, 175L, 175L, 168L, 168L, 159L, 160L, 166L, 173L, 156L, 
    166L, 170L, 160L, 170L, 170L, 168L, 167L, 163L, 171L, 168L, 
    165L, 168L, 158L, 168L, 164L, 160L, 167L, 170L, 159L, 170L, 
    168L, 174L, 163L, 156L, 174L, 163L, 160L, 165L, 164L, 170L, 
    169L, 163L, 174L, 166L, 168L, 163L, 168L, 152L, 167L, 164L, 
    165L, 160L, 167L, 180L, 165L, 168L, 168L, 160L, 172L, 169L, 
    176L, 164L, 165L, 153L, 165L, 171L, 168L, 166L, 165L, 171L, 
    163L, 164L, 169L, 164L, 164L, 177L, 167L, 164L, 160L, 167L, 
    164L, 168L, 172L, 156L, 178L, 169L, 170L, 174L, 172L, 166L, 
    155L, 168L, 166L, 170L, 176L, 162L, 165L, 164L, 162L, 169L, 
    177L, 175L, 161L, 160L, 164L, 168L, 169L, 167L, 161L, 178L, 
    168L, 160L, 170L, 174L, 168L, 164L, 170L, 180L, 172L, 167L, 
    166L, 160L, 178L, 172L, 158L, 167L, 174L, 168L, 173L, 165L, 
    171L, 173L, 170L, 168L, 160L, 165L, 174L, 174L, 165L, 175L, 
    175L, 171L, 166L, 167L, 169L, 174L, 168L, 172L, 170L, 166L, 
    160L, 164L, 160L), BQF05M2 = c(35L, 37L, 38L, 30L, 34L, 33L, 
    39L, 40L, 42L, 45L, 38L, 37L, 38L, 33L, 35L, 30L, 35L, 33L, 
    44L, 30L, 42L, 40L, 43L, 37L, 39L, 34L, 35L, 35L, 39L, 33L, 
    32L, 44L, 43L, 40L, 37L, 36L, 40L, 34L, 33L, 40L, 37L, 34L, 
    42L, 40L, 35L, 37L, 35L, 41L, 32L, 44L, 36L, 30L, 35L, 31L, 
    42L, 33L, 42L, 37L, 43L, 35L, 32L, 38L, 36L, 36L, 36L, 32L, 
    34L, 36L, 38L, 32L, 40L, 47L, 40L, 40L, 38L, 34L, 36L, 45L, 
    39L, 43L, 35L, 48L, 41L, 37L, 42L, 48L, 42L, 46L, 40L, 50L, 
    45L, 44L, 41L, 43L, 45L, 42L, 39L, 48L, 40L, 37L, 35L, 37L, 
    36L, 42L, 43L, 39L, 43L, 44L, 42L, 39L, 43L, 37L, 41L, 35L, 
    42L, 37L, 41L, 36L, 41L, 45L, 40L, 39L, 47L, 47L, 34L, 34L, 
    41L, 35L, 39L, 39L, 37L, 49L, 31L, 38L, 39L, 33L, 38L, 38L, 
    45L, 37L, 43L, 40L, 46L, 52L, 41L, 45L, 43L, 38L, 46L, 43L, 
    41L, 47L, 45L, 41L, 42L)), class = "data.frame", row.names = c("1", 
"2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", 
"14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", 
"25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", 
"36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", 
"47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", 
"58", "59", "60", "61", "62", "63", "64", "65", "66", "67", "68", 
"69", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", 
"80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90", 
"91", "92", "93", "94", "95", "96", "97", "98", "99", "100", 
"101", "102", "103", "104", "105", "106", "107", "108", "109", 
"110", "111", "112", "113", "114", "115", "116", "117", "118", 
"119", "120", "121", "122", "123", "124", "125", "126", "127", 
"128", "129", "130", "131", "132", "133", "134", "135", "136", 
"137", "138", "139", "140", "141", "142", "143", "144", "145", 
"146", "147", "148", "149", "150", "151", "152", "153", "154", 
"155"))

我尝试了as.numeric:

Error: (list) object cannot be coerced to type 'double'

也将其不公开,这是行不通的。

现在我的问题是:我必须如何将M数据集转换为哪种格式?还是如果不可能:关于如何使用我的数据建立多元线性回归模型的任何建议?

更新:我尝试使用as.numeric(levels)

> conc <- as.numeric(levels(M))[M]
Error in as.numeric(levels(M))[M] : 
  invalid subscript type 'list'

M数据集最初是我转换为.CSV的excel表。也许有一种方法可以不将其加载到R中?数据集包含数字,因此,如果R不将线性模型视为一个因素,则线性模型通常不应成为问题。

0 个答案:

没有答案