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

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: cgam
> ### Title: Constrained Generalized Additive Model Fitting
> ### Aliases: cgam
> ### Keywords: cgam routine
> 
> ### ** Examples
> 
> # Example 1.
>   data(cubic)
>   # extract x
>   x <- cubic$x
> 
>   # extract y
>   y <- cubic$y
> 
>   # regress y on x with no restriction with lm()
>   fit.lm <- lm(y ~ x + I(x^2) + I(x^3))
> 
>   # regress y on x under the restriction: "increasing and convex"
>   fit.cgam <- cgam(y ~ incr.conv(x))
> 
>   # make a plot to compare the two fits
>   par(mar = c(4, 4, 1, 1))
>   plot(x, y, cex = .7, xlab = "x", ylab = "y")
>   lines(x, fit.cgam$muhat, col = 2, lty = 2)
>   lines(x, fitted(fit.lm), col = 1, lty = 1)
>   legend("topleft", bty = "n", c("constrained cgam fit", "unconstrained lm fit"), 
+   lty = c(2, 1), col = c(2, 1))
> 
> # Example 2.
> ## Not run: 
> ##D   library(gam)
> ##D   data(kyphosis)
> ##D   
> ##D   # regress Kyphosis on Age, Number, and Start under the restrictions:
> ##D   # "concave", "increasing and concave", and "decreasing and concave" 
> ##D   fit <- cgam(Kyphosis ~ conc(Age) + incr.conc(Number) + decr.conc(Start), 
> ##D   family = binomial(), data = kyphosis) 
> ## End(Not run)
> 
> # Example 3.
>   library(MASS)
>   data(Rubber)
>   
>   # regress loss on hard and tens under the restrictions:
>   # "decreasing" and "decreasing"
>   fit.cgam <- cgam(loss ~ decr(hard) + decr(tens), data = Rubber)
>   # "smooth and decreasing" and "smooth and decreasing"
>   fit.cgam.s <- cgam(loss ~ s.decr(hard) + s.decr(tens), data = Rubber)
>   summary(fit.cgam.s)
Call:
cgam(formula = loss ~ s.decr(hard) + s.decr(tens), data = Rubber)

Coefficients:
            Estimate   StdErr t.value   p.value    
(Intercept) 175.4333   5.9624  29.423 < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for gaussian family taken to be 606.8062)

Null deviance:  225011.4  on 29  degrees of freedom 
Residual deviance:  17597.38  on 16.5  observed degrees of freedom 

Approximate significance of constrained components: 
             edf mixture.of.Beta   p.value    
s.decr(hard) 7.5          0.8772 < 2.2e-16 ***
s.decr(tens) 4.5          0.8166 < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
CIC:  10.0851>   anova(fit.cgam.s)

Family: gaussian 
Link function: identity 

Formula:
cgam(formula = loss ~ s.decr(hard) + s.decr(tens), data = Rubber)

Approximate significance of smooth terms: 
             edf mixture.of.Beta   p.value    
s.decr(hard) 7.5          0.8772 < 2.2e-16 ***
s.decr(tens) 4.5          0.8166 < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>   
>   # make a 3D plot based on fit.cgam and fit.cgam.s
>   plotpersp(fit.cgam, th = 120, main = "3D Plot of a Cgam Fit")
>   plotpersp(fit.cgam.s, tens, hard, data = Rubber, th = 120, main = "3D Plot of a Smooth Cgam Fit")
> 
> # Example 4. monotonic variance estimation
>   n <- 400
>   x <- runif(n)
>   sig <- .1 + exp(15*x-8)/(1+exp(15*x-8))
>   e <- rnorm(n)
>   mu <- 10*x^2
>   y <- mu + sig*e
> 
>   fit <- cgam(y ~ s.incr.conv(x), var.est = s.incr(x))
>   est.var <- fit$vh
>   muhat <- fit$muhat
> 
>   par(mfrow = c(1, 2))
>   plot(x, y)
>   points(sort(x), muhat[order(x)], type = "l", lwd = 2, col = 2)
>   lines(sort(x), (mu)[order(x)], col = 4)
> 
>   plot(sort(x), est.var[order(x)], col=2, lwd=2, type="l", 
+   lty=2, ylab="Variance", ylim=c(0, max(c(est.var, sig^2))))
>   points(sort(x), (sig^2)[order(x)], col=1, lwd=2, type="l")
> 
> # Example 5. monotonic variance estimation with the lidar data set in SemiPar
>   library(SemiPar)
>   data(lidar)
> 
>   fit <- cgam(logratio ~ s.decr(range), var.est=s.incr(range), data=lidar)
Error in attr(x, "nm") <- deparse(pars$x) : 
  cannot set attribute on a 'builtin'
Calls: cgam -> cgam.fit -> s.incr
Execution halted