Skip to content

Commit 31dd5b3

Browse files
authored
convert incoming parameters in simulate! and parametric bootstrap (#259)
1 parent 11312e4 commit 31dd5b3

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/simulate.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ function parametricbootstrap(
6363
θ = morig.θ,
6464
use_threads = false,
6565
) where {T}
66+
β = convert(Vector{T},β)
67+
σ = T(σ)
68+
θ = convert(Vector{T},θ)
6669
βsc, θsc, p, k, m = similar(β), similar(θ), length(β), length(θ), deepcopy(morig)
6770
y₀ = copy(response(m))
6871
# we need to do for in-place operations to work across threads
@@ -151,6 +154,9 @@ function simulate!(
151154
σ = m.σ,
152155
θ = T[],
153156
) where {T}
157+
β = convert(Vector{T},β)
158+
σ = T(σ)
159+
θ = convert(Vector{T},θ)
154160
isempty(θ) || setθ!(m, θ)
155161

156162
y = randn!(rng, response(m)) # initialize y to standard normal

test/pls.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,10 @@ end
304304
@testset "simulate!" begin
305305
ds = MixedModels.dataset(:dyestuff)
306306
fm = fit(MixedModel, @formula(yield ~ 1 + (1|batch)), ds)
307+
resp₀ = copy(response(fm))
308+
# type conversion of ints to floats
309+
simulate!(Random.MersenneTwister(1234321), fm, β=[1], σ=1)
310+
refit!(fm,resp₀)
307311
refit!(simulate!(Random.MersenneTwister(1234321), fm))
308312
@test deviance(fm) 339.0218639362958 atol=0.001
309313
refit!(fm, float(ds.yield))
@@ -313,6 +317,8 @@ end
313317
simulate!(fm, θ = fm.θ)
314318
@test_throws DimensionMismatch refit!(fm, zeros(29))
315319

320+
# type conversion of ints to floats
321+
parametricbootstrap(Random.MersenneTwister(1234321), 1, fm, β=[1], σ=1)
316322
# this should give the same results as passing with
317323
# MersenneTwister(1234321)
318324
# by setting the seed first, we test the method for the default RNG

0 commit comments

Comments
 (0)