# R's na.rm equivalent in Julia for ignoring missing values during inference?

Do we have anything like r’s na.rm attribute in Julia for Turing.jl for ignoring missing values? I have a data with missing values which is causing issue during sampling.

Don’t know `Turing.jl`, but the julia way to “ignore” missing values is to “skip” them:

``````julia> x = [1,missing,3]
3-element Vector{Union{Missing, Int64}}:
1
missing
3

julia> sum(x)
missing

julia> sum(skipmissing(x))
4
``````
2 Likes

This I know but I’m looking for something like this as shown below.

`````` for i in 1:n
for j in 1:size(data[i])[2]

data[i][:,j] ~ MvNormal(predicted[i] ,  σ)

end
end
``````

How valid is this ?

``````for j in 1:size(data)[2]
for k in 1:size(data)[1]

if ismissing(data[k,j]) == true
continue
end

data[k,j] ~ Normal(predicted[k] ,  σ*(data[k,j] .+10^-5))

end
end
``````

Basically yes, but the more idiomatic way may be with a guard like this:

``````for j in axes(data, 2)
for k in axes(data, 1)
ismissing(data[k, j]) && continue

data[k,j] ~ Normal(predicted[k] ,  σ*(data[k,j] .+10^-5))
end
end
``````