Hi,

I am trying to implement a QML estimation problem with a system of censored equations. I am trying this with Julia’s Optim library. However, I have not been able to build a working model. I get an error message:

`MethodError: no method matching zero(::Type{Array{Float64,2}})`

.

I am new to Julia and I could use some help on where to proceed next. I use Julia 0.6.2 with the most current packages.

Here is a working example with fake data of what I’ve got thus far:

```
using Distributions, Optim
nrows = 1000
X = rand(0:1, nrows, 3)
X = [ones(nrows) X]
Y = rand(Truncated(Normal(.5), 0, 1), nrows, 2)
nShares = size(Y,2)
nVars = size(X,2)
function censQML(Y, X)
ll = 0
for t in 1:nrows
for i in 1:nShares
for j in 1:nShares
if j != i
e_i(δ,σ) = (Y[t,i] - *(X[t,:], δ[:,i]))/σ[:,i]
e_j(δ,σ) = (Y[t,j] - *(X[t,:], δ[:,j]))/σ[:,j]
ρ(δ,σ) = tanh(cor(e_i(δ,σ), e_j(δ,σ)))
w(δ,σ) = e_i(δ,σ).^2 + e_j(δ,σ).^2 - 2.*ρ(δ,σ).*e_i(δ,σ).*e_j(δ,σ)
if (Y[t,i] == 0) & (Y[t,j] == 0)
l(δ,σ) = logpdf(MvNormal([0, 0], ρ(δ,σ)), [e_i(δ,σ), e_j(δ,σ)])
end
if (Y[t,i] == 1) & (Y[t,j] == 0)
l(δ,σ) = logpdf(MvNormal([1, 0], -ρ(δ,σ)), [-e_i(δ,σ), e_j(δ,σ)])
end
if (Y[t,i] == 0) & (Y[t,j] == 1)
l(δ,σ) = logpdf(MvNormal([0, 1], -ρ(δ,σ)), [e_i(δ,σ), -e_j(δ,σ)])
end
if (0 < Y[t,i] < 1) & (0 < Y[t,j] < 1)
l(δ,σ) = -log(2.*pi.*sqrt(1 - ρ(δ,σ).^2)) - σ[t,i] - σ[t,j] - w(δ,σ)./(2.*(1 - ρ(δ,σ).^2))
end
if (0 < Y[t,i] < 1) & (Y[t,j] == 0)
l(δ,σ) = log(1./exp(σ[t,i])*pdf(Normal(0, σ[t,i]), e_i(δ,σ)))
end
if (Y[t,i] == 0) & (0 < Y[t,j] < 1)
l(δ,σ) = log(1./exp(σ[t,j])*pdf(Normal(0, σ[t,j]), e_j(δ,σ)))
end
#ll = ll + l(δ,σ)
end
end
end
end
end
censQMLfn = censQML(Y, X)
δ0 = Array{Float64}(nVars,nShares)
σ0 = Array{Float64}(nVars,nShares)
res = optimize(censQMLfn, [δ0, σ0], BFGS())
```

Any help would be greatly appreciated. I’ve already benefited from two blog posts that have guided my attempt:

https://www.codementor.io/zhuojiadai/julia-vs-r-vs-python-simple-optimization-gnqi4njro

https://github.com/setzler/JuliaEconomics/blob/master/Tutorials/tutorial_2.jl