[R] Hep on using GAM() in R

From: zhijie zhang <epistat_at_gmail.com>
Date: Wed, 12 Dec 2007 20:38:18 +0800


Dear friends,
 I met some problem on using GAM() function in R.

Any help or suggestions are greatly appreciated.

# My programs and problems are list below#

library(splines)

library(gam)

point<-read.csv("d:/gam.csv",sep=",",header=TRUE) #read the data

gam.opt<-gam(mark~lo(x,y,span=0.2)+lo(lstday2004,span=0.2)+lo(slope,span=0.2)+lo(ndvi2004,span= 0.2)+lo(elevation,span=0.2)+disbinary,
family=binomial(logit),data=point) #span is 0.2

#when you run the above codes, 30 warnings() appear

> warnings()

Warning message:

  1. In lo.wam(x, z, wz, fit$smooth, which, fit$smooth.frame, ... :

  lo.wam convergence not obtained in 30 iterations

2: In lo.wam(x, z, wz, fit$smooth, which, fit$smooth.frame, ... :

  lo.wam convergence not obtained in 30 iterations

.............................................

gam.opt2<-gam(mark~lo(x,y,span=0.05)+lo(lstday2004,span=0.05)+lo(slope,span= 0.05)+lo(ndvi2004,span=0.05)+lo(elevation,span=0.05 )+disbinary,family=binomial(logit),data=point) #span is 0.05

#22 warnings()

> warnings()

  1. In lo.wam(x, z, wz, fit$smooth, which, fit$smooth.frame, ... :

  k-d tree limited by memory; nvmax= 226

2: In lo.wam(x, z, wz, fit$smooth, which, fit$smooth.frame, ... :

  pseudoinverse used at 14923

3: In lo.wam(x, z, wz, fit$smooth, which, fit$smooth.frame, ... :

  neighborhood radius 1

4: In lo.wam(x, z, wz, fit$smooth, which, fit$smooth.frame, ... :

  reciprocal condition number 0

........................................................

Q1: Their warning messages were differernt, are there any problem with the codes that i used? What does these warnings mean?

Q2: As we know, the span is an important role for smoothing, so i try to choose the optimal span by the AIC criterion. But it seemed that i can't run it successfully,

My codes are listed below.

hmin<-0.05; hmax<-0.95; hstart<-hmin; nh<-100

hstep<-(hmax-hmin)/(nh-1)

aic.h<- matrix(NA,nrow=nh,ncol=2)

for (i in 1:nh)

{

 htry<-hstart+(i-1)*hstep m.gam
<-gam(mark~lo(x,y,span=htry)+lo(lstday2004,span=htry)+lo(slope,span=htry)+lo(ndvi2004,span=htry)+lo(elevation,span=htry)+disbinary,family=binomial(logit),data=point)

 aic.h[i,2]<-m.gam$aic

 aic.h[i,1]<-htry

}

aic.h #only the first line in aic.h has values, there must be errors in my codes

Where goes wrong? How should i do for determining the best span for different variables?
  Any help or suggestions are greatly appreciated?  BTW, I'd like to send you my dataset off this mailing list if possible.

-- 
With Kind Regards,

oooO:::::::::
(..):::::::::
:\.(:::Oooo::
::\_)::(..)::
:::::::)./:::
::::::(_/::::
:::::::::::::
[***********************************************************************]
Zhi Jie,Zhang ,PHD
Tel:+86-21-54237149
Dept. of Epidemiology,School of Public Health,Fudan University
Address:No. 138 Yi Xue Yuan Road,Shanghai,China
Postcode:200032
Email:epistat_at_gmail.com
Website: www.statABC.com
[***********************************************************************]
oooO:::::::::
(..):::::::::
:\.(:::Oooo::
::\_)::(..)::
:::::::)./:::
::::::(_/::::
:::::::::::::

	[[alternative HTML version deleted]]

______________________________________________
R-help_at_r-project.org mailing list
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.
Received on Wed 12 Dec 2007 - 12:42:22 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 12 Dec 2007 - 13:30:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.