Last updated on 2019-12-18 05:47:36 CET.
Flavor | Version | Tinstall | Tcheck | Ttotal | Status | Flags |
---|---|---|---|---|---|---|
r-devel-linux-x86_64-debian-clang | 0.9-3 | 9.75 | 161.96 | 171.71 | ERROR | |
r-devel-linux-x86_64-debian-gcc | 0.9-3 | 8.12 | 151.69 | 159.81 | OK | |
r-devel-linux-x86_64-fedora-clang | 0.9-3 | 242.32 | OK | |||
r-devel-linux-x86_64-fedora-gcc | 0.9-3 | 255.95 | OK | |||
r-devel-windows-ix86+x86_64 | 0.9-3 | 30.00 | 202.00 | 232.00 | OK | |
r-devel-windows-ix86+x86_64-gcc8 | 0.9-3 | 23.00 | 263.00 | 286.00 | OK | |
r-patched-linux-x86_64 | 0.9-3 | OK | ||||
r-patched-solaris-x86 | 0.9-3 | 357.50 | OK | |||
r-release-linux-x86_64 | 0.9-3 | 9.34 | 173.60 | 182.94 | OK | |
r-release-windows-ix86+x86_64 | 0.9-3 | 17.00 | 181.00 | 198.00 | OK | |
r-release-osx-x86_64 | 0.9-3 | OK | ||||
r-oldrel-windows-ix86+x86_64 | 0.9-3 | 13.00 | 246.00 | 259.00 | OK | |
r-oldrel-osx-x86_64 | 0.9-3 | OK |
Version: 0.9-3
Check: examples
Result: ERROR
Running examples in 'model4you-Ex.R' failed
The error most likely occurred in:
> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: pmforest
> ### Title: Compute model-based forest from model.
> ### Aliases: pmforest gettree.pmforest
>
> ### ** Examples
>
> library("model4you")
>
> if(require("mvtnorm") & require("survival")) {
+
+ ## function to simulate the data
+ sim_data <- function(n = 500, p = 10, beta = 3, sd = 1){
+
+ ## treatment
+ lev <- c("C", "A")
+ a <- rep(factor(lev, labels = lev, levels = lev), length = n)
+
+ ## correlated z variables
+ sigma <- diag(p)
+ sigma[sigma == 0] <- 0.2
+ ztemp <- rmvnorm(n, sigma = sigma)
+ z <- (pnorm(ztemp) * 2 * pi) - pi
+ colnames(z) <- paste0("z", 1:ncol(z))
+ z1 <- z[,1]
+
+ ## outcome
+ y <- 7 + 0.2 * (a %in% "A") + beta * cos(z1) * (a %in% "A") + rnorm(n, 0, sd)
+
+ data.frame(y = y, a = a, z)
+ }
+
+ ## simulate data
+ set.seed(123)
+ beta <- 3
+ ntrain <- 500
+ ntest <- 50
+ simdata <- simdata_s <- sim_data(p = 5, beta = beta, n = ntrain)
+ tsimdata <- tsimdata_s <- sim_data(p = 5, beta = beta, n = ntest)
+ simdata_s$cens <- rep(1, ntrain)
+ tsimdata_s$cens <- rep(1, ntest)
+
+ ## base model
+ basemodel_lm <- lm(y ~ a, data = simdata)
+
+ ## forest
+ frst_lm <- pmforest(basemodel_lm, ntree = 20,
+ perturb = list(replace = FALSE, fraction = 0.632),
+ control = ctree_control(mincriterion = 0))
+
+ ## personalised models
+ # (1) return the model objects
+ pmodels_lm <- pmodel(x = frst_lm, newdata = tsimdata, fun = identity)
+ class(pmodels_lm)
+ # (2) return coefficients only (default)
+ coefs_lm <- pmodel(x = frst_lm, newdata = tsimdata)
+
+ # compare predictive objective functions of personalised models versus
+ # base model
+ sum(objfun(pmodels_lm)) # -RSS personalised models
+ sum(objfun(basemodel_lm, newdata = tsimdata)) # -RSS base model
+
+
+ if(require("ggplot2")) {
+ ## dependence plot
+ dp_lm <- cbind(coefs_lm, tsimdata)
+ ggplot(tsimdata) +
+ stat_function(fun = function(z1) 0.2 + beta * cos(z1),
+ aes(color = "true treatment\neffect")) +
+ geom_point(data = dp_lm,
+ aes(y = aA, x = z1, color = "estimates lm"),
+ alpha = 0.5) +
+ ylab("treatment effect") +
+ xlab("patient characteristic z1")
+ }
+ }
Loading required package: survival
No data given. I'm using data set simdata from the current environment parent.frame(). Please check if that is what you want.
Warning in model.frame.default(object$predictf, data = newdata, na.action = na.pass, :
variable 'a' is not a factor
Warning in model.frame.default(object$predictf, data = newdata, na.action = na.pass, :
variable 'a' is not a factor
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
model4you
--- call from context ---
pmodel(x = frst_lm, newdata = tsimdata)
--- call from argument ---
if (class(ret) == "matrix") ret <- t(ret)
--- R stacktrace ---
where 1: pmodel(x = frst_lm, newdata = tsimdata)
--- value of length: 2 type: logical ---
[1] TRUE FALSE
--- function from context ---
function (x = NULL, model = NULL, newdata = NULL, OOB = TRUE,
fun = coef, return_attr = c("modelcall", "data", "similarity"))
{
if (is.matrix(x)) {
if (is.null(model))
stop("When x is a matrix, model must not be NULL. Please enter a model object.")
pweights <- x
}
else {
if (is.null(model))
model <- x$info$model
pweights <- predict(x, type = "weights", newdata = newdata,
OOB = OOB)
}
get_pmod <- function(w) {
if (sum(w) == 0)
stop("The weights for one observation are all 0. A solution may be increasing ntree.")
dat <- x$data
dat$w <- w
pmod <- update(model, weights = w, subset = w > 0, data = dat)
fun(pmod)
}
ret <- apply(pweights, 2, get_pmod)
if (class(ret) == "matrix")
ret <- t(ret)
if (all.equal(fun, identity) == TRUE)
class(ret) <- c("pmodel_identity", class(ret))
class(ret) <- c("pmodel", class(ret))
if ("modelcall" %in% return_attr)
attr(ret, "modelcall") <- getCall(model)
if ("data" %in% return_attr)
if (is.null(newdata))
attr(ret, "data") <- x$data
else attr(ret, "data") <- newdata
if ("similarity" %in% return_attr)
attr(ret, "similarity") <- pweights
return(ret)
}
<bytecode: 0x1015e318>
<environment: namespace:model4you>
--- function search by body ---
Function pmodel in namespace model4you has this body.
----------- END OF FAILURE REPORT --------------
Error in if (class(ret) == "matrix") ret <- t(ret) :
the condition has length > 1
Calls: pmodel
Execution halted
Flavor: r-devel-linux-x86_64-debian-clang
Version: 0.9-3
Check: tests
Result: ERROR
Running 'test-pmodel-test.R' [25s/29s]
Running 'test-pmodel.R' [21s/25s]
Running 'test-pmtree.R' [26s/28s]
Comparing 'test-pmtree.Rout' to 'test-pmtree.Rout.save' ...95c95,102
< | [2] age <= 50: n = 502
---
> | [2] age <= 50
> | | [3] age <= 42: n = 153
> | | (Intercept) trt2
> | | -0.1300531 0.5027284
> | | [4] age > 42: n = 371
> | | (Intercept) trt2
> | | -0.9932518 0.7773634
> | [5] age > 50: n = 476
97,100c104
< | -1.162126 1.162126
< | [3] age > 50: n = 498
< | (Intercept) trt2
< | -1.034074 1.980880
---
> | -0.7958013 1.9056497
102,103c106,107
< Number of inner nodes: 1
< Number of terminal nodes: 2
---
> Number of inner nodes: 2
> Number of terminal nodes: 3
105c109
< Objective function: 601.9864
---
> Objective function: 621.198
108c112,119
< | [2] age <= 50: n = 502
---
> | [2] age <= 50
> | | [3] age <= 42: n = 153
> | | (Intercept) trt2
> | | -0.1300531 0.5027284
> | | [4] age > 42: n = 371
> | | (Intercept) trt2
> | | -0.9932518 0.7773634
> | [5] age > 50: n = 476
110,113c121
< | -1.162126 1.162126
< | [3] age > 50: n = 498
< | (Intercept) trt2
< | -1.034074 1.980880
---
> | -0.7958013 1.9056497
115,116c123,124
< Number of inner nodes: 1
< Number of terminal nodes: 2
---
> Number of inner nodes: 2
> Number of terminal nodes: 3
118c126
< Objective function: 601.9864
---
> Objective function: 621.198
122c130,137
< | [2] age <= 50: n = 502
---
> | [2] age <= 50
> | | [3] age <= 42: n = 153
> | | (Intercept) trt2
> | | -0.1300531 0.5027284
> | | [4] age > 42: n = 371
> | | (Intercept) trt2
> | | -0.9932518 0.7773634
> | [5] age > 50: n = 476
124,127c139
< | -1.162126 1.162126
< | [3] age > 50: n = 498
< | (Intercept) trt2
< | -1.034074 1.980880
---
> | -0.7958013 1.9056497
129,130c141,142
< Number of inner nodes: 1
< Number of terminal nodes: 2
---
> Number of inner nodes: 2
> Number of terminal nodes: 3
132c144
< Objective function: 601.9864
---
> Objective function: 621.198
136c148,155
< | [2] age <= 50: n = 22
---
> | [2] age <= 50
> | | [3] age <= 43: n = 8
> | | (Intercept) trt2
> | | -0.4367177 0.7420993
> | | [4] age > 43: n = 14
> | | (Intercept) trt2
> | | -0.9253406 0.6662319
> | [5] age > 50: n = 20
138,141c157
< | -1.162126 1.162126
< | [3] age > 50: n = 20
< | (Intercept) trt2
< | -1.034074 1.980880
---
> | -0.7958013 1.9056497
143,144c159,160
< Number of inner nodes: 1
< Number of terminal nodes: 2
---
> Number of inner nodes: 2
> Number of terminal nodes: 3
146c162
< Objective function: 91.09863
---
> Objective function: 94.40128
156,159c172,179
< | [2] age <= 50: n = 502
< | (Intercept) trt2
< | -1.162126 1.162126
< | [3] age > 50: n = 498
---
> | [2] age <= 50
> | | [3] age <= 42: n = 153
> | | (Intercept) trt2
> | | -0.1300531 0.5027284
> | | [4] age > 42: n = 371
> | | (Intercept) trt2
> | | -0.9932518 0.7773634
> | [5] age > 50: n = 476
161c181
< | -1.034074 1.980880
---
> | -0.7958013 1.9056497
163,164c183,184
< Number of inner nodes: 1
< Number of terminal nodes: 2
---
> Number of inner nodes: 2
> Number of terminal nodes: 3
166c186
< Objective function (negative log-likelihood): 601.9864
---
> Objective function (negative log-likelihood): 621.198
180,181c200,201
< statistic 1.446675e+01
< p.value 7.220786e-04
---
> statistic 1.754685e+01
> p.value 1.547928e-04
185,186c205,206
< statistic 2.0885768
< p.value 0.3519422
---
> statistic 9.609115153
> p.value 0.008192325
190,191c210,221
< statistic 4.1541909
< p.value 0.1252936
---
> statistic 0.7184773
> p.value 0.6982077
>
> $`4`
> age
> statistic 2.0024795
> p.value 0.3674237
>
> $`5`
> age
> statistic 1.1781017
> p.value 0.5548537
196,197c226,227
< statistic 7.19313420
< p.value 0.02741768
---
> statistic 7.40146997
> p.value 0.02470536
201,202c231,232
< statistic 2.7056665
< p.value 0.2585068
---
> statistic 8.03869435
> p.value 0.01796469
204a235,240
> NULL
>
> $`4`
> NULL
>
> $`5`
206,207c242,243
< statistic 3.6772322
< p.value 0.1590374
---
> statistic 1.1198024
> p.value 0.5712655
212c248
< 'log Lik.' -601.9864 (df=5)
---
> 'log Lik.' -621.198 (df=8)
214c250
< 'log Lik.' -601.9864 (df=4)
---
> 'log Lik.' -621.198 (df=6)
217c253
< [1] -601.9864
---
> [1] -621.198
219c255
< [1] -601.9864
---
> [1] -621.198
221c257
< [1] -601.9864
---
> [1] -621.198
223c259
< [1] -601.9864
---
> [1] -621.198
228c264
< 'log Lik.' -601.9864 (df=4)
---
> 'log Lik.' -621.198 (df=6)
230c266
< 'log Lik.' -623.9381 (df=NA)
---
> 'log Lik.' -674.0438 (df=NA)
236c272
< 'log Lik.' 24.60555 (df=4)
---
> 'log Lik.' 55.4331 (df=6)
343c379
< | | [3] tests <= 57.69231: n = 124
---
> | | [3] tests <= 57.69231: n = 123
345c381
< | | 42.603550 -6.488818
---
> | | 41.586538 -5.471806
348c384
< | | 54.967949 -1.729082
---
> | | 54.807692 -1.568826
353c389
< | | [7] tests > 92.30769: n = 88
---
> | | [7] tests > 92.30769: n = 89
355c391
< | | 87.73389 -10.65998
---
> | | 89.06883 -11.99492
360c396
< Objective function: -282919.6
---
> Objective function: -276926.2
401c437
< 184270
---
> 167022.9
413c449
< 247262.1814 67543.0073 18595.5202 3297.5797 959.4839
---
> 269734.5165 72661.7239 15878.6172 2973.8659 932.7745
507,516c543,550
< 1: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< Ran out of iterations and did not converge
< 2: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< Ran out of iterations and did not converge
< 3: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< Ran out of iterations and did not converge
< 4: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< Ran out of iterations and did not converge
< 5: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< one or more coefficients may be infinite
---
> 1: In fitter(X, Y, strats, offset, init, control, weights = weights, :
> Loglik converged before variable 1 ; beta may be infinite.
> 2: In fitter(X, Y, strats, offset, init, control, weights = weights, :
> Loglik converged before variable 1,2 ; beta may be infinite.
> 3: In fitter(X, Y, strats, offset, init, control, weights = weights, :
> Loglik converged before variable 1,2 ; beta may be infinite.
> 4: In fitter(X, Y, strats, offset, init, control, weights = weights, :
> Loglik converged before variable 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269 ; beta may be infinite.
520,525c554,557
< 1: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< Ran out of iterations and did not converge
< 2: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< Ran out of iterations and did not converge
< 3: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< one or more coefficients may be infinite
---
> 1: In fitter(X, Y, strats, offset, init, control, weights = weights, :
> Loglik converged before variable 1,2 ; beta may be infinite.
> 2: In fitter(X, Y, strats, offset, init, control, weights = weights, :
> Loglik converged before variable 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269 ; beta may be infinite.
529,538c561,568
< 1: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< Ran out of iterations and did not converge
< 2: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< Ran out of iterations and did not converge
< 3: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< Ran out of iterations and did not converge
< 4: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< Ran out of iterations and did not converge
< 5: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< one or more coefficients may be infinite
---
> 1: In fitter(X, Y, strats, offset, init, control, weights = weights, :
> Loglik converged before variable 1,2 ; beta may be infinite.
> 2: In fitter(X, Y, strats, offset, init, control, weights = weights, :
> Loglik converged before variable 1,3 ; beta may be infinite.
> 3: In fitter(X, Y, strats, offset, init, control, weights = weights, :
> Loglik converged before variable 1,2 ; beta may be infinite.
> 4: In fitter(X, Y, strats, offset, init, control, weights = weights, :
> Loglik converged before variable 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269 ; beta may be infinite.
542,549c572,577
< 1: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< Ran out of iterations and did not converge
< 2: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< Ran out of iterations and did not converge
< 3: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< Ran out of iterations and did not converge
< 4: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< one or more coefficients may be infinite
---
> 1: In fitter(X, Y, strats, offset, init, control, weights = weights, :
> Loglik converged before variable 1,2 ; beta may be infinite.
> 2: In fitter(X, Y, strats, offset, init, control, weights = weights, :
> Loglik converged before variable 1,2 ; beta may be infinite.
> 3: In fitter(X, Y, strats, offset, init, control, weights = weights, :
> Loglik converged before variable 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269 ; beta may be infinite.
553,562c581,588
< 1: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< Ran out of iterations and did not converge
< 2: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< Ran out of iterations and did not converge
< 3: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< Ran out of iterations and did not converge
< 4: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< Ran out of iterations and did not converge
< 5: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< one or more coefficients may be infinite
---
> 1: In fitter(X, Y, strats, offset, init, control, weights = weights, :
> Loglik converged before variable 1,2 ; beta may be infinite.
> 2: In fitter(X, Y, strats, offset, init, control, weights = weights, :
> Loglik converged before variable 1,3 ; beta may be infinite.
> 3: In fitter(X, Y, strats, offset, init, control, weights = weights, :
> Loglik converged before variable 1,2 ; beta may be infinite.
> 4: In fitter(X, Y, strats, offset, init, control, weights = weights, :
> Loglik converged before variable 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269 ; beta may be infinite.
566,573c592,597
< 1: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< Ran out of iterations and did not converge
< 2: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< Ran out of iterations and did not converge
< 3: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< Ran out of iterations and did not converge
< 4: In fitter(X, Y, istrat, offset, init, control, weights = weights, :
< one or more coefficients may be infinite
---
> 1: In fitter(X, Y, strats, offset, init, control, weights = weights, :
> Loglik converged before variable 1,2 ; beta may be infinite.
> 2: In fitter(X, Y, strats, offset, init, control, weights = weights, :
> Loglik converged before variable 1,2 ; beta may be infinite.
> 3: In fitter(X, Y, strats, offset, init, control, weights = weights, :
> Loglik converged before variable 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269 ; beta may be infinite.
Running the tests in 'tests/test-pmodel.R' failed.
Complete output:
> library("model4you")
Loading required package: partykit
Loading required package: grid
Loading required package: libcoin
Loading required package: mvtnorm
> library("mvtnorm")
> library("survival")
> set.seed(123)
>
> ## function to simulate the data
> sim_data <- function(n = 500, p = 10, beta = 3, sd = 1){
+
+ ## treatment
+ lev <- c("C", "A")
+ a <- rep(factor(lev, labels = lev, levels = lev), length = n)
+
+ ## correlated z variables
+ sigma <- diag(p)
+ sigma[sigma == 0] <- 0.2
+ ztemp <- rmvnorm(n, sigma = sigma)
+ z <- (pnorm(ztemp) * 2 * pi) - pi
+ colnames(z) <- paste0("z", 1:ncol(z))
+ z1 <- z[,1]
+
+ ## outcome
+ y <- 7 + 0.2 * (a %in% "A") + beta * cos(z1) * (a %in% "A") + rnorm(n, 0, sd)
+
+ data.frame(y = y, a = a, z)
+ }
>
> ## simulate data
> beta <- 3
> ntrain <- 500
> ntest <- 100
> simdata <- simdata_s <- sim_data(p = 5, beta = beta, n = ntrain)
> tsimdata <- tsimdata_s <- sim_data(p = 5, beta = beta, n = ntest)
> simdata_s$cens <- rep(1, ntrain)
> tsimdata_s$cens <- rep(1, ntest)
>
> ## base model
> basemodel_lm <- lm(y ~ a, data = simdata)
> basemodel_wb <- survreg(Surv(y, cens) ~ a, data = simdata_s)
>
> ## forest
> frst_lm <- pmforest(basemodel_lm, ntree = 10,
+ perturb = list(replace = FALSE, fraction = 0.632),
+ control = ctree_control(mincriterion = 0, lookahead = TRUE))
No data given. I'm using data set simdata from the current environment parent.frame(). Please check if that is what you want.
> frst_wb <- pmforest(basemodel_wb, ntree = 10,
+ perturb = list(replace = FALSE, fraction = 0.632),
+ control = ctree_control(mincriterion = 0, lookahead = TRUE))
No data given. I'm using data set simdata_s from the current environment parent.frame(). Please check if that is what you want.
>
> ## personalised models
> coefs_lm <- pmodel(x = frst_lm, newdata = tsimdata)
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
model4you
--- call from context ---
pmodel(x = frst_lm, newdata = tsimdata)
--- call from argument ---
if (class(ret) == "matrix") ret <- t(ret)
--- R stacktrace ---
where 1: pmodel(x = frst_lm, newdata = tsimdata)
--- value of length: 2 type: logical ---
[1] TRUE FALSE
--- function from context ---
function (x = NULL, model = NULL, newdata = NULL, OOB = TRUE,
fun = coef, return_attr = c("modelcall", "data", "similarity"))
{
if (is.matrix(x)) {
if (is.null(model))
stop("When x is a matrix, model must not be NULL. Please enter a model object.")
pweights <- x
}
else {
if (is.null(model))
model <- x$info$model
pweights <- predict(x, type = "weights", newdata = newdata,
OOB = OOB)
}
get_pmod <- function(w) {
if (sum(w) == 0)
stop("The weights for one observation are all 0. A solution may be increasing ntree.")
dat <- x$data
dat$w <- w
pmod <- update(model, weights = w, subset = w > 0, data = dat)
fun(pmod)
}
ret <- apply(pweights, 2, get_pmod)
if (class(ret) == "matrix")
ret <- t(ret)
if (all.equal(fun, identity) == TRUE)
class(ret) <- c("pmodel_identity", class(ret))
class(ret) <- c("pmodel", class(ret))
if ("modelcall" %in% return_attr)
attr(ret, "modelcall") <- getCall(model)
if ("data" %in% return_attr)
if (is.null(newdata))
attr(ret, "data") <- x$data
else attr(ret, "data") <- newdata
if ("similarity" %in% return_attr)
attr(ret, "similarity") <- pweights
return(ret)
}
<bytecode: 0xa5bd6d0>
<environment: namespace:model4you>
--- function search by body ---
Function pmodel in namespace model4you has this body.
----------- END OF FAILURE REPORT --------------
Error in if (class(ret) == "matrix") ret <- t(ret) :
the condition has length > 1
Calls: pmodel
In addition: Warning message:
In model.frame.default(object$predictf, data = newdata, na.action = na.pass, :
variable 'a' is not a factor
Execution halted
Flavor: r-devel-linux-x86_64-debian-clang