Displaying 20 results from an estimated 10000 matches similar to: "problem with predict() for gam() models"
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
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,
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
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,
+
2005 Mar 24
1
Prediction using GAM
Recently I was using GAM and couldn't help noticing
the following incoherence in prediction:
> data(gam.data)
> data(gam.newdata)
> gam.object <- gam(y ~ s(x,6) + z, data=gam.data)
> predict(gam.object)[1]
1
0.8017407
>
predict(gam.object,data.frame(x=gam.data$x[1],z=gam.data$z[1]))
1
0.1668452
I would expect that using two types of predict
arguments
2010 Dec 08
1
I want to get smoothed splines by using the class gam
Hi all,
I try to interpolate a data set in the form:
time Erg
0.000000 48.650000
1.500000 56.080000
3.000000 38.330000
4.500000 49.650000
6.000000 61.390000
7.500000 51.250000
9.000000 50.450000
10.500000 55.110000
12.000000 61.120000
18.000000 61.260000
24.000000 62.670000
36.000000 63.670000
48.000000 74.880000
I want to get smoothed splines by using the class gam
The first way I tried , was
2011 Aug 06
1
help with predict for cr model using rms package
Dear list,
I'm currently trying to use the rms package to get predicted ordinal
responses from a conditional ratio model. As you will see below, my
model seems to fit well to the data, however, I'm having trouble
getting predicted mean (or fitted) ordinal response values using the
predict function. I have a feeling I'm missing something simple,
however I haven't been able to
2012 Aug 06
0
GAM and interpolation?
Hello fellow R users,
I would need your help on GAM/GAMM models and interpolation on a marked
spatial point process (cases and controls).
I use the mgcv package to fit a GAMM model with a binary outcome, a
parametric part (var1+..+varn), a spline used for the spatial variation, and
a random effect coded through another spline in this form:
gam(outcome~var1+.+varn+s(xlong+ylat)+s(var,
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 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
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
2006 Feb 05
1
how to extract predicted values from a quantreg fit?
Hi,
I have used package quantreg to estimate a non-linear fit to the
lowest part of my data points. It works great, by the way.
But I'd like to extract the predicted values. The help for
predict.qss1 indicates this:
predict.qss1(object, newdata, ...)
and states that newdata is a data frame describing the observations
at which prediction is to be made.
I used the same technique I used
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:
2011 Aug 10
0
GAM Prediction
I'm looking for the best way to do the following:
run a set of GAM models, and then make predictions with new data.
My problem is the size of the gam model object, I would like to strip it
down to the bare minimum of information needed to apply the model to new
data. For example, if this were a linear model, I would just keep the
betas. If this were an ordinary spline fit, I think I
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
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
2008 Apr 09
1
mgcv::predict.gam lpmatrix for prediction outside of R
This is in regards to the suggested use of type="lpmatrix" in the
documentation for mgcv::predict.gam. Could one not get the same result more
simply by using type="terms" and interpolating each term directly? What is
the advantage of the lpmatrix approach for prediction outside R? Thanks.
--
View this message in context:
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 <-
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
2010 Aug 30
1
'mgcv' package, problem with predicting binomial (logit) data
Dear R-help list,
I?m using the mgcv package to plot predictions based on the gam function.
I predict the chance of being a (frequent) participant at theater plays vs.
not being a participant by age.
Because my outcome variable is dichotomous, I use the binomial family with
logit link function.
Dataset in attachment, code to read it in R:
data <- read.spss("pas_r.sav")
attach(data)