Abaixo o exemplo que estou rodando em minha maquina, e em seguida o erro.<br>Mesmo com o <b>rnorm(1)</b>, que o Benilton me corrigiu.<br><br>Abraço<br><br>Ricardo<br><br><br>## Simulacao de dados<br>set.seed(456)<br>n <- 50<br>
var <- 150<br>x <- matrix(0, 1000, 5)<br>w <- matrix(0, 1000, 1)<br>y <- matrix(0, 1000, 1)<br>b <- matrix(0, 1000, 1)<br><br>## Gera w's para a matriz w<br>  for (i in 1:1000)<br>    {<br>    x [i,1] <- i<br>
    w[i] <- rnorm (1) *sqrt(var)<br>    y[i] <- NULL<br>    if i <= n<br>    b[i] <- 1<br>    else b[i] <- 2<br>    }<br><br><br><br><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Arial; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -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; font-size: medium; "><span class="Apple-style-span" style="font-family: 'Lucida Console'; font-size: 16px; line-height: 20px; text-align: -webkit-left; white-space: pre-wrap; "><pre tabindex="0" class="GD40030CLR" style="font-family: 'Lucida Console'; font-size: 12pt !important; outline-style: none; outline-width: initial; outline-color: initial; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; white-space: pre-wrap !important; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; line-height: 1.3; ">
<span class="GD40030CGR">Erro: símbolo inesperado em:
"    y[i] <- NULL
    if i"
</span><span class="GD40030COR ace_keyword" style="white-space: pre; color: rgb(127, 0, 85); ">> </span><span class="GD40030CCR ace_keyword" style="color: rgb(127, 0, 85); ">    b[i] <- 1
</span><span class="GD40030CGR">Erro em b[i] <- 1 : objeto 'i' não encontrado
</span><span class="GD40030COR ace_keyword" style="white-space: pre; color: rgb(127, 0, 85); ">> </span><span class="GD40030CCR ace_keyword" style="color: rgb(127, 0, 85); ">    else b[i] <- 2
</span><span class="GD40030CGR">Erro: 'else' inesperado em "    else"
</span><span class="GD40030COR ace_keyword" style="white-space: pre; color: rgb(127, 0, 85); ">> </span><span class="GD40030CCR ace_keyword" style="color: rgb(127, 0, 85); ">    }
</span><span class="GD40030CGR">Erro: '}' inesperado em "    }"</span></pre></span></span><br><br><br><br><br>