similar to: Prediction using GAM

Displaying 20 results from an estimated 10000 matches similar to: "Prediction using GAM"

2013 Jul 08
1
error in "predict.gam" used with "bam"
Hello everyone. I am doing a logistic gam (package mgcv) on a pretty large dataframe (130.000 cases with 100 variables). Because of that, the gam is fitted on a random subset of 10000. Now when I want to predict the values for the rest of the data, I get the following error: > gam.basis_alleakti.1.pr=predict(gam.basis_alleakti.1, +
2008 Jun 11
1
mgcv::gam error message for predict.gam
Sometimes, for specific models, I get this error from predict.gam in library mgcv: Error in complete.cases(object) : negative length vectors are not allowed Here's an example: model.calibrate <- gam(meansalesw ~ s(tscore,bs="cs",k=4), data=toplot, weights=weight, gam.method="perf.magic") > test <- predict(model.calibrate,newdata) Error in
2007 Aug 08
1
prediction using gam
I am fitting a two dimensional smoother in gam, say junk = gam(y~s(x1,x2)), to a response variable y that is always positive and pretty well behaved, both x1 and x2 are contained within [0,1]. I then create a new dataset for prediction with values of (x1,x2) within the range of the original data. predict(junk,newdata,type="response") My predicted values are a bit strange
2009 Jan 16
2
Predictions with GAM
Dear, I am trying to get a prediction of my GAM on a response type. So that I eventually get plots with the correct values on my ylab. I have been able to get some of my GAM's working with the example shown below: * model1<-gam(nsdall ~ s(jdaylitr2), data=datansd) newd1 <- data.frame(jdaylitr2=(244:304)) pred1 <- predict.gam(model1,newd1,type="response")* The problem I am
2011 Apr 19
1
Prediction interval with GAM?
Hello, Is it possible to estimate prediction interval using GAM? I looked through ?gam, ?predict.gam etc and the mgcv.pdf Simon Wood. I found it can calculate confidence interval but not clear if I can get it to calculate prediction interval. I read "Inference for GAMs is difficult and somewhat contentious." in Kuhnert and Venable An Introduction to R, and wondering why and if that
2012 Oct 10
2
GAM without intercept
Hi everybody, I am trying to fit a GAM model without intercept using library mgcv. However, the result has nothing to do with the observed data. In fact the predicted points are far from the predicted points obtained from the model with intercept. For example: #First I generate some simulated data: library(mgcv) x<-seq(0,10,length=100) y<-x^2+rnorm(100) #then I fit a gam model with
2011 Mar 28
2
mgcv gam predict problem
Hello I'm using function gam from package mgcv to fit splines. ?When I try to make a prediction slightly beyond the original 'x' range, I get this error: > A = runif(50,1,149) > B = sqrt(A) + rnorm(50) > range(A) [1] 3.289136 145.342961 > > > fit1 = gam(B ~ s(A, bs="ps"), outer.ok=TRUE) > predict(fit1, newdata=data.frame(A=149.9), outer.ok=TRUE) Error
2007 Feb 13
1
Missing variable in new dataframe for prediction
Hi, I'm using a loop to evaluate several models by taking adjacent variables from my dataframe. When i try to get predictions for new values, i get an error message about a missing variable in my new dataframe. Below is an example adapted from ?gam in mgcv package library(mgcv) set.seed(0) n<-400 sig<-2 x0 <- runif(n, 0, 1) x1 <- runif(n, 0, 1) x2 <- runif(n, 0, 1) x3 <-
2009 Nov 21
1
3-D Plotting of predictions from GAM/GAMM object
Hello all, Thank you for the previous assistance I received from this listserve! My current question is: How can I create an appropriate matrix of values from a GAM (actually a GAMM) to make a 3-D plot? This model is fit as a tensor product spline of two predictors and I have used it to make specific predictions by calling:
2013 Mar 21
1
[mgcv][gam] Odd error: Error in PredictMat(object$smooth[[k]], data) : , `by' variable must be same dimension as smooth arguments
Dear List, I'm getting an error in mgcv, and I can't figure out where it comes from. The setup is the following: I've got a fitted GAM object called "MI", and a vector of "prediction data" (with default values for predictors). I feed this into predict.gam(object, newdata = whatever) via the following function: makepred = function(varstochange,val){ for
2004 Oct 15
1
2d approx
Hi, I am looking for a function that generalizes 'approx' to two (or more) dimensions. The references on the approx help page point toward splines, but a) splines is what I am trying to avoid in the first place and b) splines (except for mgcv splines) seem to be one dimensional. Here is a more detailed account. Using mgcv:gam I fit an additive model xy.gam according to the formula y ~
2003 Jun 03
3
gam questions
Dear all, I'm a fairly new R user having two questions regarding gam: 1. The prediction example on p. 38 in the mgcv manual. In order to get predictions based on the original data set, by leaving out the 'newdata' argument ("newd" in the example), I get an error message "Warning message: the condition has length > 1 and only the first element will be used in: if
2006 Nov 15
1
can I get standard error from predict.gam()?
Hi everybody, I am using predict.gam() now. I but it seems there is no such option to get standard errors of the predicted values. I tried to set se=T or se.fit=T but no use. If you know anything about that please let me know. Thanks very much. Kevin. [[alternative HTML version deleted]]
2009 May 18
1
Predicting complicated GAMMs on response scale
Hi, I am using GAMMs to show a relationship of temperature differential over time with a model that looks like this:- gamm(Diff~s(DaysPT)+AirToC,method="REML") where DaysPT is time in days since injury and Diff is repeat measures of temperature differentials with regards to injury sites compared to non-injured sites in individuals over the course of 0-24 days. I use the following
2011 Jun 24
2
mgcv:gamm: predict to reflect random s() effects?
Dear useRs, I am using the gamm function in the mgcv package to model a smooth relationship between a covariate and my dependent variable, while allowing for quantification of the subjectwise variability in the smooths. What I would like to do is to make subjectwise predictions for plotting purposes which account for the random smooth components of the fit. An example. (sessionInfo() is at
2007 Feb 27
1
interactions and GAM
Dear R-users, I have 1 remark and 1 question on the inclusion of interactions in the gam function from the gam package. I need to fit quantitative predictors in interactions with factors. You can see an example of what I need in fig 9.13 p265 from Hastie and Tibshirani book (1990). It's clearly stated that in ?gam "Interactions with nonparametric smooth terms are not fully
2010 Dec 30
0
prediction intervals for (mcgv) gam objects
As I understand it,  predict.lm(l ,newdata=nd ,interval="confidence") yields confidence bands for the predicted mean of new observations and lm.predict(l ,newdata=nd ,interval="prediction") yields confidence bands for new observations themselves, given an lm object l.   However with regard to {mgcv} although  predict.gam (g ,se.fit=TRUE ,interval= "prediction")
2009 Feb 25
1
monotonic GAM with more than one term
Hi, Does anyone know how to fit a GAM where one or more smooth terms are constrained to be monotonic, in the presence of "by" variables or other terms? I looked at the example in ?pcls but so far have not been able to adapt it to the case where there is more than one predictor. For example, require(mgcv) set.seed(0) n<-100 # Generate data from a monotonic truth.
2003 Jun 07
0
problem with predict() for gam() models
I run the following code in R 1.6.2 on Windows: xxx <- rnorm(100) yyy <- .5 * rnorm(100) + sqrt(1-.5^2) * rnorm(100) ord <- order(xxx) xxx <- xxx[ord] # for yyy <- yyy[ord] # convenience in reading printout rm(ord) reg.gam <- gam(yyy ~ s(xxx, k=8)) f <- function(x, reg.gam, target.y) { cat("inside f() called by optimize():\n") cat("arg x=", x,
2011 Sep 20
0
Problems using predict from GAM model averaging (MuMIn)
I am struggling to get GAM model predictions from the top models calculated using model.avg in the package "MuMIn". My model looks something like the following: gamp <- gam(log10(y)~s(x1,bs="tp",k=3)+s(x2,bs="tp",k=3)+ s(x3,bs="tp",k=3)+s(x4,bs="tp",k=3)+s(x5,bs="tp",k=3)+ s(x6,bs="tp",k=3)+x7,data=dat,