[Rd] Including a file in a Rd file

2010-04-06 Thread Christophe Genolini

Hi all,
Is it possible to include a file in an .Rd file? For example, it might 
be convenient to write a file "author.Rd" and then include it in all the 
Rd file:


\author{
 \include{author.Rd}
}

Christophe

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Strange error

2010-04-06 Thread Terry Therneau
Someone just sent me a data set that causes the lmekin function, part of
the kinship package, to fail.  In chasing it down I get an error I have
never seen before.

fit <- lmekin(icam1 ~ factor(center) + age + factor(sex),
  random= ~1|iid, data=chaidata, varlist=kmat)
Error in Y - fitted : non-numeric argument to binary operator

Add the recover option, and the offending lines are
fitted <- c(X %*% lfit$coef)  #fitted, on the original scale
residuals <- Y - fitted

> options(error=recover)
> fit <- lmekin(icam1 ~ factor(center) + age + factor(sex),
+   random= ~1|iid, data=chaidata, varlist=kmat)
Error in Y - fitted : non-numeric argument to binary operator

Enter a frame number, or 0 to exit   

1: lmekin(icam1 ~ factor(center) + age + factor(sex), random = ~1 | iid,
data 

Selection: 
Enter an item from the menu, or 0 to exit
Selection: 1
Called from: eval(expr, envir, enclos)
Browse[1]> dim(X)
[1] 26016
Browse[1]> lfit$coef
(Intercept) factor(center)2 factor(center)3 factor(center)4
age 
217.9110997  -2.9079576  -0.2147915  -7.8141818
0.5210394 
   factor(sex)2 
  5.1384741 
Browse[1]>  X %*% lfit$coef
`__Deferred_Default_Marker__`

--

  X is a model.matrix.  If I save the two objects and reload them into a
fresh R session the multiplication works just fine. 

  I haven't modified this code in several years, and it is widely used.
All the C code is shared with coxme. Subsetting the data, or modifing
the fixed effects has no impact on the error.  The same code runs in
Splus.  At the point of error the computations have finished and it is
putting together a result list: all of the results are correct.
Nevertheless, my best (only) guess is memory corruption.

Questions:
  Is this a rational guess?  Any others?
  Can you give any further insight on the error message?

Terry Therneau

sessionInfo()
R version 2.10.0 (2009-10-26) 
x86_64-unknown-linux-gnu 

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C  
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=C  
 [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C 
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C   

attached base packages:
[1] grDevices datasets  splines   graphics  utils stats
methods  
[8] base 

other attached packages:
[1] survival_2.35-9 rlocal_1.5.3   
>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Including a file in a Rd file

2010-04-06 Thread Uwe Ligges



On 06.04.2010 09:27, Christophe Genolini wrote:

Hi all,
Is it possible to include a file in an .Rd file? For example, it might
be convenient to write a file "author.Rd" and then include it in all the
Rd file:


Not in that way, but you could perhaps arrange by using the new 
technology described in section "2.11 Dynamic pages" of the current 
devel version of the Writing R Extensions manual (untested).


Best wishes,
Uwe Ligges




\author{
\include{author.Rd}
}

Christophe

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] [R] library(): load library from a specified location

2010-04-06 Thread Kevin Coombes
If we're counting votes, then I vote "no".  And I'd be willing to help 
stuff the ballot box and even volunteer to count the final tallies in 
order to make sure that the "no" side wins.


I understand the logical argument in favor of "use" or "require" or 
"borrow". I am not swayed.


Backwards compatibility matters. A lot. This proposed change breaks an 
unfathomably large amount of existing code.  With zero gain in terms of 
performance or reliability.  It probably does not even help new users 
just learning the language, since they still have to be confused about 
why there are two functions that do almost the same thing in terms of 
loading packages.


Even with a "long deprecation" time, I don't see the value. Just train 
yourself to interpret

> library(aPackage)
as the syntactic form of the thing in R that has the semantic meaning: 
"go to the library and bring back aPackage".


Curmudgeonly,
   Kevin

Martin Maechler wrote:

[ re-diverted to R-devel ]

  

Barry Rowlingson 
on Tue, 30 Mar 2010 20:15:00 +0100 writes:



> On Tue, Mar 30, 2010 at 7:58 PM, Rolf Turner
>  wrote:
>> But ***please*** say ``load *package*'', not ``load
>> library''.  The *location* (collection of packages) from
>> which you wish to load the given package is the
>> ``library''.

>  Anyone vote for deprecating the library() function and
> renaming it use() or requiring require() instead?

I'm voting pro.   



We (R core) had planned to do this, probably about 5 to eight
years ago, then started discussing about possible features of
the new  use()  function, of making a package into an "object"
that you'd want to interrogate, ...
and then probably got tired  ;-)

