Create Parameters for Simulation with Uncertainty
Usage
simpar(
nsim,
theta,
covar,
omega,
sigma,
odf = NULL,
sdf = NULL,
digits = 4,
min = -Inf,
max = Inf
)
Arguments
- nsim
scalar numeric specifying the number of sets to attempt
- theta
vector of point estimates of fixed effect parameters
- covar
variance-covariance matrix for fixed effect parameters
- omega
list of variance-covariance matrices for first level random effects
- sigma
list of variance-covariance matrices for second level random effects
- odf
vector of omega degrees of freedom, one per matrix
- sdf
vector of sigma degrees of freedom, one per matrix
- digits
number of significant digits to include in output
- min
lower limit for parameter estimates
- max
upper limit for parameter estimates
Value
matrix, with column names indicating parameters, and row names indicating set number before filtering by min and max.
Details
If min or max are non-default (see below), you may want to set nsim marginally higher to allow for dropped sets. covar is coerced to matrix using as.matrix.
If omega and sigma are not lists, they are coerced using list. Then each element is coerced using as.matrix.
By default, each element in odf and sdf will be the length (number of elements) in the corresponding matrix.
min
and max
may be given as scalar values, in which case they apply to
all parameters (as do the defaults). Alternatively, the first n limits may
be specified as a vector, in which case the remaining (if any) will be the
default. If any simulated parameter does not fall between its limits, inclusive,
the entire parameter set (row) is dropped from the result, with warning.
Examples
set.seed(100)
simpar(
nsim=10,
theta=c(13,75,1),
covar=matrix(c(10,7,2,7,30,1,2,1,0.5),ncol=3,nrow=3),
omega=list(
0.1,
matrix(c(0.04,0.02,0.02,0.04),ncol=2,nrow=2)
),
odf=c(50,20),
sigma=list(0.04,1),
sdf=c(99,99),
min=rep(0,3),
max=rep(90,3)
)
#> TH.1 TH.2 TH.3 OM1.1 OM2.2 OM3.2 OM3.3 SG1.1 SG2.2
#> 1 14.13 77.63 1.0640 0.10390 0.04442 0.007829 0.03910 0.03569 1.0690
#> 2 12.98 74.21 1.2430 0.09322 0.05781 0.048300 0.07054 0.04070 1.0910
#> 3 12.59 75.60 0.9816 0.11000 0.06001 0.009597 0.03225 0.04675 1.0330
#> 4 13.38 69.56 1.4090 0.11790 0.10790 0.061510 0.06000 0.03660 0.9531
#> 5 13.18 74.26 0.8007 0.11190 0.08363 0.046380 0.07052 0.04134 1.2040
#> 6 12.40 73.30 0.7659 0.09395 0.03944 0.017340 0.07900 0.03551 0.9038
#> 7 13.02 78.48 0.7257 0.08317 0.05386 0.027630 0.04757 0.04314 0.8023
#> 8 13.11 70.69 1.1650 0.08464 0.04884 0.041840 0.08535 0.04101 0.8885
#> 9 12.07 80.26 0.3608 0.10420 0.03331 -0.006786 0.06227 0.03728 0.8611
#> 10 19.73 74.93 2.5130 0.06927 0.06935 0.050570 0.05766 0.03791 0.9706
simpar(
nsim=1,
theta=c(13,75,1),
covar=matrix(c(10,7,2,7,30,1,2,1,0.5),ncol=3,nrow=3),
omega=list(
0.1,
matrix(c(0.04,0.02,0.02,0.04),ncol=2,nrow=2)
),
odf=c(50,20),
sigma=list(0.04,1),
sdf=c(99,99),
min=rep(0,3),
max=rep(90,3)
)
#> TH.1 TH.2 TH.3 OM1.1 OM2.2 OM3.2 OM3.3 SG1.1 SG2.2
#> 1 15.18 75.47 1.29 0.09543 0.03465 0.01318 0.07248 0.0442 1.26
simpar(
nsim=1,
theta=c(13,75,1),
covar=matrix(c(10,7,2,7,30,1,2,1,0.5),ncol=3,nrow=3),
omega=list(
0.1,
matrix(c(0.04,0.02,0.02,0.04),ncol=2,nrow=2)
),
odf=c(50,20),
sigma=list(0.04,1),
sdf=c(99,99),
min=Inf,
max=-1
)
#> Warning: 1 of 1 rows dropped
#> TH.1 TH.2 TH.3 OM1.1 OM2.2 OM3.2 OM3.3 SG1.1 SG2.2