Dear R users,
I'm using the "reldist" add-on package to calculate relative
distribution in R as part of my research project. The subject is a general
mental health score ranging from 0 to 12 (integer values only) with 0 indicating
no mental health problem and positive values meaning some or sever mental health
problem.
When I run the programme to compare the scores of population samples from two
different years by plotting PDF, for example 1991 to 2005 as I show here, I keep
having a problem regarding the smoothing parameter.
As you can see from the copied workspace image from R, when I specified a
smoothing parameter (0.4) in the first time, it showed a warning message. And
for the 2nd and 3rd time that I used other smoothing values (2 and 5), no
warning message were given. The last time I didn't choose any smoothing
value and the computer used a vary small smoothing value, but the graph
doesn't look as smooth as the first three ones. It is always the case that
it only gives a warning message for the first time no matter what value I
choose. And if I don't specify any smoothing parameter and the computer will
generate one, in which case no warning message is given but the values computer
chooses sometimes are not optimal.
I would be very grateful if anybody could help me with this problem.
Thank you very much!
Best wishes,
Jing Shen
> hse91<-read.table("h:/HSE/hse91p.txt",header=TRUE)
> hse05<-read.table("h:/HSE/hse05p.txt",header=TRUE)
> ghq91<-hse91$ghq12scr
> ghq05<-hse05$ghq12scr
> wgt91<-hse91$wgt
> wgt05<-hse05$wgt
>
g10<-reldist(y=ghq05,yo=ghq91,smooth=0.4,ci=TRUE,ywgt=wgt05,yowgt=wgt91,yolabs=seq(-1,7,by=0.5),ylim=c(0.5,7.0),bar=TRUE,quiet=FALSE,xlab="proportion
of the original cohort")
This is mgcv 1.3-25
Smoothing using 0.4
Warning message:
fitted rates numerically 0 occurred in: gam.fit(G, family = G$family, control =
control, gamma = gamma, >
>
g10<-reldist(y=ghq05,yo=ghq91,smooth=2.0,ci=TRUE,ywgt=wgt05,yowgt=wgt91,yolabs=seq(-1,7,by=0.5),ylim=c(0.5,7.0),bar=TRUE,quiet=FALSE,xlab="proportion
of the original cohort")
Smoothing using 2 >
>
g10<-reldist(y=ghq05,yo=ghq91,smooth=5.0,ci=TRUE,ywgt=wgt05,yowgt=wgt91,yolabs=seq(-1,7,by=0.5),ylim=c(0.5,7.0),bar=TRUE,quiet=FALSE,xlab="proportion
of the original cohort")
Smoothing using 5 >
> g10<-reldist(y=ghq05,yo=ghq91,ci=TRUE,ywgt=wgt05,yowgt=wgt91,yolabs=se
> q(-1,7,by=0.5),ylim=c(0.5,7.0),bar=TRUE,quiet=FALSE,xlab="proportion
of the original cohort")
Smoothing using 8.121196e-08