I am getting the following error when trying to run a gam.possion model with Zelig.
Error in eval(expr, envir, enclos) : attempt to apply non-function Even the example won't run. library(mgcv) library(Zelig) n <- 400 sig <- 2 x0 <- runif(n, 0, 1); x1 <- runif(n, 0, 1) x2 <- runif(n, 0, 1); x3 <- runif(n, 0, 1) f0 <- function(x) 2 * sin(pi * x) f1 <- function(x) exp(2 * x) f2 <- function(x) 0.2 * x^11 * (10 * (1 - x))^6 + 10 * (10 * x)^3 * (1 - x)^10 f3 <- function(x) 0 * x f <- f0(x0) + f1(x1) + f2(x2) g <- exp(f/4) y <- rpois(rep(1, n), g) my.data <- as.data.frame(cbind(y, x0, x1, x2, x3)) z.out <- zelig(y ~ s(x0) + s(x1) + s(x2) + s(x3), model = "gam.poisson", data = my.data) What am I doing wrong? Session info is below. Thanks a lot! Sincerely, Milu #### sessionInfo() R version 3.3.2 (2016-10-31) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1 locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] Zelig_5.0-13 mgcv_1.8-15 nlme_3.1-128 loaded via a namespace (and not attached): [1] Rcpp_0.12.8 nloptr_1.0.4 plyr_1.8.4 miscTools_0.6-22 tools_3.3.2 lme4_1.1-12 [7] MatchIt_2.4-21 jsonlite_1.1 tibble_1.2 lattice_0.20-34 Matrix_1.2-7.1 DBI_0.5-1 [13] maxLik_1.3-4 parallel_3.3.2 SparseM_1.74 coda_0.18-1 AER_1.2-4 dplyr_0.5.0 [19] MatrixModels_0.4-1 nnet_7.3-12 stats4_3.3.2 lmtest_0.9-34 grid_3.3.2 R6_2.2.0 [25] geepack_1.2-1 survival_2.40-1 VGAM_1.0-2 foreign_0.8-67 minqa_1.2.4 Amelia_1.7.4 [31] Formula_1.2-1 car_2.1-3 magrittr_1.5 mcmc_0.9-4 MASS_7.3-45 splines_3.3.2 [37] pbkrtest_0.4-6 assertthat_0.1 quantreg_5.29 sandwich_2.3-4 survey_3.31-5 MCMCpack_1.3-8 [43] lazyeval_0.2.0 zoo_1.7-13 [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.