similar to: How to get curve information from a gam model

Displaying 20 results from an estimated 20000 matches similar to: "How to get curve information from a gam model"

2010 Dec 14
2
Use generalised additive model to plot curve
Readers, I have been reading 'the r book' by Crawley and think that the generalised additive model is appropriate for this problem. The package 'gam' was installed using the command (as root) install.package("gam") ... library(gam) > library(gam) Loading required package: splines Loading required package: akima > library(mgcv) This is mgcv 1.3-25 Attaching
2007 Jun 22
1
two basic question regarding model selection in GAM
Qusetion #1 ********* Model selection in GAM can be done by using: 1. step.gam {gam} : A directional stepwise search 2. gam {mgcv} : Smoothness estimation using GCV or UBRE/AIC criterion Suppose my model starts with a additive model (linear part + spline part). Using gam() {mgcv} i got estimated degrees of freedom(edf) for the smoothing splines. Now I want to use the functional form of my model
2012 Jul 23
1
mgcv: Extract random effects from gam model
Hi everyone, I can't figure out how to extract by-factor random effect adjustments from a gam model (mgcv package). Example (from ?gam.vcomp): library(mgcv) set.seed(3) dat <- gamSim(1,n=400,dist="normal",scale=2) a <- factor(sample(1:10,400,replace=TRUE)) b <- factor(sample(1:7,400,replace=TRUE)) Xa <- model.matrix(~a-1) ## random main effects Xb <-
2007 Dec 13
1
Two repeated warnings when runing gam(mgcv) to analyze my dataset?
Dear all, I run the GAMs (generalized additive models) in gam(mgcv) using the following codes. m.gam <-gam(mark~s(x)+s(y)+s(lstday2004)+s(ndvi2004)+s(slope)+s(elevation)+disbinary,family=binomial(logit),data=point) And two repeated warnings appeared. Warnings$B!'(B 1: In gam.fit(G, family = G$family, control = control, gamma = gamma, ... : Algorithm did not converge 2: In gam.fit(G,
2007 Oct 05
2
question about predict.gam
I'm fitting a Poisson gam model, say model<-gam(a65tm~as.factor(day.week )+as.factor(week)+offset(log(pop65))+s(time,k=10,bs="cr",fx=FALSE,by=NA,m=1),sp=c( 0.001),data=dati1,family=poisson) Currently I've difficulties in obtaining right predictions by using gam.predict function with MGCV package in R version 2.2.1 (see below my syntax).
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
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
2005 Oct 05
3
testing non-linear component in mgcv:gam
Hi, I need further help with my GAMs. Most models I test are very obviously non-linear. Yet, to be on the safe side, I report the significance of the smooth (default output of mgcv's summary.gam) and confirm it deviates significantly from linearity. I do the latter by fitting a second model where the same predictor is entered without the s(), and then use anova.gam to compare the
2010 Mar 04
2
which coefficients for a gam(mgcv) model equation?
Dear users, I am trying to show the equation (including coefficients from the model estimates) for a gam model but do not understand how to. Slide 7 from one of the authors presentations (gam-theory.pdf URL: http://people.bath.ac.uk/sw283/mgcv/) shows a general equation log{E(yi )} = ?+ ?xi + f (zi ) . What I would like to do is put my model coefficients and present the equation used. I am an
2011 Dec 09
3
gam, what is the function(s)
Hello, I'd like to understand 'what' is predicting the response for library(mgcv) gam? For example: library(mgcv) fit <- gam(y~s(x),data=as.data.frame(l_yx),family=binomial) xx <- seq(min(l_yx[,2]),max(l_yx[,2]),len=101) plot(xx,predict(fit,data.frame(x=xx),type="response"),type="l") I want to see the generalized function(s) used to predict the response
2013 Nov 06
3
Nonnormal Residuals and GAMs
Greetings, My question is more algorithmic than prectical. What I am trying to determine is, are the GAM algorithms used in the mgcv package affected by nonnormally-distributed residuals? As I understand the theory of linear models the Gauss-Markov theorem guarantees that least-squares regression is optimal over all unbiased estimators iff the data meet the conditions linearity,
2012 Aug 14
1
Random effects in gam (mgcv 1.7-19)
Hi, I am using the gam function in the mgcv package, I have random effects in my model (bs="re") this has worked fine, but after I updated the mgcv package to version 1.7-19 I recive an error message when I run the model. > fit1<-gam(IV~s(RUTE,bs="re")+s(T13)+s(H40)+factor(AAR)+s(V3)+s(G1)+s(H1)+s(V1)+factor(LEDD),data=data5,method="ML") > summary.gam(fit1)
2008 Jul 01
1
Simulate from a GAM model
Does anybody have any suggestions on how I might simulate from fitted GAM model? I am using the gam function in the mgcv package to fit a variable coefficient model like the following from the examples. I would like simulate based on the fitted model like the simulate function in the stats package does for lm models. library(mgcv) set.seed(10) ## simulate date from y = f(x2)*x1 + error dat
2003 Jun 04
2
gam()
Dear all, I've now spent a couple of days trying to learn R and, in particular, the gam() function, and I now have a few questions and reflections regarding the latter. Maybe these things are implemented in some way that I'm not yet aware of or have perhaps been decided by the R community to not be what's wanted. Of course, my lack of complete theoretical understanding of what
2008 May 06
1
mgcv::gam shrinkage of smooths
In Dr. Wood's book on GAM, he suggests in section 4.1.6 that it might be useful to shrink a single smooth by adding S=S+epsilon*I to the penalty matrix S. The context was the need to be able to shrink the term to zero if appropriate. I'd like to do this in order to shrink the coefficients towards zero (irrespective of the penalty for "wiggliness") - but not necessarily all the
2012 Jul 30
2
mgcv 1.7-19, vis.gam(): "invalid 'z' limits'
Hi everyone, I ran a binomial GAM consisting of a tensor product of two continuous variables, a continuous parametric term and crossed random intercepts on a data set with 13,042 rows. When trying to plot the tensor product with vis.gam(), I get the following error message: Error in persp.default(m1, m2, z, col = col, zlim = c(min.z, max.z), xlab = view[1], : invalid 'z' limits In
2013 Jun 17
1
Can you use two offsets in gam (mgcv)?
Hello, I have been trying to find out whether it is possible to use more than one offset in a gam (in mgcv). The reason I would like to do this is to 1) account for area surveyed in a Poisson model of sightings of porpoises within defined grid cells (each cell has a slightly different area) and 2) account for detection probability within each grid cell (some grid cells are further away from the
2004 Apr 18
2
Error in gam?
I'm having some problems using variable names containing spaces (using backticks) with gam (mgcv 0.9-6, R 1.8.1). Some toy code to reproduce my problem is below. Am I doing something wrong, or should I pass this bug on to Simon Wood? (Or do I need to rename my variables to get rid of the spaces?) Thanks, Hadley library(mgcv) test <- data.frame(a = c(1:10), `a b` = c(1:10)^2,
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, +
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