Running examples in ‘csurvey-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: csvy
> ### Title: Estimation of Domain Means with Monotonicity or Convexity
> ###   Constraints
> ### Aliases: csvy summary.csvy vcov.csvy predict.csvy coef.csvy
> ###   confint.csvy plotpersp.csvy barplot.csvy
> ### Keywords: main routine
> 
> ### ** Examples
> 
> data(api)
> 
> mcat = apipop$meals
> for(i in 1:10){mcat[trunc(apipop$meals/10)+1==i] = i}
> mcat[mcat==100]=10
> D1 = 10
> 
> gcat = apipop$col.grad
> for(i in 1:10){gcat[trunc(apipop$col.grad/10)+1==i] = i}
> gcat[gcat >= 5] = 4
> D2 = 4
> 
> nsp = c(200,200,200)  ## sample sizes per stratum
> 
> es = sample(apipop$snum[apipop$stype=='E'&!is.na(apipop$avg.ed)&!is.na(apipop$api00)],nsp[1])
> ms = sample(apipop$snum[apipop$stype=='M'&!is.na(apipop$avg.ed)&!is.na(apipop$api00)],nsp[2])
> hs = sample(apipop$snum[apipop$stype=='H'&!is.na(apipop$avg.ed)&!is.na(apipop$api00)],nsp[3])
> sid = c(es,ms,hs)
> 
> pw = 1:6194*0+4421/nsp[1]
> pw[apipop$stype=='M'] = 1018/nsp[2]
> pw[apipop$stype=='H'] = 755/nsp[3]
> 
> fpc = 1:6194*0+4421
> fpc[apipop$stype=='M'] = 1018
> fpc[apipop$stype=='H'] = 755
> 
> strsamp = cbind(apipop,mcat,gcat,pw,fpc)[sid,]
> 
> dstrat = svydesign(ids=~snum, strata=~stype, fpc=~fpc, data=strsamp, weight=~pw)
> rds = as.svrepdesign(dstrat, type="JKn")
> 
> # Example 1: monotonic in one dimension
> ansc1 = csvy(api00~decr(mcat), design=rds, nD=D1)

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution

warning: solve(): system is singular; attempting approx solution
> # checked estimated domain means
> # ansc1$muhat
> 
> # Example 2: monotonic in three dimensions
> D1 = 5
> D2 = 5
> D3 = 6
> Ds = c(D1, D2, D3)
> M = cumprod(Ds)[3]
> 
> x1vec = 1:D1
> x2vec = 1:D2
> x3vec = 1:D3
> grid = expand.grid(x1vec, x2vec, x3vec)
> N = M*100*4
> Ns = rep(N/M, M)
> 
> mu.f = function(x) {
+   mus = x[1]^(0.25)+4*exp(0.5+2*x[2])/(1+exp(0.5+2*x[2]))+sqrt(1/4+x[3])
+   mus = as.numeric(mus$Var1)
+   return (mus)
+ }
> 
> mus = mu.f(grid)
> 
> H = 4
> nh = c(180,360,360,540)
> n = sum(nh)
> Nh = rep(N/H, H)
> 
> #generate population
> y = NULL
> z = NULL
> 
> set.seed(1)
> for(i in 1:M){
+   Ni = Ns[i]
+   mui = mus[i]
+   ei = rnorm(Ni, 0, sd=1)
+   yi = mui + ei
+   y = c(y, yi)
+   zi = i/M + rnorm(Ni, mean=0, sd=1)
+   z = c(z, zi)
+ }
> 
> x1 = rep(grid[,1], times=Ns)
> x2 = rep(grid[,2], times=Ns)
> x3 = rep(grid[,3], times=Ns)
> domain = rep(1:M, times=Ns)
> 
> cts = quantile(z, probs=seq(0,1,length=5))
> strata = 1:N*0
> strata[z >= cts[1] & z < cts[2]] = 1
> strata[z >= cts[2] & z < cts[3]] = 2
> strata[z >= cts[3] & z < cts[4]] = 3
> strata[z >= cts[4] & z <= cts[5]] = 4
> freq = rep(N/(length(cts)-1), n)
> 
> w0 = Nh/nh
> w = 1:N*0
> w[strata == 1] = w0[1]
> w[strata == 2] = w0[2]
> w[strata == 3] = w0[3]
> w[strata == 4] = w0[4]
> pop = data.frame(y = y, x1 = x1, x2 = x2, x3 = x3, domain = domain, strata = strata, w=w)
> ssid = stratsample(pop$strata, c("1"=nh[1], "2"=nh[2], "3"=nh[3], "4"=nh[4]))
> sample.stsi = pop[ssid, ,drop=FALSE]
> ds = svydesign(id=~1, strata =~strata, fpc=~freq, weights=~w, data=sample.stsi)
> 
> 
> #domain means are increasing w.r.t x1, x2 and block monotonic in x3
> ord = c(1,1,2,2,3,3)
> ans = csvy(y~incr(x1)*incr(x2)*block.Ord(x3,order=ord), design=ds, nD=M, test=FALSE, n.mix=0)
> 
> #3D plot of estimated domain means: x1 and x2 with confidence intervals
> plotpersp(ans, ci = "both")
> 
> 
> #3D plot of estimated domain means: x3 and x2
> plotpersp(ans, x3, x2)
Warning in min(thvecs[x1id, xm[, 1] == x1a]) :
  no non-missing arguments to min; returning Inf
Warning in min(thvecs[x1id, xm[, 1] == x1b]) :
  no non-missing arguments to min; returning Inf
Warning in min(thvecs[x2id, xm[, 2] == x2a]) :
  no non-missing arguments to min; returning Inf
Warning in min(thvecs[x2id, xm[, 2] == x2b]) :
  no non-missing arguments to min; returning Inf
Error in xgmat[i1, i2] <- eta0 + th1add + th2add : 
  replacement has length zero
Calls: plotpersp -> plotpersp.cgam
Execution halted