<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span>Bom dia,</span></div><div><span></span> </div><div><span>estou com dificuldades em rodar um modelo no R que acredito ser devido aos NA. Apesar do software aparentemente remover os NA's na hora de rodar a funcao lm, quando ajusto meu modelo </span></div><div><span>model<-lm(cpstotalnorm~indconfident+indpride+indenergy+indgrowth+indseethingsnew+indinputstrategy<br> +indtrainingavailable+grppointsofview+grpconflictresol+grprightpeople+grpdifferentviews+grprethink<br> +grplessonss)</span></div><div><span></span> </div><div><span>recebo um erro "error contrasts can be applied only to factors with 2 or more levels", pesquisei sobre o erro e vi que poderiam ser dois casos: ou as variáveis poderiam estar
definidas como caracteres e nao como fatores - o que nao é o caso, ou há NA's no conjunto de dados - é o caso.</span></div><div><span></span> </div><div><span>Tentei retirar entao os NA's dos dados para rodr o modelo, porém usando a funcao:</span></div><div><span>datanew<-na.omit(data) </span></div><div><span></span> </div><div><span>o R retira todas as observacoes, e nao só o NA, por exemplo:</span></div><div><span></span> </div><div><span><span style='font: 13px/15px "Lucida Console"; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: pre-wrap; border-collapse: separate; orphans: 2; widows: 2; background-color: rgb(225, 226, 229); -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;' class="Apple-style-span"><span style="color: blue;
white-space: pre;" class="GNVMTOMCDBB ace_keyword">> </span><span style="color: blue;" class="GNVMTOMCHAB ace_keyword">datanew$indseethingsnew<br></span>factor(0)<br>Levels: 1 2 3 4 5 6 7</span></span></div><div><span><span style='font: 13px/15px "Lucida Console"; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: pre-wrap; border-collapse: separate; orphans: 2; widows: 2; background-color: rgb(225, 226, 229); -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;' class="Apple-style-span"></span></span> </div><div><span><span style='font: 13px/15px "Lucida Console"; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: pre-wrap; border-collapse: separate; orphans: 2; widows: 2;
background-color: rgb(225, 226, 229); -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;' class="Apple-style-span">enquanto se retiro somente os NA's dessa variável, no conjunto de dados original, ele mantém todas as outras observacoes:</div><pre style='margin: 0px; line-height: 1.2; font-family: "Lucida Console"; font-size: 10pt !important; white-space: pre-wrap !important; outline-style: none; -webkit-user-select: text;' class="GNVMTOMCABB" tabIndex="0"><span style="color: blue; white-space: pre;" class="GNVMTOMCDBB ace_keyword">> </span><span style="color: blue;" class="GNVMTOMCHAB ace_keyword">c<-na.omit(data$indseethingsnew)
</span><span style="color: blue; white-space: pre;" class="GNVMTOMCDBB ace_keyword">> </span><span style="color: blue;" class="GNVMTOMCHAB ace_keyword">c
</span> [1] 2 2 2 3 1 3 1 2 1 1 2 3 3 3 3 2 2 1 3 4 1 1 4 3 2 3 1 2 2 1 5 2 1 3 1 1 1 6 3 1 2 1 1 1 1 2 1 2 1 3 1
[52] 3 2 5 1 5 1 1 3 2 1 2 2 1 2 2 1 1 2 2 1 2 1 2 2 1 1 2 2 3 2 2 1 2 2 2 2 3 1 3 2 2 1 3 1 2 2 1 2 3 2 1
[103] 2 1 2 4 2 1 1 2 2 1 3 3 2 2 1 1 6 2 1 2 4 2 3 3 2 2 2 2 1 3 6 1 1 3 2 3 3 1 2 3 2 2 7 2 3 2 1 3 4 1 2
[154] 3 2 1 3
attr(,"na.action")
[1] 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] 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] 85 86 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
[76] 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
[101] 211 212 213 214 215 216 217 218 219
attr(,"class")
[1] "omit"
Levels: 1 2 3 4 5 6 7
</pre><pre style='margin: 0px; line-height: 1.2; font-family: "Lucida Console"; font-size: 10pt !important; white-space: pre-wrap !important; outline-style: none; -webkit-user-select: text;' class="GNVMTOMCABB" tabIndex="0"> </pre><pre style='margin: 0px; line-height: 1.2; font-family: "Lucida Console"; font-size: 10pt !important; white-space: pre-wrap !important; outline-style: none; -webkit-user-select: text;' class="GNVMTOMCABB" tabIndex="0">Entao meu novo conjunto de dados datanew contém apenas zeros!</pre><pre style='margin: 0px; line-height: 1.2; font-family: "Lucida Console"; font-size: 10pt !important; white-space: pre-wrap !important; outline-style: none; -webkit-user-select: text;' class="GNVMTOMCABB" tabIndex="0"> </pre><pre style='margin: 0px; line-height: 1.2; font-family: "Lucida Console"; font-size: 10pt !important; white-space: pre-wrap !important; outline-style: none; -webkit-user-select: text;' class="GNVMTOMCABB"
tabIndex="0">Alguém teria alguma sugestao?</pre><pre style='margin: 0px; line-height: 1.2; font-family: "Lucida Console"; font-size: 10pt !important; white-space: pre-wrap !important; outline-style: none; -webkit-user-select: text;' class="GNVMTOMCABB" tabIndex="0"> </pre><pre style='margin: 0px; line-height: 1.2; font-family: "Lucida Console"; font-size: 10pt !important; white-space: pre-wrap !important; outline-style: none; -webkit-user-select: text;' class="GNVMTOMCABB" tabIndex="0">Obrigada,</pre><pre style='margin: 0px; line-height: 1.2; font-family: "Lucida Console"; font-size: 10pt !important; white-space: pre-wrap !important; outline-style: none; -webkit-user-select: text;' class="GNVMTOMCABB" tabIndex="0">Daniela</pre></span></span><div></div><div> </div><div><span style="font-size: 16px;">-- <br>Daniela Rodrigues Recchia</span></div><div><span style="font-size: 16px;">M.Sc. in Statistics<br></span></div><div style="color: rgb(0, 0,
0); font-family: arial, helvetica, clean, sans-serif; font-style: normal; background-color: transparent;"><span style="font-size: medium;"><br></span></div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, clean, sans-serif; font-style: normal; background-color: transparent;"><span style="font-size: 13px;">Tel. (Mobil): +49 01578 7588382</span></div><div><span style="font-size: 16px;">Kißlegg - Germany</span></div><div><span style="font-size: small;"><br></span></div><div><span style="font-size: x-small;"><br></span></div><div><span style="font-size: x-small;"><span style='line-height: 18px; font-family: "helvetica neue", arial, sans-serif; font-style: italic;'>“The standard of success in life is absolutely the amount of joy you feel”</span><br></span></div><div style="background-color: transparent;"><span style="font-size: small;"><span style="font-size: x-small;"><span style='line-height: 18px; font-family: "helvetica neue", arial,
sans-serif; font-style: italic;'>Esther & Jerry Hick</span></span><br></span></div><div><span style="font-size: small;"> </span></div></div></body></html>