With the many moons passed, I'd now tend to *not* add features,
but really renamed 'library' to 'use' 
and create a  library() with a deprecation message which then

simply calls use()...
and yes, I'd allow a very exceptionally long deprecation period
of two to five years before making library() defunct.

Martin

>  I mean, when I go get a book out of our library, I don't
> say "I'd like to library Case Studies in Spatial Point
> Process Modelling".  Maybe we should use
> 'borrow(package)'? Then it might be clear you were getting
> a package from a library, and that you magically put it
> back at the end of your R session

>  Slightly silly mood this evening



> Barry

> __
> r-h...@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.

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel



__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] GAMs and survival data

2010-04-06 Thread Kris Jones
Hello. I'm trying to analyze data, which is looking at the relationship between 
temperature and survival for fish (from fertilization to emergence). Looking at 
the raw data, there appears to be a bell shaped relationship. Ordinarily for 
survival data, I would run a generalized linear model (because the data has a 
binomial error structure). However, I am thinking that running a generalized 
additive model (which I've never used before), as its my understanding that 
they are better able to deal with non-linear relationships. Hopefully this is a 
correct assumption. 

Question 1: Unfortunately, the data I have to work with is not formatted to be 
as #successes or # failures, as R seems to want for other generalized models 
(the survival data I have is percent survival). I'm using 'The R Book' by Mick 
Crawley,and have searched online, but haven't had much luck finding the right 
code that will run with percentage data for GAM (and whether or not its 
appropriate to use percentage data). Is it inappropriate to run the analyses 
like this? With Generalized Linear Models R seems to want #successes and 
failures, but the GAM doesn't (it worked--output below). I'm just wondering 
whether it is alright to run the model as I have done (with percentage data)? 

Question 2: For this type of model (GAM), is there a simple way of constructing 
an equation for the model (e.g., to come up with predicted values). This is 
probably not the best, but I've plotted the predicted values in Excel, fitted a 
polynomial trend line and got the equation from there. I'm just wondering if 
there's a more appropriate way to get it in R? 

Not sure if it would be useful, but I've provided the code and output for the 
model below. Any help you can offer would be much appreciated. Thanks in 
advance for your help--I really appreciate it! 

Kris 




> names(data) 
[1] "Temp" "Survival" 
> str(data) 
'data.frame': 17 obs. of 2 variables: 
$ Temp : num 35.6 38.8 39 39 41 ... 
$ Survival: num 0.14 0.972 0.697 0.938 0.83 0.987 0.989 0.9 0.996 0.87 ... 
> 
> Surv<-gam(Survival~s(Temp), quasibinomial, data=na.omit(data)) 
> summary(Surv) 

Family: quasibinomial 
Link function: logit 

Formula: 
Survival ~ s(Temp) 

Parametric coefficients: 
Estimate Std. Error t value Pr(>|t|) 
(Intercept) 1.9938 0.3067 6.501 8.02e-05 *** 
--- 
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 
1 

Approximate significance of smooth terms: 
edf Ref.df F p-value 
s(Temp) 6.325 6.325 4.065 0.0257 * 
--- 
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 
1 

R-sq.(adj) = 0.775 Deviance explained = 81.2% 
GCV score = 0.18885 Scale est. = 0.10748 n = 17 





This email has been processed by SmoothZap - www.smoothwall.net


[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel