[R] .NAME in .Fortran

2012-09-10 Thread Peter Dunn
ROR
Running examples in 'tweedie-Ex.R' failed
The error most likely occurred in:

### Name: tweedie-package
### Title: Tweedie Distributions
### Aliases: tweedie-package Tweedie
### Keywords: models
### ** Examples
# Generate random numbers
set.seed(314)
y <- rtweedie( 500, p=1.5, mu=1, phi=1)
# With index  p  between 1 and 2, this produces continuous
# data with exact zeros
x <- rnorm( length(y), 0, 1)  # Unrelated predictor
# With exact zeros, index  p  must be between 1 and 2
# Fit the tweedie distribution; expect p about 1.5
out <- tweedie.profile( y~1, p.vec=seq(1.1, 1.9, length=9), do.plot=TRUE)
1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9
.Error in .Fortran(.NAME = "pdfun", as.double(power),
as.double(phi[i]/(y[i]^(2 -  :
  supplied argument name '.NAME' does not match 'name'
Calls: tweedie.profile -> dtweedie.inversion -> .Fortran
Execution halted
** running examples for arch 'x86_64' ... ERROR
Running examples in 'tweedie-Ex.R' failed
The error most likely occurred in:

### Name: tweedie-package
### Title: Tweedie Distributions
### Aliases: tweedie-package Tweedie
### Keywords: models
### ** Examples
# Generate random numbers
set.seed(314)
y <- rtweedie( 500, p=1.5, mu=1, phi=1)
# With index  p  between 1 and 2, this produces continuous
# data with exact zeros
x <- rnorm( length(y), 0, 1)  # Unrelated predictor
# With exact zeros, index  p  must be between 1 and 2
# Fit the tweedie distribution; expect p about 1.5
out <- tweedie.profile( y~1, p.vec=seq(1.1, 1.9, length=9), do.plot=TRUE)
1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9
.Error in .Fortran(.NAME = "pdfun", as.double(power),
as.double(phi[i]/(y[i]^(2 -  :
  supplied argument name '.NAME' does not match 'name'
Calls: tweedie.profile -> dtweedie.inversion -> .Fortran
Execution halted



--
Dr Peter Dunn
Biostatistician
Faculty of Science, Health, Education and
Engineering (T3.03; ML 33)
Ph: +61 7 5456 5085 | Fax: +61 7 5430 2896 | Email: pdu...@usc.edu.au |
Web: www.usc.edu.au <http://www.usc.edu.au/>





University of the Sunshine Coast, Locked Bag 4, Maroochydore DC, Queensland, 
4558 Australia.
CRICOS Provider No: 01595D
Please consider the environment before printing this email.
This email is confidential. If received in error, please delete it from your 
system.

__
R-help@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] Sweave problem: lines repeated

2010-12-13 Thread Peter Dunn
Hi all

I'm having a problem when using Sweave.  Here is a minimal example.

My input file (eg, test.Snw) looks like this:





<>=
data(cars)
m1 <- lm( dist~speed, data=cars ); coef( m1 )
@

<>=
<>
@

<>=
data(cars)
m1 <- lm( dist~speed, data=cars )
@

<>=
<>
@
 



After running Sweave over this file in R, the output file (eg. test.tex) looks 
like this:



\begin{Schunk}
\begin{Sinput}
> data(cars)
> m1 <- lm( dist~speed, data=cars ); coef( m1 )
> m1 <- lm( dist~speed, data=cars ); coef( m1 )
\end{Sinput}
\begin{Soutput}
(Intercept)   speed 
 -17.5790953.932409 
\end{Soutput}
\end{Schunk}
 

\begin{Schunk}
\begin{Sinput}
> data(cars)
> m1 <- lm( dist~speed, data=cars )
\end{Sinput}
\end{Schunk}
 



For some reason I cannot fathom, the first two chunks end up giving me *part* 
of the verbatim code twice (which is not what I was expecting), but the last 
two chunks do things as I expect.

Can anyone point me to my error, or explain why this happens? 

P.

> sessionInfo()
R version 2.12.0 (2010-10-15)
Platform: i386-apple-darwin9.8.0/i386 (32-bit)

locale:
[1] en_AU.UTF-8/en_AU.UTF-8/C/C/en_AU.UTF-8/en_AU.UTF-8

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

other attached packages:
[1] MASS_7.3-8

loaded via a namespace (and not attached):
[1] tools_2.12.0
> version
   _
platform   i386-apple-darwin9.8.0   
arch   i386 
os darwin9.8.0  
system i386, darwin9.8.0
status  
major  2
minor  12.0 
year   2010 
month  10   
day15   
svn rev53317
language   R    
version.string R version 2.12.0 (2010-10-15)



Peter Dunn: Biostatistician (Room T4.15)
School of Health and Sport Science
Faculty of Science, Health and Education  ML-34
University of the Sunshine Coast, Locked Bag 4
Maroochydore DC Qld 4558
 
Tel: +61 7 5456 5085
Fax: +61 7 5430 2896
Email: pdu...@usc.edu.au
www.usc.edu.au


CRICOS Provider Number: 01595D
This communication is intended for the recipient only and should not be 
forwarded, distributed or otherwise read by others without express permission. 
The views expressed in this email are not necessarily those of the University 
of the Sunshine Coast.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

__
R-help@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.


Re: [R] Using termplot() with transformations of x

2010-08-29 Thread Peter Dunn
Hi

>the two models  are identical because of having the same independent
> variable and dependent variable.they produce different termplot()s because
> of they base on different variables,one is x,the other is logx.see the
> lateral axis.

Sure; this is all obvious from the code and the plots.

But my question is *why* two fundamentally identical models produce different 
termplot()s?

As the original post asks:  If this is intended, what is the logic? Or am I 
missing something?

Let me place explain further.

Suppose I try this

m1 <- lm(y~x)
termplot(m1)

and I see that there is a problem.  So I decide to use log(x) as a predictor 
instead of x; I could do this one of two ways:

logx <- log(x)

m2 <- lm(y~logx)
termplot(m2)

m3 <- lm(y~log(x))
termplot(x3)


In the first case, the new termplot() tells me the model looks good.

In the second case, I output is the same as for termplot(m1) produced, and I 
don't really learn anything new.  

So the original questions remain: If this is intended, what is the logic? Or am 
I missing something?

Perhaps I could add: How do I explain and justify this behaviour to someone?

Thanks.

P.



Peter Dunn: Biostatistician (Room T4.12)
School of Health and Sport Science
Faculty of Science, Health and Education  ML-34
University of the Sunshine Coast, Locked Bag 4
Maroochydore DC Qld 4558
 
Tel: +61 7 5456 5085
Fax: +61 7 5430 2896
Email: pdu...@usc.edu.au
www.usc.edu.au

CRICOS Provider Number: 01595D
This communication is intended for the recipient only and should not be 
forwarded, distributed or otherwise read by others without express permission. 
The views expressed in this email are not necessarily those of the University 
of the Sunshine Coast.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

__
R-help@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] Using termplot() with transformations of x

2010-08-26 Thread Peter Dunn
Hi all

I was playing with termplot(), and came across what appears to be an 
inconsistency.

It would appreciate if someone could enlighten me:

> # First, generate some data:
> y <- rnorm(100)
> x <- runif(length(y),1,2)

> # Now find the log of x:
> logx <- log(x)
>
> # Now fit two models that are exactly the same, but specified differently:
> m1 <- lm(y~log(x)) # Using log in the call
> m2 <- lm(y~logx) # Using the variable logx
>
> # The two termplots() are different:
> par(mfrow=c(1,2))
> termplot(m1)
> termplot(m2)


I see two models that are identical, but produce different termplot()s.  In 
both cases, the independent variable is log(x), but is just specified 
differently.

If this is intended, what is the logic?  Or am I missing something?

Thanks.

P.

> sessionInfo()
R version 2.11.1 (2010-05-31) 
x86_64-apple-darwin9.8.0 

locale:
[1] en_AU.UTF-8/en_AU.UTF-8/C/C/en_AU.UTF-8/en_AU.UTF-8

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


Peter Dunn: Biostatistician (Room T4.12)
School of Health and Sport Science
Faculty of Science, Health and Education  ML-34
University of the Sunshine Coast, Locked Bag 4
Maroochydore DC Qld 4558
 
Tel: +61 7 5456 5085
Fax: +61 7 5430 2896
Email: pdu...@usc.edu.au
www.usc.edu.au

CRICOS Provider Number: 01595D
This communication is intended for the recipient only and should not be 
forwarded, distributed or otherwise read by others without express permission. 
The views expressed in this email are not necessarily those of the University 
of the Sunshine Coast.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

__
R-help@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] Sweave output from print.summary.glm is too wide

2009-08-18 Thread Peter Dunn
Hi all
 
I am preparing a document using Sweave; a really useful tool.  But I am having 
a problem.  
 
Consider this toy example Sweave file:
 
 
\documentclass{article}
 
\begin{document}
<>=
options(width=40)   # Set width to 40 characters
hide <- capture.output(example(glm)) # Create an example of the problem, but 
hide the output
summary(glm.D93)   # This is where the problem is evident
@
\end{document}
 
The intent of the  options(width=40)  command is to ensure the output does not 
extend to far to the right of the page, as per the Sweave manual Section A.14.  
And in most cases, this does the job.
 
Now, I run Sweave on the above file, run pdflatex.  Feel free to run the above 
code to see the actual result, but here is an edited text version of the output:
 
> options(width = 40)
> hide <- capture.output(example(glm))
> summary(glm.D93)
Call:
glm(formula = counts ~ outcome + treatment, family = poisson())
Deviance Residuals:
1 2 3 4
-0.67125 0.96272 -0.16965 -0.21999
5 6 7 8
-0.95552 1.04939 0.84715 -0.09167
9
-0.96656
Coefficients:
Estimate Std. Error
(Intercept) 3.045e+00 1.709e-01
outcome2 -4.543e-01 2.022e-01
outcome3 -2.930e-01 1.927e-01
treatment2 8.717e-16 2.000e-01
treatment3 4.557e-16 2.000e-01
z value Pr(>|z|)
(Intercept) 17.815 <2e-16 ***
outcome2 -2.247 0.0246 *
outcome3 -1.520 0.1285
treatment2 4.36e-15 1.
treatment3 2.28e-15 1.
 
 
The final pdf output file is mostly fine: but not all of the output of  
print.summary.glm  obeys the   width=40  command.  
 
The middle parts of the output are suitable wrapped (the coefficients, std 
error, z and P-value bit), but the bits at the end (not shown) and the start 
are not; for example, look at the  Call:  section of the output above.
 
I'd be expecting the initial part of the output to appear something like this, 
suitably wrapped:
 
 
> summary(glm.D93)
Call:
glm(formula = counts ~ outcome + 
treatment, family = poisson())
 
 
As far as I can recall,  print.summary.glm  and  print.summary.lm  are the only 
times I have seen this behaviour.  I found a similar thread posted June 2009 
("overshoot of formula line in summary output of Sweave"); there appeared no 
resolution in that thread, or after contacting the originator of the post.  
 
So my question:
* What can I do to ensure my output is not extending too far to the right with  
print.summary.glm?
 
 
Thanks as always.
 
P.
 

> sessionInfo()
R version 2.9.0 (2009-04-17)
i486-pc-linux-gnu
 
locale:
LC_CTYPE=en_AU.UTF-8;LC_NUMERIC=C;LC_TIME=en_AU.UTF-8;LC_COLLATE=en_AU.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_AU.UTF-8;LC_PAPER=en_AU.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_AU.UTF-8;LC_IDENTIFICATION=C
 
attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base
 
other attached packages:
[1] GLMsData_0.7
 
loaded via a namespace (and not attached):
[1] tools_2.9.0
>  

 
 
 
 
 
 
Peter Dunn: Biostatistician
School of Health and Sport Science
Faculty of Science, Health and Education  ML-34
University of the Sunshine Coast, Locked Bag 4
Maroochydore DC Qld 4558
 
Tel: +61 7 5456 5085
Fax: +61 7 5430 2896
Email: pdu...@usc.edu.au 
www.usc.edu.au ( http://www.usc.edu.au/ )

CRICOS Provider Number: 01595D

This communication is intended for the recipient only and should not be 
forwarded, distributed or otherwise read by others without express permission. 
The views expressed in this email are not necessarily those of the University 
of the Sunshine Coast.

-- 
This message has been scanned for viruses and\ dangerous...{{dropped:8}}

__
R-help@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.


Re: [R] Error building package: LaTeX error when creating PDF version

2009-04-23 Thread Peter Dunn
Duncan suggested R CMD check was not finding  pdflatex, because there is no 
.log file in the same directory as the .tex file.
 
However, the first line of output from R CMD check says:  
> * checking for working pdflatex ... OK
Indeed:
pdu...@pdunnubuntu:~/DSdata/GLMsData.Rchecks$ R CMD pdflatex
This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6)
 %&-line parsing enabled.
**
 
And it waits for input.
 
So that doesn't seem to be the problem.
 
Further suggestions?
 
P.
 
 
 
Peter Dunn: Biostatistician
School of Health and Sport Science
Faculty of Science, Health and Education  ML-34
University of the Sunshine Coast, Locked Bag 4
Maroochydore DC Qld 4558
 
Tel: +61 7 5456 5085
Fax: +61 7 5430 2896
Email: pdu...@usc.edu.au 
www.usc.edu.au ( http://www.usc.edu.au/ )

>>> Duncan Murdoch  24/04/2009 10:40 am >>>
On 23/04/2009 8:24 PM, Peter Dunn wrote:
> Hi all
>  
> I am trying to build an R package, which I have successfully done many times 
> before, but have an error I cannot trace.  I hope someone can help me.
>  
> Here's is some edited output (full output below if it is useful):
>  
> pdu...@pdunnubuntu:~/DSdata$ R CMD build GLMsData
> * checking for file 'GLMsData/DESCRIPTION' ... OK
> * preparing 'GLMsData':
> * checking DESCRIPTION meta-information ... OK
> * removing junk files
> * checking for LF line-endings in source and make files
> * checking for empty or unneeded directories
> * building 'GLMsData_0.7.tar.gz'
> 
> pdu...@pdunnubuntu:~/DSdata$ R CMD check GLMsData
> * checking for working pdflatex ... OK
> * using log directory '/home/pdunn2/DSdata/GLMsData.Rcheck'
> * using R version 2.9.0 (2009-04-17)
> 
> 
>  
> * checking data for non-ASCII characters ... OK
> * checking examples ... OK
> * checking PDF version of manual ... WARNING
> LaTeX errors when creating PDF version.
> This typically indicates Rd problems.
> * checking PDF version of manual without index ... ERROR
>  
>  
> So there is an error making the PDf version of the package manual.  That's 
> fine; I am happy to fix it.  But first I need to find it.
>  
> So I enter the directory GLMsData.Rcheck and find the corresponding tex file 
> for the manual, and run  pdflatex  on this tex file:
>  
> pdu...@pdunnubuntu:~/DSdata$ cd GLMsData.Rcheck/
> pdu...@pdunnubuntu:~/DSdata/GLMsData.Rcheck$ pdflatex GLMsData-manual.tex
> 
> 
> 
> Output written on GLMsData-manual.pdf (79 pages, 405091 bytes).
> Transcript written on GLMsData-manual.log.
> pdu...@pdunnubuntu:~/DSdata/GLMsData.Rcheck$ 
>  
>  
> So from what I gather:
> * R CMD check  finds an error when using  pdflatex  to make the PDF version 
> of the manual
> * But when I manually run  pdflatex  on the tex file, it works OK.
>  
> Obviously, I am missing something.  Can someone tell me what it is?  I can't 
> find enlightenment on the archives or the manuals.

You should also have a .log file in the same directory as the .tex file. 
  You probably have a new one now that pdflatex works; please move that 
one aside and run R CMD check again.  If you get a .log file, it should 
list whatever the error was; you could compare it to the .log that 
worked if you can't spot it.  If you don't get a new log, that means R 
CMD check couldn't run pdflatex.

Duncan Murdoch

> 
> Thanks everyone.
> 
> P.
> 
> 
> 
>> sessionInfo()
> R version 2.9.0 (2009-04-17)
> i486-pc-linux-gnu
> 
> locale:
> LC_CTYPE=en_AU.UTF-8;LC_NUMERIC=C;LC_TIME=en_AU.UTF-8;LC_COLLATE=en_AU.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_AU.UTF-8;LC_PAPER=en_AU.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_AU.UTF-8;LC_IDENTIFICATION=C
> 
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methodsbase
> 
> 
> 
> 
> 
> FULL OUTPUT:
> 
> pdu...@pdunnubuntu:~/DSdata$ R CMD build GLMsData
> * checking for file 'GLMsData/DESCRIPTION' ... OK
> * preparing 'GLMsData':
> * checking DESCRIPTION meta-information ... OK
> * removing junk files
> * checking for LF line-endings in source and make files
> * checking for empty or unneeded directories
> * building 'GLMsData_0.7.tar.gz'
> 
> pdu...@pdunnubuntu:~/DSdata$ R CMD check GLMsData
> * checking for working pdflatex ... OK
> * using log directory '/home/pdunn2/DSdata/GLMsData.Rcheck'
> * using R version 2.9.0 (2009-04-17)
> * using session charset: UTF-8
> * checking for file 'GLMsData/DESCRIPTION' ... OK
> * checking extension type ... Package
> * this is package 'GLMsData' version '0.7'
> * checking package dependencies ... OK
> * checking if this is a source packag

[R] Error building package: LaTeX error when creating PDF version

2009-04-23 Thread Peter Dunn
ival. Pub-lished on the in-ter-net [][]$\T1/p
cr/m/n/10 www . health . wa . gov . au / Publications /
[75]
Overfull \hbox (1.66795pt too wide) in paragraph at lines 3290--3290
[]\T1/ptm/m/n/10 the smok-ing sta-tus of the women in the \T1/ptm/m/it/10 orig-
i-nal \T1/ptm/m/n/10 sur-vey; a fac-tor with lev-els \T1/pcr/m/n/10 NonSmoker
[76] [77] [78]
No file GLMsData-manual.ind.
[79] (./GLMsData-manual.aux) )
(see the transcript file for additional information){/usr/share/texmf-texlive/f
onts/enc/dvips/base/8r.enc}
Output written on GLMsData-manual.pdf (79 pages, 405091 bytes).
Transcript written on GLMsData-manual.log.
pdu...@pdunnubuntu:~/DSdata/GLMsData.Rcheck$ 





-- 

Peter Dunn: Biostatistician
School of Health and Sport Science
Faculty of Science, Health and Education  ML-34
University of the Sunshine Coast, Locked Bag 4
Maroochydore DC Qld 4558
 
Tel: +61 7 5456 5085
Fax: +61 7 5430 2896
Email: pdu...@usc.edu.au
www.usc.edu.au


CRICOS Provider Number: 01595D

This communication is intended for the recipient only and should not be 
forwarded, distributed or otherwise read by others without express permission. 
The views expressed in this email are not necessarily those of the University 
of the Sunshine Coast.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

__
R-help@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] OT: Adding verbatim R code text into LaTeX documents: texttt; verb or url?

2009-01-27 Thread Peter Dunn
Hi all

I use Sweave extensively to mix R and LaTeX, and often have R code appearing in 
my LaTeX document.

Just a quick question then: What is the best way to add example of R commands 
into LaTeX in-line?  (That is, not using Sweave.)  For example, suppose I wish 
to place in my document this instruction:



...is done in R using the command  \verb|lm( y ~ var.one + var.two )| as 
follows:



I used  \verb  above, but I see three options:  \verb, \url (package url), or 
\texttt; there are probably others.

Here are my comments on these three:

- Using \texttt is OK, but it disappears my tildes and can hyphenate

- Using \verb is good, but it can hyphenate.

- Using \url is very good, but it:
* disappears my spaces; so for the above example, the spaces added for clarity 
are gone.
* Minor:  I like my verbatim text a little smaller (\small size), and change 
the font size for verbatim using  \def\verba...@font{\small\ttfamily} but \url 
seems to ignore this and appears larger than if I used \text or \verb.

Also, using \url often adds line-breaks mid-variable at the dots (for example, 
splitting  var.one  to have "var." on one line, and "one" on the next). I'm not 
sure this is a problem or not; here it is just an observation.

Ideally, one would want a LaTeX function, say \rcode{}, that displayed in-text 
using non-proportional font, kept tildes, kept spacing, uses my verb-font 
changes, and broke at sensible places for R.  (I don't want much, do I?)

So two questions:

* What do other people do?  Maybe there is a solution I have over-looked.

* Is there an easy solution?  I suppose writing such a command in LaTeX is 
possible, but there is strong evidence to reject the hypothesis that I would be 
able to write one.  Maybe one of the above choices are easily adopted.

If no easy solutions exist or emerge, I'm happy to run with \url.

Thanks again.

P.

Peter Dunn
Biostatistician
School of Health and Sport Science
Faculty of Science, Health and Education
University of the Sunshine Coast
 
Tel: +61 7 5456 5085
Fax: +61 7 5430 2896
Email: pdu...@usc.edu.au
www.usc.edu.au


CRICOS Provider Number: 01595D

This communication is intended for the recipient only and should not be 
forwarded, distributed or otherwise read by others without express permission. 
The views expressed in this email are not necessarily those of the University 
of the Sunshine Coast.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

__
R-help@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] Understanding glm family documentation: dev.resids

2008-11-12 Thread Peter Dunn
Hi all

Consider the  family  function, as used by glm.  The help page says the value 
of the family object is a list, one element of which is the following:


dev.resids function giving the deviance residuals as a function of (y, mu, wt). 


But reading any of the family functions (eg  poisson) shows that  dev.resids  
is a function that computes the *square* of the deviance residuals (at least, 
by every definition I know of).  Further, the deviance residuals returned by  
residuals.glm  are essentially computed as the square root of  dev.resids.

Something seems amiss.  The element  dev.resids  actually seems to compute the 
deviance residuals squared.  I guess the help file could be changed to read:


dev.resids function giving the square of the deviance residuals as a function 
of (y, mu, wt). 


...but then,  dev.resids  still seems a misleading label, but that may so 
entrenched it will never changed.

(By my definition, the square of the deviance residuals is not quite the unit 
deviance as the weights need to be incorporated differently, but others may 
disagree.)

Of course, I could be way off track.  I would appreciate enlightenment.

P.




Peter Dunn
Biostatistician
School of Health and Sport Science
Faculty of Science, Health and Education
University of the Sunshine Coast
 
Tel: +61 7 5456 5085
Fax: +61 7 5430 2896
Email: [EMAIL PROTECTED]
www.usc.edu.au


CRICOS Provider Number: 01595D

This communication is intended for the recipient only and should not be 
forwarded, distributed or otherwise read by others without express permission. 
The views expressed in this email are not necessarily those of the University 
of the Sunshine Coast.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

__
R-help@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] Citing R in journal articles (or the failure to)

2008-11-11 Thread Peter Dunn
Hi all

I was reading a paper recently in which I was surprised to see an R package of 
mine obviously used, without acknowledgement.  Indeed, R itself was used 
without any acknowledgment.  So I contact the author about these issues, who 
said (in part):


Regarding the R packages, I used the "tweedie" and "statmod" for my
analyses as you pointed out.
The referee of this paper advised me that it is not needed to cite
"R" because it is a kind of free software different from the
commercial package such as SAS.




What is the logic behind this?  What can be done about it?  That makes me quite 
angry...

P.

Peter Dunn
Biostatistician
School of Health and Sport Science
Faculty of Science, Health and Education
University of the Sunshine Coast
 
Tel: +61 7 5456 5085
Fax: +61 7 5430 2896
Email: [EMAIL PROTECTED]
www.usc.edu.au


Peter Dunn
Biostatistician
School of Health and Sport Science
Faculty of Science, Health and Education
University of the Sunshine Coast
 
Tel: +61 7 5456 5085
Fax: +61 7 5430 2896
Email: [EMAIL PROTECTED]
www.usc.edu.au


CRICOS Provider Number: 01595D

This communication is intended for the recipient only and should not be 
forwarded, distributed or otherwise read by others without express permission. 
The views expressed in this email are not necessarily those of the University 
of the Sunshine Coast.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

__
R-help@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.


Re: [R] Bug/Error in formatC? (Was: Why doesn 't formatC( x, digits=2, format= " g")...)

2008-06-10 Thread Peter Dunn
Martin

I know you and Brian have been discussing this issue, and Brian 
would officially declare it a 'buglet' if he used that word, but 
for completeness (I should have done this anyway; my oversight):

> What are the exact platform details?

> sessionInfo()
R version 2.7.0 (2008-04-22)
i486-pc-linux-gnu

locale:
LC_CTYPE=en_AU.UTF-8;LC_NUMERIC=C;LC_TIME=en_AU.UTF-8;LC_COLLATE=en_AU.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_AU.UTF-8;LC_PAPER=en_AU.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_AU.UTF-8;LC_IDENTIFICATION=C

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

loaded via a namespace (and not attached):
[1] tools_2.7.0


-- 
Dr Peter Dunn  |  dunn  usq.edu.au
Faculty of Sciences, USQ; http://www.sci.usq.edu.au/staff/dunn
Aust. Centre for Sustainable Catchments: www.usq.edu.au/acsc

This email (including any attached files) is confidentia...{{dropped:15}}

__
R-help@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] Bug/Error in formatC? (Was: Why doesn 't formatC( x, digits=2, format= " g")...)

2008-06-09 Thread Peter Dunn
Hi all

After posting what follows, Duncan Murdoch suggested perhaps a bug 
in formatC, or an error on documentation.  Any comments?

In particular, bug, error or not, any ideas about how I can 
consistently get two significant figures to print?

P.



--  Original Message  --

Hi all

I am not a C programmer, but I am trying to understand  formatC  to 
get consistent printing of reals to a given number of significant 
digits.

Can someone please explain this to me?  These first three give what 
I expect on reading ?formatC:


> formatC(0.005, digits=2,format="fg",flag="#")
[1] "0.0060"
> formatC(0.5, digits=2,format="fg",flag="#")
[1] "0.60"
> formatC(5., digits=2,format="fg",flag="#")
[1] "6.0"


This seems consistent with what I read (but perhaps do not 
understand) in ?formatC, where I read this:


digits   the desired number of digits after the decimal
point (format = "f") or significant digits (format = "g", 
= "e" or = "fg"). 


Since I am using  format="fg" and digits=2, so I am expecting two 
significant digits to always show, which I have above. So I fail to 
understand this:


> formatC(0.5, digits=2,format="fg",flag="#")
[1] "0.6"
> formatC(0.59, digits=2, format="fg",flag="#")
[1] "0.59"


I was expecting both of these to produce "0.59".  But in the 
first case above, I get one significant digit only.  

I'm obviously misunderstanding something; can someone enlighten me?  
(No doubt, someone will point out a nuance of the help files I 
didn't understand!) 

Also, since the above obviously doesn't do what I hoped 
(consistently printing two sig figs), could someone also explain 
how I can consistently get two significant figures in situation 
like above?

Thanks as always.

P.

-- 
Dr Peter Dunn  |  dunn  usq.edu.au
Faculty of Sciences, USQ; http://www.sci.usq.edu.au/staff/dunn
Aust. Centre for Sustainable Catchments: www.usq.edu.au/acsc

This email (including any attached files) is confidentia...{{dropped:15}}

__
R-help@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] Why doesn't formatC( x, digits=2, format="g") doesn't always give 2 sig figs?

2008-06-05 Thread Peter Dunn
Hi all

I am not a C programmer, but I am trying to understand  formatC  to 
get consistent printing of reals to a given number of significant 
digits.

Can someone please explain this to me?  These first three give what 
I expect on reading ?formatC:


> formatC(0.005, digits=2,format="fg",flag="#")
[1] "0.0060"
> formatC(0.5, digits=2,format="fg",flag="#")
[1] "0.60"
> formatC(5., digits=2,format="fg",flag="#")
[1] "6.0"


This seems consistent with what I read (but perhaps do not 
understand) in ?formatC, where I read this:


digits   the desired number of digits after the decimal point
(format = "f") or significant digits (format = "g", = "e" or
 = "fg"). 


Since I am using  format="fg" and digits=2, so I am expecting two 
significant digits to always show, which I have above. So I fail to 
understand this:


> formatC(0.5, digits=2,format="fg",flag="#")
[1] "0.6"
> formatC(0.59, digits=2, format="fg",flag="#")
[1] "0.59"


I was expecting both of these to produce "0.59".  But in the 
first case above, I get one significant digit only.  

I'm obviously misunderstanding something; can someone enlighten me?  
(No doubt, someone will point out a nuance of the help files I 
didn't understand!) 

Also, since the above obviously doesn't do what I hoped 
(consistently printing two sig figs), could someone also explain 
how I can consistently get two significant figures in situation 
like above?

Thanks as always.

P.
-- 
Dr Peter Dunn  |  dunn  usq.edu.au
Faculty of Sciences, USQ; http://www.sci.usq.edu.au/staff/dunn
Aust. Centre for Sustainable Catchments: www.usq.edu.au/acsc

This email (including any attached files) is confidentia...{{dropped:15}}

__
R-help@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.


Re: [R] tweedie model

2008-03-05 Thread Peter Dunn
I am.

What do you need to know now?

P.


On Thursday 06 March 2008 09:39, Roslina Zakaria wrote:
> Hi R users,
> Anybody using tweedie model to analyze rainfall data?
> Thanks in advance for your attention.
>
> __
> R-help@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.

-- 
Dr Peter Dunn  |  dunn  usq.edu.au
Faculty of Sciences, USQ; http://www.sci.usq.edu.au/staff/dunn
Aust. Centre for Sustainable Catchments: www.usq.edu.au/acsc

This email (including any attached files) is confidentia...{{dropped:15}}

__
R-help@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.


Re: [R] quantile-residual plot

2008-02-28 Thread Peter Dunn
> What is quantile residuals?
See

Dunn, Peter K. and Smyth, Gordon K. (1996). Randomized Quantile 
Residuals. Journal of Computational and Graphical Statistics, 
volume 5, issue 3, 236–244.

Or see ?qresid in R package  statmod.

P.

-- 
Dr Peter Dunn  |  dunn  usq.edu.au
Faculty of Sciences, USQ; http://www.sci.usq.edu.au/staff/dunn
Aust. Centre for Sustainable Catchments: www.usq.edu.au/acsc

This email (including any attached files) is confidentia...{{dropped:15}}

__
R-help@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] Adding LaTeX cross-references into Sweave plots

2008-02-26 Thread Peter Dunn
Hi all

I'm using Sweave and LaTeX, and love how they interact.

But here's a different interaction I'm not sure how to achieve; I 
hope someone can help.  I use a simple example, of course, to 
demonstrate.

Suppose in my LaTeX document I have this:

Here is a linear equation:
\begin{equation}
y = -1 + 3 x
\label{EQ:example}
\end{equation}

This appears in the final product with an Equation number, say (1).

Now suppose I wish to produce a graphic in R:

<>=
plot( c(-1,1), c(-1,1), type="n", 
main="Graph of Eq (1)")
abline(-1, 3)
@

All easy.

But... how to I ensure the correct LaTeX label appears in the plot?  
You see, if I run LaTeX again, and my equation is no longer 
labelled (1) and changes to (say) label (3), I have to manually fix 
the Sweave code to read

<>=
plot( c(-1,1), c(-1,1), type="n", 
main="Graph of Eq (3)")
abline(-1, 3)
@

Any ideas of how that can be automated?  I guess something like this 
(though this obviously will fail):


<>=
plot( c(-1,1), c(-1,1), type="n", 
main="Graph of Eq (\label{EQ:equation})")
abline(-1, 3)
@

Thanks as always.

P.

-- 
Dr Peter Dunn  |  dunn  usq.edu.au
Faculty of Sciences, USQ; http://www.sci.usq.edu.au/staff/dunn
Aust. Centre for Sustainable Catchments: www.usq.edu.au/acsc

This email (including any attached files) is confidentia...{{dropped:15}}

__
R-help@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.


Re: [R] Identity link in tweedie

2007-12-17 Thread Peter Dunn
Cristina

> I'm using the tweedie distribution package and I cant figure out
> how to run a model using an identity link. I know I can use a log
> link by having link.power=0 and I think identity would be
> link.power=1, but I'm not sure. 

Yes, that is correct.

> Furthermore when I try running it 
> with link.power=1 it requires starting values which I cant manage
> to give appropriately 

Without any code to see, I will guess at what is happening.  The 
trouble with using an identity link is that the predicted means, 
say mu, may be negative, where as the Tweedie distributions have mu 
greater than zero.  In using the identity link, you may be asking R 
to fit the impossible.

Perhaps the question you need to ask is this:  Why do you need an 
identity link?

P.

-- 
Dr Peter Dunn  |  dunn  usq.edu.au
Faculty of Sciences, USQ; http://www.sci.usq.edu.au/staff/dunn
Aust. Centre for Sustainable Catchments: www.usq.edu.au/acsc

This email (including any attached files) is confidentia...{{dropped:15}}

__
R-help@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.


Re: [R] Help! - boxcox transformations

2007-12-13 Thread Peter Dunn
> I am trying to detrend and transform variables to achieve
> normality and stationarity (for time series use, namely spectral
> analysis). I am using the boxcox transformations.
>
>
>
> As my dataset contains zeros, I found I need to add a constant to
> it in order to run "boxcox". 

If your data are continuous with exact zeros, and contain a lot of 
zeros, no transformation may help.  You simply map a stack of zeros 
to some other value.  Box--Cox transforms are not really designed 
for this.

If your data really is continuous with exact zeros, other options 
exist such as hurdle models, Tweedie glms (package  tweedie) and so 
forth.

P.

-- 
Dr Peter Dunn  |  dunn  usq.edu.au
Faculty of Sciences, USQ; http://www.sci.usq.edu.au/staff/dunn
Aust. Centre for Sustainable Catchments: www.usq.edu.au/acsc

This email (including any attached files) is confidentia...{{dropped:15}}

__
R-help@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] Mixing lty specifications in legend

2007-11-07 Thread Peter Dunn
Hi all

I have a plot with lines, one specified as (say) lty=1, 
using standard line types, and another as (say) my
own spec: lty="51".

I can't get  legend  to display both.  Toy example:


> plot(1~1)
> legend("topright", lty=c("51",1), legend=c("My own","Standard"))
Error in segments(x1, y1, x2, y2, ...) : invalid line type: must be
length 2, 4, 6 or 8
>


Any ideas?

P.

> sessionInfo()
R version 2.5.0 (2007-04-23) 
i386-pc-mingw32 

locale:
LC_COLLATE=English_Australia.1252;LC_CTYPE=English_Australia.1252;LC_MON
ETARY=English_Australia.1252;LC_NUMERIC=C;LC_TIME=English_Australia.1252

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

other attached packages:
car  xtable statmod 
"1.2-2" "1.5-1" "1.3.1" 





Dr Peter Dunn  (USQ CRICOS No. 00244B)
  Web:http://www.sci.usq.edu.au/staff/dunn
  Email:  dunn @ usq.edu.au
  ACSC:  http://www.usq.edu.au/acsc

This email (including any attached files) is confidentia...{{dropped:15}}

__
R-help@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] Problem using xtable on an array

2007-09-12 Thread Peter Dunn
Hi all

I know about producing a minimal example to show my problem.  But I'm
having trouble producing a minimal example that displays this
behaviour, so please bear with me to begin with.


Observe:  I create an array called model.mat.  Some details on this:

> str(model.mat)
 num [1:18, 1:4] -0.170 -0.304 -2.617  2.025 -1.610 ...
 - attr(*, "dimnames")=List of 2
  ..$ : chr [1:18] "Amount: CP for VF" "Amount: CP for F" "Amount: CP for 
M" "Amount: RD for VF" ...
  ..$ : chr [1:4] "beta_0" "P-value" "beta_1" "P-value"


It contains the following:

> model.mat[1:2,]
  beta_0   P-valuebeta_1  P-value
Amount: CP for VF -0.1702877 0.7716153 0.5148616 2.020602e-03
Amount: CP for F  -0.3042522 0.1966133 0.8795982 6.058299e-12



That's fine.  Now to produce a LaTeX table using xtable,
I get:

> xtable(model.mat[1:2,])

  Amount: CP for VF & $-$0.17 & 0.77 & 0.51 & 0.77 \\
  Amount: CP for F & $-$0.30 & 0.20 & 0.88 & 0.20 \\


That is, the final column does *not* correspond to the final
column of model.mat itself.  It is actually column 2 repeated.

What's going on?  If I try repeating on a minimal type example,
xtable works as expected:


> fred <- array( seq(1,18*4), dim=c(18,4))
> fred[1:2, ]
 [,1] [,2] [,3] [,4]
[1,]1   19   37   55
[2,]2   20   38   56
> xtable(fred[1:2, ])
% latex table generated in R 2.5.0 by xtable 1.4-6 package
% Thu Sep 13 14:09:46 2007
\begin{table}[ht]
\begin{center}
\begin{tabular}{r}
  \hline
 & 1 & 2 & 3 & 4 \\
  \hline
1 &   1 &  19 &  37 &  55 \\
  2 &   2 &  20 &  38 &  56 \\
   \hline
\end{tabular}
\end{center}
\end{table}


So it is not a generic problem. But what could it be?  I can't decide
where to look, so find a solution or produce a minimal example to display
this behaviour.  I actually use this construct with xtable a lot, so
it disturbs me to find this error... which is probably is something
I am doing.



The problem exists for a smaller subsets of this array also; let's take
columns 2, 3 and 4 only:

> model.mat[1:2,2:4]
P-valuebeta_1  P-value
Amount: CP for VF 0.7716153 0.5148616 2.020602e-03
Amount: CP for F  0.1966133 0.8795982 6.058299e-12
> xtable(model.mat[1:2,2:4])
% latex table generated in R 2.5.0 by xtable 1.4-6 package
% Thu Sep 13 14:04:40 2007
\begin{table}[ht]
\begin{center}
\begin{tabular}{}
  \hline
 & P-value & beta\_1 & P-value \\
  \hline
Amount: CP for VF & 0.77 & 0.51 & 0.77 \\
  Amount: CP for F & 0.20 & 0.88 & 0.20 \\
   \hline
\end{tabular}
\end{center}
\end{table}


Is it a problem with my particular array  model.mat  or something
I am doing wrong/silly?  I don't know where to start.

Thanks all, as always.

P.

> sessionInfo()
R version 2.5.0 (2007-04-23)
i486-pc-linux-gnu

locale:
LC_CTYPE=en_AU.UTF-8;LC_NUMERIC=C;LC_TIME=en_AU.UTF-8;LC_COLLATE=en_AU.UTF-8;LC_MONETARY=en_AU.UTF-8;LC_MESSAGES=en_AU.UTF-8;LC_PAPER=en_AU.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_AU.UTF-8;LC_IDENTIFICATION=C

attached base packages:
[1] "stats" "graphics"  "grDevices" "utils" "datasets"  "methods"
[7] "base"

other attached packages:
car  xtable statmod
"1.2-1" "1.4-6" "1.3.0"



-- 
Dr Peter Dunn  |  dunn  usq.edu.au
Faculty of Sciences, USQ; http://www.sci.usq.edu.au/staff/dunn
Aust. Centre for Sustainable Catchments: www.usq.edu.au/acsc

This email (including any attached files) is confidential an...{{dropped}}

__
R-help@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.