[R] Trouble with tibbles

2018-06-14 Thread Kevin E. Thorpe
I am trying to learn and use the tidyverse tools and one peculiarity 
that I seem to encounter is that converting some data frames to tibbles 
gives surprising results. I tried to make a toy example illustrates the 
problem but couldn't. Let me show some output that illustrates the problem.


> str(bincrct)
'data.frame':   267 obs. of  4 variables:
 $ StudyID : num  20101 20102 20103 20104 20105 ...
 $ Intervention: Factor w/ 2 levels "Intervention",..: 2 2 2 2 2 1 1 1 
1 1 ...

 $ Cluster : num  1 1 1 1 1 2 2 2 2 3 ...
 $ apptx   : num  0 0 1 0 0 1 1 1 0 1 ...
> as_tibble(bincrct)
Error: `x` must be a numeric or a character vector
> str(as_tibble(bincrct))
Classes ‘tbl_df’, ‘tbl’ and 'data.frame':   267 obs. of  4 variables:
 $ StudyID : num  20101 20102 20103 20104 20105 ...
 $ Intervention: Factor w/ 2 levels "Intervention",..: 2 2 2 2 2 1 1 1 
1 1 ...

 $ Cluster : num  1 1 1 1 1 2 2 2 2 3 ...
 $ apptx   : num  0 0 1 0 0 1 1 1 0 1 ...

When I tried to create a data frame and run as_tibble() on it, things 
behaved correctly. My best guess is that the old data frame I am using 
has some additional baggage with it that I am unaware of.


I also tried manually creating a tibble as follows which also did not work.

> with(bincrct, tibble(StudyID,Intervention,Cluster,apptx))
Error: `x` must be a numeric or a character vector

Any ideas? Here is my sessionInfo(). I just updated my packages this 
morning to see if that was the issue.


> sessionInfo()
R version 3.5.0 Patched (2018-04-23 r74633)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Slackware 14.2 x86_64 (post 14.2 -current)

Matrix products: default
BLAS: /usr/local/lib64/R/lib/libRblas.so
LAPACK: /usr/local/lib64/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=C
 [5] LC_MONETARY=en_US.UTF-8LC_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] stats graphics  grDevices utils datasets  methods   base

other attached packages:
 [1] forcats_0.3.0   stringr_1.3.1   dplyr_0.7.5 purrr_0.2.5
 [5] readr_1.1.1 tidyr_0.8.1 tibble_1.4.2ggplot2_2.2.1
 [9] tidyverse_1.2.1 knitr_1.20

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.17 cellranger_1.1.0 pillar_1.2.3 compiler_3.5.0
 [5] plyr_1.8.4   bindr_0.1.1  tools_3.5.0  lubridate_1.7.4
 [9] jsonlite_1.5 nlme_3.1-137 gtable_0.2.0 lattice_0.20-35
[13] pkgconfig_2.0.1  rlang_0.2.1  psych_1.8.4  cli_1.0.0
[17] rstudioapi_0.7   parallel_3.5.0   haven_1.1.1  bindrcpp_0.2.2
[21] xml2_1.2.0   httr_1.3.1   hms_0.4.2grid_3.5.0
[25] tidyselect_0.2.4 glue_1.2.0   R6_2.2.2 readxl_1.1.0
[29] foreign_0.8-70   modelr_0.1.2 reshape2_1.4.3   magrittr_1.5
[33] scales_0.5.0 rvest_0.3.2  assertthat_0.2.0 mnormt_1.5-5
[37] colorspace_1.3-2 stringi_1.2.3lazyeval_0.2.1   munsell_0.5.0
[41] broom_0.4.4  crayon_1.3.4


--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Trouble building R 3.5.0 under Ubuntu 18.04

2018-05-23 Thread Kevin E. Thorpe
I suspect the main difficulty the OP is having is building R with shlib 
support.


Steve, can you build from source without the --enable-R-shlib flag on 
configure?


Kevin

On 05/23/2018 01:58 PM, Ista Zahn wrote:

On Tue, May 22, 2018 at 6:47 PM, Steve Gutreuter <sgutreu...@gmail.com> wrote:

I would love to hear from anyone who has successfully built 3.5.0 under
  Ubuntu 18.04 (Bionic Beaver).


This is the wrong list, see R-sig-debian. That said,

apt-get update
apt-get build-dep r-base
wget https://cran.r-project.org/src/base/R-3/R-3.5.0.tar.gz
tar -xvf R-3.5.0.tar.gz
cd R-3.5.0
./configure
make
./bin/R

works for me.

--Ista
  My attempts have failed, including:


export LDFLAGS="$LDFLAGS -fPIC"
export CXXFLAGS="$CXXFLAGS -fPIC"
export CFLAGS="$CFLAGS -fPIC"
./configure --enable-R-shlib --prefix=/usr/lib/R/3.5.0

 Configure completes normally without errors or warnings

make

 make fails, always with lines like:
/usr/bin/x86_64-linux-gnu-ld: ../appl/dtrsl.o: relocation R_X86_64_32
against `.rodata' can not be used when making a shared object;
recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: attrib.o: relocation R_X86_64_PC32
against symbol `R_NilValue' can not be used when making a shared
object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
Makefile:177: recipe for target 'libR.so' failed
make[3]: *** [libR.so] Error 1
make[3]: Leaving directory '/home/steve/src/R/R-3.5.0/src/main'
Makefile:135: recipe for target 'R' failed

How does one set the -fPIC flag?

I have never had trouble compiling under Mint, which is based on
Ubuntu.

Thanks!
Steve




--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Converting a list to a data frame

2018-05-04 Thread Kevin E. Thorpe
It looks like you made a copy/paste error below. Your ata.frame should 
be data.frame.


Kevin

On 05/04/2018 08:18 AM, Bill Poling wrote:

Good morning.

Novice usR. Here.

I am following this string, among many, learning as I go.

Quick question please?

I thought that perhaps ata.frame was part of the zoo pkg, b/c when I 
searched it came up in help?


However, evidently not or I am not using it properly.

Please advise, thank you.

x <- list(A=data.frame(x=1:2, y=3:4),B=data.frame(x=5:6,y=7:8))

x2 <- do.call(rbind, lapply(names(x), function(z)

ata.frame(type=z, dat[[z]])))

#Error in ata.frame(type = z, dat[[z]]) : could not find function 
"ata.frame"


?ata.frame

??ata.frame #Looks like it’s part of the zoo package?

install.packages("zoo")

#Typo: dat[[z]] should be x[[z]]:

x <- list(A=data.frame(x=1:2, y=3:4),B=data.frame(x=5:6,y=7:8))

x2 <- do.call(rbind, lapply(names(x), function(z)

ata.frame(type=z, x[[z]])))

#Error in ata.frame(type = z, dat[[z]]) : still cannot find function 
"ata.frame"?


*William H. Poling, Ph.D.*

*From:* R-help [mailto:r-help-boun...@r-project.org] *On Behalf Of 
*Huzefa Khalil

*Sent:* Wednesday, May 02, 2018 1:24 PM
*To:* Kevin E. Thorpe <kevin.tho...@utoronto.ca>
*Cc:* R Help Mailing List <r-help@r-project.org>
*Subject:* Re: [R] Converting a list to a data frame

Hi Kevin,

There is probably a better way, but it can be done in two steps like this

temp <- list(A=data.frame(x=1:2, y=3:4),B=data.frame(x=5:6,y=7:8))

temp <- lapply(names(temp), function(n, temp) {
temp[[n]]$type <- n
return(temp[[n]])
}, temp = temp)

do.call(rbind, temp)



On Wed, May 2, 2018 at 1:11 PM, Kevin E. Thorpe 
<kevin.tho...@utoronto.ca <mailto:kevin.tho...@utoronto.ca>>

wrote:

 > I suspect this is pretty easy, but I'm having trouble figuring it out.
 > Basically, I have a list of data frames such as the following example:
 >
 > list(A=data.frame(x=1:2, y=3:4),B=data.frame(x=5:6,y=7:8))
 >
 > I would like to turn this into data frame where the list elements are
 > essentially rbind'ed together and the element name becomes a new 
variable.

 > For example, I would like to turn the list above into a data frame that
 > looks like this:
 >
 > data.frame(type=c("A","A","B","B"),x=c(1:2,5:6),y=c(3:4,7:8))
 >
 > Appreciate any pointers.
 >
 > Kevin
 >
 > --
 > Kevin E. Thorpe
 > Head of Biostatistics, Applied Health Research Centre (AHRC)
 > Li Ka Shing Knowledge Institute of St. Michael's Hospital
 > Assistant Professor, Dalla Lana School of Public Health
 > University of Toronto
 > email: kevin.tho...@utoronto.ca <mailto:kevin.tho...@utoronto.ca> 
Tel: 416.864.5776 Fax: 416.864.3016



--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Converting a list to a data frame

2018-05-03 Thread Kevin E. Thorpe

On 05/03/2018 01:28 PM, Hadley Wickham wrote:

On Wed, May 2, 2018 at 11:53 AM, Jeff Newmiller
<jdnew...@dcn.davis.ca.us> wrote:

Another approach:


library(tidyr)
L <- list( A = data.frame( x=1:2, y=3:4 )
  , B = data.frame( x=5:6, y=7:8 )
  )
D <- data.frame( Type = names( L )
, stringsAsFactors = FALSE
)
D$data <- L
unnest(D, data)
#>   Type x y
#> 1A 1 3
#> 2A 2 4
#> 3B 5 7
#> 4B 6 8



I think a slightly more idiomatic tidyverse solution is dplyr::bind_rows()

l <- list(
   A = data.frame(x = 1:2, y = 3:4),
   B = data.frame(x = 5:6, y = 7:8)
)

dplyr::bind_rows(l, .id = "type")
#>   type x y
#> 1A 1 3
#> 2A 2 4
#> 3B 5 7
#> 4B 6 8

This also has the advantage of returning a data frame when the inputs
are data frames.

Hadley



I _clearly_ need to learn the dplyr package.

--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Converting a list to a data frame

2018-05-03 Thread Kevin E. Thorpe

On 05/03/2018 03:59 AM, Martin Maechler wrote:

David L Carlson <dcarl...@tamu.edu>
 on Wed, 2 May 2018 21:43:52 + writes:



Typo: dat[[z]] should be x[[z]]:

x2 <- do.call(rbind, lapply(names(x), function(z)
 data.frame(type=z, x[[z]])))
x2
   type x y
1A 1 3
2A 2 4
3B 5 7
4B 6 8

David C


Before this thread gets carried away to data.table and
tibbleverse (and as nobody else has done so) :

Let me nominate this beautiful solution by
Bill Dunlap and David Carlson to win the prize  with a 10 out 10 grade:

Beautiful use of  do.call() and lapply(), two of the most
versatile and important functions from the base R toolbox.

Congratulations!

Martin Maechler
R Core Team


First of all, thank you to all who responded. I have learned (and will 
learn) about several new things. The data.table/tibbleverse is one of 
those places I have yet to tread but it never seems to be a "good" time 
to learn as generally when these tools would be helpful is when I am 
trying to get something done but don't have the time to recast the 
problem in a different paradigm.


Second, I echo Martin's comment. The combined solution of Bill Dunlap 
and David Carlson is beautifully elegant.


Thanks again,

Kevin




-Original Message-
From: R-help <r-help-boun...@r-project.org> On Behalf Of David L Carlson
Sent: Wednesday, May 2, 2018 3:51 PM
To: William Dunlap <wdun...@tibco.com>; Kevin E. Thorpe 
<kevin.tho...@utoronto.ca>
Cc: r-help mailing list <r-help@r-project.org>
Subject: Re: [R] Converting a list to a data frame

Or add the type column first and then rbind:

x <- list(A=data.frame(x=1:2, y=3:4),B=data.frame(x=5:6,y=7:8))
x2 <- do.call(rbind, lapply(names(x), function(z)
   data.frame(type=z, dat[[z]])))


David L Carlson
Department of Anthropology
Texas A University
College Station, TX 77843-4352

-Original Message-
From: R-help <r-help-boun...@r-project.org> On Behalf Of William Dunlap via 
R-help
Sent: Wednesday, May 2, 2018 12:28 PM
To: Kevin E. Thorpe <kevin.tho...@utoronto.ca>
Cc: R Help Mailing List <r-help@r-project.org>
Subject: Re: [R] Converting a list to a data frame


x1 <- do.call(rbind, c(x, list(make.row.names=FALSE)))
x2 <- cbind(type=rep(names(x), vapply(x, nrow, 0)), x1)
str(x2)

'data.frame':   4 obs. of  3 variables:
  $ type: Factor w/ 2 levels "A","B": 1 1 2 2
  $ x   : int  1 2 5 6
  $ y   : int  3 4 7 8


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Wed, May 2, 2018 at 10:11 AM, Kevin E. Thorpe <kevin.tho...@utoronto.ca>
wrote:


I suspect this is pretty easy, but I'm having trouble figuring it out.
Basically, I have a list of data frames such as the following example:

list(A=data.frame(x=1:2, y=3:4),B=data.frame(x=5:6,y=7:8))

I would like to turn this into  data frame where the list elements are
essentially rbind'ed together and the element name becomes a new variable.
For example, I would like to turn the list above into a data frame
that looks like this:

data.frame(type=c("A","A","B","B"),x=c(1:2,5:6),y=c(3:4,7:8))

Appreciate any pointers.

Kevin




--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Converting a list to a data frame

2018-05-02 Thread Kevin E. Thorpe
I suspect this is pretty easy, but I'm having trouble figuring it out. 
Basically, I have a list of data frames such as the following example:


list(A=data.frame(x=1:2, y=3:4),B=data.frame(x=5:6,y=7:8))

I would like to turn this into  data frame where the list elements are 
essentially rbind'ed together and the element name becomes a new 
variable. For example, I would like to turn the list above into a data 
frame that looks like this:


data.frame(type=c("A","A","B","B"),x=c(1:2,5:6),y=c(3:4,7:8))

Appreciate any pointers.

Kevin

--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Package ddalpha is not building for me in R 3.5.0

2018-04-27 Thread Kevin E. Thorpe
I was updating packages after upgrading R to 3.5.0 and one package, 
ddalpha, that is dependency for caret is not building. All the compiled 
code builds but something seems to start going wrong at the byte-compile 
stage. Here is the error and sessionInfo(). My computer has 8 GB of RAM, 
by the way. Has anyone else encountered this?


** R
** data
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error in system2(file.path(R.home("bin"), "R"), c(if (nzchar(arch)) 
paste0("--arch=",  :
  cannot popen ' '/usr/local/lib64/R/bin/R' --no-save --slave 2>&1 < 
'/tmp/RtmpZB2yyH/file64c65776e871'', probable reason 'Cannot allocate 
memory'

* removing ‘/usr/local/lib64/R/library/ddalpha’
Warning in q("no", status = status, runLast = FALSE) :
  system call failed: Cannot allocate memory


sessionInfo()

R version 3.5.0 Patched (2018-04-23 r74633)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Slackware 14.2 x86_64 (post 14.2 -current)

Matrix products: default
BLAS: /usr/local/lib64/R/lib/libRblas.so
LAPACK: /usr/local/lib64/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=C
 [5] LC_MONETARY=en_US.UTF-8LC_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] stats graphics  grDevices utils datasets  methods   base

loaded via a namespace (and not attached):
[1] compiler_3.5.0 tools_3.5.0tcltk_3.5.0


--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] unable to move temporary installation of package

2018-03-28 Thread Kevin E. Thorpe
I am glad you found the culprit. I will tuck that additional piece of 
info away for the next time my students have trouble.


Kevin

On 03/27/2018 09:22 PM, Paul Lantos wrote:

I think MalwareBytes may have been the culprit. I disabled it and it's working 
now (even with my regular antivirus running).

Thanks all for the advice!
Paul

-Original Message-
From: Paul Lantos
Sent: Tuesday, March 27, 2018 8:35 PM
To: Kevin E. Thorpe <kevin.tho...@utoronto.ca>; Jeff Newmiller 
<jdnew...@dcn.davis.ca.us>
Cc: r-help@r-project.org
Subject: RE: [R] unable to move temporary installation of package

Thanks, Kevin. I have done that but no luck.
Paul

-Original Message-
From: Kevin E. Thorpe [mailto:kevin.tho...@utoronto.ca]
Sent: Tuesday, March 27, 2018 2:15 PM
To: Paul Lantos <paul.lan...@duke.edu>; Jeff Newmiller 
<jdnew...@dcn.davis.ca.us>
Cc: r-help@r-project.org
Subject: Re: [R] unable to move temporary installation of package

I have seen that error from students trying to install, usually from the Rcpp 
package.

One suggestion I received was to try disabling your virus scanner while doing 
the install. The reason being that the scanner has not completed its job by the 
time the installer wants to move stuff around.

Kevin

On 03/27/2018 01:14 PM, Paul Lantos wrote:

Thanks,

Here's the error, for example:


install.packages("mgcv")

Installing package into 'C:/Users/pl39/Documents/R/win-library/3.4'
(as 'lib' is unspecified)
trying URL 
'https://urldefense.proofpoint.com/v2/url?u=https-3A__mirrors.nics.utk.edu_cran_bin_windows_contrib_3.4_mgcv-5F1.8-2D23.zip=DwICaQ=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_gZ4adc=pCiIbVPBNWU0azo0D48ChUH_fawb-FalNVOf1sUn1r4=5-qaO5WU1pkjvRmIviMw3IowdsiGfP6AgLhJVhucBw8=_oH3hPXmUvvElYCBZg_LBSX0-ZF3XUqACxmRdV1Gzso='
Content type 'application/zip' length 2775362 bytes (2.6 MB)
downloaded 2.6 MB

package 'mgcv' successfully unpacked and MD5 sums checked Warning in
install.packages :
unable to move temporary installation 
'C:\Users\pl39\Documents\R\win-library\3.4\file1f287a90e67\mgcv' to 
'C:\Users\pl39\Documents\R\win-library\3.4\mgcv'

The downloaded binary packages are in
C:\Users\pl39\AppData\Local\Temp\RtmpWorMmU\downloaded_packages






getOption("repos")

  CRANCRANextra
"https://urldefense.proofpoint.com/v2/url?u=https-3A__mirrors.nics.utk.edu_cran_=DwICaQ=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_gZ4adc=pCiIbVPBNWU0azo0D48ChUH_fawb-FalNVOf1sUn1r4=5-qaO5WU1pkjvRmIviMw3IowdsiGfP6AgLhJVhucBw8=vmRVCTk6BWFZihnxWmmt3Y-Jiz-XaemOdukRPfySpEY=;
 
"https://urldefense.proofpoint.com/v2/url?u=http-3A__www.stats.ox.ac.uk_pub_RWin=DwICaQ=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_gZ4adc=pCiIbVPBNWU0azo0D48ChUH_fawb-FalNVOf1sUn1r4=5-qaO5WU1pkjvRmIviMw3IowdsiGfP6AgLhJVhucBw8=BUJFWakLtQSrcVuTuqJ-PPtwzHo5pfFje9q2D18Fs-Y=;
attr(,"RStudio")
[1] TRUE

I've used different CRAN mirrors though and gotten the same error.



Would you suggest deleting my personal directory and recreating it? I get the 
same error if I try and install packages to my documents, my desktop, wherever, 
so I sort of doubt that would fix the problem.

Paul


-Original Message-
From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us]
Sent: Tuesday, March 27, 2018 1:14 PM
To: Paul Lantos <paul.lan...@duke.edu>
Cc: r-help@r-project.org
Subject: RE: [R] unable to move temporary installation of package

Nothing jumps out at me yet.

1) You missed including the text of your command (presumably
install.packages) along with the actual text of the error.

2) What is the output of:

getOption("repos")

3) You might also consider looking at

system2( "cacls.exe", .libPaths()[1] )

though we may not be able to interpret the output appropriately in this venue if you are 
working on a managed computer... you might need local help. I would guess you would need 
"yourdomain\youruser:(OI)(CI)F".

Note that your personal R library is not deleted when you uninstall R...
if you have not yet deleted C:\Users\pl39\Documents\R\win-library\3.4
and let R re-create it then uninstalling would not have helped a permissions 
problem.

On Tue, 27 Mar 2018, Paul Lantos wrote:


Ok, thanks --


sessionInfo()

R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8
x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
States.1252 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

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

loaded via a namespace (and not attached):
[1] compiler_3.4.4 tools_3.4.4yaml_2.1.14

.libPaths()

[1] "C:/Users/pl39/Documents/R/win-library/3.4" "C:/Program 
Files/R/R-3.4.4/library"

file.info(.libPaths())

  

Re: [R] unable to move temporary installation of package

2018-03-27 Thread Kevin E. Thorpe
n. I don't run R in any
special way.

So I'm not sure where that leaves me... thanks for any suggestions.

Paul



-Original Message-
From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us]
Sent: Monday, March 26, 2018 5:22 PM
To: r-help@r-project.org; Paul Lantos <paul.lan...@duke.edu>;
r-help@r-project.org
Subject: Re: [R] unable to move temporary installation of package

A) Don't try to "move" packages from one library (=directory of
installed packages) to another.

B) Although R Open is very close to CRAN R, it has some differences
that you REALLY NEED TO READ about at their website. Pay particular
attention to the checkpoint feature in this case. Note that troubles
installing it or with the MKL are probably off-topic here, though R
language questions should still be fair game.

C) Having Administrator rights carries at least as much
responsibility to know what you are doing BEFORE you do it as it
bestows flexibility to get things done. If you used "Run As
Administrator" to install R or any packages then you have probably
set the permissions on your personal library inappropriately. If so,
you need to use your superpowers judiciously to eliminate your
personal library completely and then run R as a normal user to install/update R 
packages.
--
Sent from my phone. Please excuse my brevity.

On March 26, 2018 12:16:02 PM PDT, Paul Lantos <paul.lan...@duke.edu>
wrote:

I'm running Windows 10 / R Studio / R Open 3.4.3



Since getting a new computer recently I cannot install packages into

my

personal libpath directory, and I can't seem to update packages (it
says all packages are up to date even if I manually install an old
version). I've got 100% admin rights on the computer and in the

library

folder, I've set my R environment variable to specify the correct
directory, I can freely move things manually in and out of the
library



if needed, and R can read and use any package that's already in there.
But I can't install or I get the "unable to move" error.



I've uninstalled and reinstalled everything, tried this in
non-Studio sessions using both R Open and regular R 3.4.4, and I get
the same error.



Thanks for any help,

Paul Lantos


_
Paul M. Lantos, MD, MS GIS, FIDSA, FAAP, FACP Associate Professor of
Internal Medicine and Pediatrics  Pediatric Infectious Diseases
General Internal Medicine Duke University School of Medicine Duke
Global Health Institute
_


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mail
m
an_listinfo_r-2Dhelp=DwIFaQ=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_g
Z
4adc=pCiIbVPBNWU0azo0D48ChUH_fawb-FalNVOf1sUn1r4=twuFRS-tVJfQuRzjI
S
0GBC710QPtmpe1rDy5PNvS-GI=OtjN9-16IbB6IqUW1THCx-YX8wccZgBEQmfZY6cuBI
I
=
PLEASE do read the posting guide
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.or
g
_posting-2Dguide.html=DwIFaQ=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_
g
Z4adc=pCiIbVPBNWU0azo0D48ChUH_fawb-FalNVOf1sUn1r4=twuFRS-tVJfQuRzj
I
S0GBC710QPtmpe1rDy5PNvS-GI=sY7Wm-L9iESeuqa2CevDBwLsBx06RewTYq2-DFg9K
M U= and provide commented, minimal, self-contained, reproducible

code.




---
Jeff NewmillerThe .   .  Go Live...
DCN:<jdnew...@dcn.davis.ca.us>Basics: ##.#.   ##.#.  Live Go...
Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k




--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Unexpected behaviour in rms::lrtest

2018-02-14 Thread Kevin E. Thorpe

Hello.

One of my teaching assistants was experimenting and encountered 
unexpected behaviour with the lrtest function in the rms package. It 
appears that when you have a pair of non-nested models that employ an 
RCS, the error checking for non-nested models appears not to work.


Here is a reproducible example.

> library(rms)
Loading required package: Hmisc
Loading required package: lattice
Loading required package: survival
Loading required package: Formula
Loading required package: ggplot2

Attaching package: ‘Hmisc’

The following objects are masked from ‘package:base’:

format.pval, units

Loading required package: SparseM

Attaching package: ‘SparseM’

The following object is masked from ‘package:base’:

backsolve

>
> ### Code below that generates the data taken from the
> ### help page for lrm()
>
> n <- 1000# define sample size
> set.seed(17) # so can reproduce the results
> age<- rnorm(n, 50, 10)
> blood.pressure <- rnorm(n, 120, 15)
> cholesterol<- rnorm(n, 200, 25)
> sex<- factor(sample(c('female','male'), n,TRUE))
> label(age)<- 'Age'  # label is in Hmisc
> label(cholesterol)<- 'Total Cholesterol'
> label(blood.pressure) <- 'Systolic Blood Pressure'
> label(sex)<- 'Sex'
> units(cholesterol)<- 'mg/dl'   # uses units.default in Hmisc
> units(blood.pressure) <- 'mmHg'
>
> # Specify population model for log odds that Y=1
> L <- .4*(sex=='male') + .045*(age-50) +
+  (log(cholesterol - 10)-5.2)*(-2*(sex=='female') + 2*(sex=='male'))
> # Simulate binary y to have Prob(y=1) = 1/[1+exp(-L)]
> y <- ifelse(runif(n) < plogis(L), 1, 0)
>
> exdata <- 
data.frame(y=y,age=age,blood.pressure=blood.pressure,cholesterol=cholesterol,sex=sex)

>
> ###
> ### Example
> ###
>
> fit1 <- lrm(y ~ blood.pressure + sex * age + cholesterol, data = exdata)
> fit2 <- lrm(y ~ blood.pressure + age + sex * cholesterol, data = exdata)
> lrtest(fit1, fit2) # error as expected
Error in lrtest(fit1, fit2) : models are not nested
> fit3 <- lrm(y ~ blood.pressure + sex * age + rcs(cholesterol, 4), 
data = exdata)
> fit4 <- lrm(y ~ blood.pressure + age + sex * rcs(cholesterol, 4), 
data = exdata)

> lrtest(fit3,fit4) # gives result for apparently non-nested models

Model 1: y ~ blood.pressure + sex * age + rcs(cholesterol, 4)
Model 2: y ~ blood.pressure + age + sex * rcs(cholesterol, 4)

  L.R. Chisq d.f.P
2.043630e+01 2.00e+00 3.650168e-05

For reference, here is my sessionInfo() although my TA got the same 
results and I do not know what his sessionInfo() was.


> sessionInfo()
R version 3.4.3 Patched (2017-12-12 r73903)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Slackware 14.2

Matrix products: default
BLAS: /usr/local/lib64/R/lib/libRblas.so
LAPACK: /usr/local/lib64/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=C
 [5] LC_MONETARY=en_US.UTF-8LC_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] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] rms_5.1-2   SparseM_1.77Hmisc_4.1-1 ggplot2_2.2.1
[5] Formula_1.2-2   survival_2.41-3 lattice_0.20-35 knitr_1.18

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.14pillar_1.0.1compiler_3.4.3
 [4] RColorBrewer_1.1-2  plyr_1.8.4  base64enc_0.1-3
 [7] tools_3.4.3 rpart_4.1-11digest_0.6.13
[10] polspline_1.1.12nlme_3.1-131tibble_1.4.1
[13] gtable_0.2.0htmlTable_1.11.1checkmate_1.8.5
[16] rlang_0.1.6 Matrix_1.2-12   rstudioapi_0.7
[19] mvtnorm_1.0-6   gridExtra_2.3   stringr_1.2.0
[22] cluster_2.0.6   MatrixModels_0.4-1  htmlwidgets_0.9
[25] grid_3.4.3  nnet_7.3-12 data.table_1.10.4-3
[28] foreign_0.8-69  multcomp_1.4-8  TH.data_1.0-8
[31] latticeExtra_0.6-28 magrittr_1.5codetools_0.2-15
[34] MASS_7.3-48 scales_0.5.0backports_1.1.2
[37] htmltools_0.3.6 splines_3.4.3       colorspace_1.3-2
[40] quantreg_5.34   sandwich_2.4-0  stringi_1.1.6
[43] acepack_1.4.1   lazyeval_0.2.1  munsell_0.4.3
[46] zoo_1.8-1


--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Cox Regression : Spline Coefficient Interpretation?

2017-11-02 Thread Kevin E. Thorpe

Your output is mangled beyond interpretation.

However, when it comes to interpreting splines in general, you cannot 
easily convert the individual beta coefficients into, say HR by 
exponenitating them. The collection of beta coefficients describe the 
relationship between the continuous variable and the outcome.


Consider a simple case. Suppose you fit a model with x and x^2. You 
cannot really interpret the x^2 coefficient in isolation from the x 
coefficient. It is the same with splines only worse.


Graphical displays of the spline are often more informative.

Kevin

On 11/01/2017 04:12 PM, Kosta S. wrote:

Hi,

I'm using a Cox-Regression to estimate hazard rates on prepayments.

I'm using the "pspline" function to face non-linearity, but I have no clue
how to interpret the result.
Unfortunately I did not find enough information on the "pspline" function
wether in the survival package nor using google..

I got following output:

* library(survival)*
















*> Option.test2<-coxph(Surv(START,STOP,ZEROBAL==1)~pspline(OPTION),
data=FNMA)coxph(formula = Surv(START, STOP, ZEROBAL == 1) ~
pspline(OPTION), data = FNMA)> > Option.test2> Call:> coxph(formula =
Surv(START, STOP, ZEROBAL == 1) ~ pspline(OPTION), > data = FNMA)>
  coef  se(coef)   se2 Chisq   DF
 p> pspline(OPTION), linear   -0.13340.01310.0131  104.4325
1.00 <0.0002> pspline(OPTION), nonlin
 1747.1295 3.05 <0.0002> Iterations: 8 outer, 19
Newton-Raphson>  Theta= 0.991 > Degrees of freedom for terms= 4 >
Likelihood ratio test=2136  on 4.05 df, p=0  n= 3390429 >  *



Thanks,

KS




--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Converting SAS Code

2017-09-29 Thread Kevin E. Thorpe
Regarding point 3, as a moderator I have been helping Andrew get this 
post out to the list over the past week. His previous attempts were 
encoded in some way that the listserv rejected. He sent me the post via 
his gmail account and viewing the source I saw it had at least both 
plain test and HTML an I said it was worth a try to post it. Certainly 
on my mail client his post displays acceptably with the notice that the 
HTML alternative was removed.


Kevin

On 09/29/2017 09:51 AM, Michael Dewey wrote:

You might get better answers if you

1 - break this down into separate issues
2 - tell us what you want to achieve in words rather than SAS, we all 
read English but few of us speak SAS

3 - post in plain text not HTML as HTML mangles your post

On 29/09/2017 13:47, Andrew Harmon wrote:

Hello all,

My statistical analysis training up until this point has been 
entirely done

in SAS. The code I frequently used was:

*Yield Champagin;

data yield;

set stress;

if field='YV' then delete;

if field='HB' then delete;

if barcode='16187DD4015' then delete;

if barcode='16187DD6002' then delete;

if barcode='16187DD2007' then delete;

if barcode='16187DD5016' then delete;

if barcode='16187DD8007' then delete;

if barcode='16187DD7010' then delete;

if barcode='16187DD7007' then delete;

if barcode='16187DD8005' then delete;

if barcode='16187DD6004' then delete;

if barcode='16187DD5008' then delete;

if barcode='16187DD7012' then delete;

if barcode='16187DD6010' then delete;

run; quit;



Title'2016 Asilomar Stress Relief champagin yield';

proc mixed method=reml data=yield;

class rep Management Foliar_Fungicide Chemical_Treatment;

model Grain_Yield__Mg_h_ =Management|Foliar_Fungicide|Chemical_Treatment
Final_Stand__Plants_A_ / outpred=resids residual ddfm=kr;

random rep rep*Management rep*Management*Foliar_Fungicide;

lsmeans Management|Foliar_Fungicide|Chemical_Treatment / pdiff;

ods output diffs=ppp lsmeans=means;

ods listing exclude diffs lsmeans;

run; quit;

%include'C:\Users\harmon12\Desktop\pdmix800.sas';

%pdmix800(ppp,means,alpha=0.10,sort=yes);

ods graphics off;

run; quit;

proc univariate data=resids normal plot; id Barcode Grain_Yield__Mg_h_
pearsonresid; var resid;
proc print data=resids (obs=3);run;

Can someone please help me convert my code to R? Any help would be much
appreciated.


Thanks,


Andrew Harmon

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

---
This email has been checked for viruses by AVG.
http://www.avg.com






--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Reversing table()

2017-03-17 Thread Kevin E. Thorpe
I am wondering if there is a way to undo the results of table().

For example if you had a table that looked like the result of table(x, y) or 
table(x, y, z) is there a simple/elegant way to reverse the process to get the 
"original" x, y and z vectors?

Thanks,

Kevin

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] rms::latex.anova broken?

2017-02-09 Thread Kevin E. Thorpe
I figured I should follow-up to say the function is not broken, rather 
it was me not paying close attention to recent release notes.


Frank Harrell kindly informed me (thanks Frank) that with recent 
versions of Hmisc/rms I should use options(prType="latex") for LaTeX 
output to behave correctly.


Kevin

On 02/07/2017 02:23 PM, Kevin E. Thorpe wrote:

I am re-running some logistic regression analyses using lrm from the rms
package but latex(anova(...)) appears to be broken on my system.

Here is some anova() output followed by the latex() error for two models
since the error changes. My sessionInfo() follows the other output. I
have updated all my packages and re-installed Hmisc and rms plus
dependencies. The only thing I haven't done yet is update R completely.
Has anyone else encountered this and know how to solve it?


anova(full)

Wald Statistics  Response: id14

 Factor  Chi-Square d.f. P
 birthweight_kilo 0.87   1   0.3517
 ageinmonth   4.12   1   0.0423
 zbmi 6.49   1   0.0108
 maxtbf  15.16   1   0.0001
 cowsmilk 6.54   1   0.0106
 Male 1.96   1   0.1611
 multivitamin 0.76   1   0.3819
 bottleuse0.13   1   0.7194
 preterm  0.50   1   0.4811
 AGEINTRO_cowsmilk0.06   1   0.8032
 AGEINTRO_complefood  0.61   1   0.4356
 TOTAL   30.49  11   0.0013

latex(anova(full),file="",table.env=FALSE,booktabs=TRUE)

Error in ifelse(sn %nin% c("d.f.", "MS", "Partial SS"), math(sn), sn) :
  could not find function "math"

anova(full.nl)

Wald Statistics  Response: id14

 Factor  Chi-Square d.f. P
 birthweight_kilo 3.68   2   0.1588
  Nonlinear   2.65   1   0.1037
 ageinmonth  16.25   2   0.0003
  Nonlinear  13.45   1   0.0002
 zbmi 4.07   2   0.1310
  Nonlinear   0.23   1   0.6323
 maxtbf  15.81   2   0.0004
  Nonlinear   2.57   1   0.1092
 cowsmilk 3.34   2   0.1880
  Nonlinear   1.16   1   0.2821
 Male 1.21   1   0.2711
 multivitamin 0.57   1   0.4494
 bottleuse0.06   1   0.8100
 preterm  0.01   1   0.9418
 AGEINTRO_cowsmilk3.65   2   0.1612
  Nonlinear   3.28   1   0.0700
 AGEINTRO_complefood  5.40   2   0.0671
  Nonlinear   4.00   1   0.0455
 TOTAL NONLINEAR 25.41   7   0.0006
 TOTAL   52.13  18   <.0001

latex(anova(full.nl),file="",table.env=FALSE,booktabs=TRUE)

Error in paste0(specs$lspace, specs$italics(substring(rowl, 2)), sep =
"") :
  attempt to apply non-function


sessionInfo()

R version 3.2.3 Patched (2016-01-31 r70055)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Slackware 14.2

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=C
 [5] LC_MONETARY=en_US.UTF-8LC_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] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] rms_5.1-0   SparseM_1.74Hmisc_4.0-2 ggplot2_2.2.1
[5] Formula_1.2-1   survival_2.40-1 lattice_0.20-34 knitr_1.15.1

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.9 RColorBrewer_1.1-2  plyr_1.8.4
 [4] base64enc_0.1-3 tools_3.2.3 rpart_4.1-10
 [7] digest_0.6.12   polspline_1.1.12tibble_1.2
[10] gtable_0.2.0htmlTable_1.9   checkmate_1.8.2
[13] nlme_3.1-131Matrix_1.2-8mvtnorm_1.0-5
[16] gridExtra_2.2.1 stringr_1.1.0   cluster_2.0.5
[19] htmlwidgets_0.8 MatrixModels_0.4-1  grid_3.2.3
[22] nnet_7.3-12 data.table_1.10.4   foreign_0.8-67
[25] multcomp_1.4-6  TH.data_1.0-8   latticeExtra_0.6-28
[28] magrittr_1.5codetools_0.2-15MASS_7.3-45
[31] scales_0.4.1backports_1.0.5 htmltools_0.3.5
[34] splines_3.2.3   assertthat_0.1  colorspace_1.3-2
[37] quantreg_5.29   sandwich_2.3-4  stringi_1.1.2
[40] acepack_1.4.1   lazyeval_0.2.0  munsell_0.4.3
[43] zoo_1.7-14





--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] rms::latex.anova broken?

2017-02-07 Thread Kevin E. Thorpe
I am re-running some logistic regression analyses using lrm from the rms 
package but latex(anova(...)) appears to be broken on my system.


Here is some anova() output followed by the latex() error for two models 
since the error changes. My sessionInfo() follows the other output. I 
have updated all my packages and re-installed Hmisc and rms plus 
dependencies. The only thing I haven't done yet is update R completely. 
Has anyone else encountered this and know how to solve it?


> anova(full)
Wald Statistics  Response: id14

 Factor  Chi-Square d.f. P
 birthweight_kilo 0.87   1   0.3517
 ageinmonth   4.12   1   0.0423
 zbmi 6.49   1   0.0108
 maxtbf  15.16   1   0.0001
 cowsmilk 6.54   1   0.0106
 Male 1.96   1   0.1611
 multivitamin 0.76   1   0.3819
 bottleuse0.13   1   0.7194
 preterm  0.50   1   0.4811
 AGEINTRO_cowsmilk0.06   1   0.8032
 AGEINTRO_complefood  0.61   1   0.4356
 TOTAL   30.49  11   0.0013
> latex(anova(full),file="",table.env=FALSE,booktabs=TRUE)
Error in ifelse(sn %nin% c("d.f.", "MS", "Partial SS"), math(sn), sn) :
  could not find function "math"
> anova(full.nl)
Wald Statistics  Response: id14

 Factor  Chi-Square d.f. P
 birthweight_kilo 3.68   2   0.1588
  Nonlinear   2.65   1   0.1037
 ageinmonth  16.25   2   0.0003
  Nonlinear  13.45   1   0.0002
 zbmi 4.07   2   0.1310
  Nonlinear   0.23   1   0.6323
 maxtbf  15.81   2   0.0004
  Nonlinear   2.57   1   0.1092
 cowsmilk 3.34   2   0.1880
  Nonlinear   1.16   1   0.2821
 Male 1.21   1   0.2711
 multivitamin 0.57   1   0.4494
 bottleuse0.06   1   0.8100
 preterm  0.01   1   0.9418
 AGEINTRO_cowsmilk3.65   2   0.1612
  Nonlinear   3.28   1   0.0700
 AGEINTRO_complefood  5.40   2   0.0671
  Nonlinear   4.00   1   0.0455
 TOTAL NONLINEAR 25.41   7   0.0006
 TOTAL   52.13  18   <.0001
> latex(anova(full.nl),file="",table.env=FALSE,booktabs=TRUE)
Error in paste0(specs$lspace, specs$italics(substring(rowl, 2)), sep = 
"") :

  attempt to apply non-function

> sessionInfo()
R version 3.2.3 Patched (2016-01-31 r70055)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Slackware 14.2

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=C
 [5] LC_MONETARY=en_US.UTF-8LC_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] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] rms_5.1-0   SparseM_1.74Hmisc_4.0-2 ggplot2_2.2.1
[5] Formula_1.2-1   survival_2.40-1 lattice_0.20-34 knitr_1.15.1

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.9 RColorBrewer_1.1-2  plyr_1.8.4
 [4] base64enc_0.1-3 tools_3.2.3 rpart_4.1-10
 [7] digest_0.6.12   polspline_1.1.12tibble_1.2
[10] gtable_0.2.0htmlTable_1.9   checkmate_1.8.2
[13] nlme_3.1-131Matrix_1.2-8mvtnorm_1.0-5
[16] gridExtra_2.2.1 stringr_1.1.0   cluster_2.0.5
[19] htmlwidgets_0.8 MatrixModels_0.4-1  grid_3.2.3
[22] nnet_7.3-12 data.table_1.10.4   foreign_0.8-67
[25] multcomp_1.4-6  TH.data_1.0-8   latticeExtra_0.6-28
[28] magrittr_1.5codetools_0.2-15MASS_7.3-45
[31] scales_0.4.1backports_1.0.5 htmltools_0.3.5
[34] splines_3.2.3   assertthat_0.1  colorspace_1.3-2
[37] quantreg_5.29   sandwich_2.3-4  stringi_1.1.2
[40] acepack_1.4.1   lazyeval_0.2.0  munsell_0.4.3
[43] zoo_1.7-14


--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Converting a list to a data frame

2016-11-04 Thread Kevin E. Thorpe
There is probably a very simple elegant way to do this, but I have been 
unable to find it. Here is a toy example. Suppose I have a list of data 
frames like this.


 print(x <- 
list('1'=data.frame(id=1:4,expand.grid(x1=0:1,x2=0:1)),'2'=data.frame(id=5:8,expand.grid(x1=2:3,x2=2:3

$`1`
  id x1 x2
1  1  0  0
2  2  1  0
3  3  0  1
4  4  1  1

$`2`
  id x1 x2
1  5  2  2
2  6  3  2
3  7  2  3
4  8  3  3

The real application will have more than 2 elements so I'm looking for a 
general approach. I basically want to rbind the data frames in each list 
element and add a variable that adds the element name. In this example 
the result would look something like this.


rbind(data.frame(set='1',x[[1]]),data.frame(set='2',x[[2]]))
  set id x1 x2
1   1  1  0  0
2   1  2  1  0
3   1  3  0  1
4   1  4  1  1
5   2  5  2  2
6   2  6  3  2
7   2  7  2  3
8   2  8  3  3

Obviously, for 2 elements the simple rbind works but I would like a 
general solution for arbitrary length lists. Hopefully that is clear.


Kevin

--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Error installing packages

2016-10-19 Thread Kevin E. Thorpe

Hello.

I am posting this on behalf of one of my students who is getting error 
messages when installing some packages. I have not seen this before nor 
have I been able to replicate it. I'm including the relevant (I think) 
information. I get the students to install rms with dependencies. As you 
can see, rms does get installed but when the attempt is made to attach 
it, ggplot2 cannot be loaded. Thus I tried explicitly installing ggplot2 
and you can see then ensuing errors below. I have included the 
sessionInfo() at the end.


I hope someone can point me at a solution.


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> install.packages("rms",dependencies=TRUE)
Installing package into ‘C:/Users/Leticia/Documents/R/win-library/3.3’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 
'http://cran.utstat.utoronto.ca/bin/windows/contrib/3.3/rms_4.5-0.zip'

Content type 'application/zip' length 1074995 bytes (1.0 MB)
downloaded 1.0 MB

package ‘rms’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\Leticia\AppData\Local\Temp\Rtmpa0q2o2\downloaded_packages
> library(rms)
Loading required package: Hmisc
Loading required package: lattice
Loading required package: survival
Loading required package: Formula
Loading required package: ggplot2
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), 
versionCheck = vI[[j]]) :

  there is no package called ‘Rcpp’
Error: package ‘ggplot2’ could not be loaded
> install.packages("ggplot2",dependencies=TRUE)
Installing package into ‘C:/Users/Leticia/Documents/R/win-library/3.3’
(as ‘lib’ is unspecified)
also installing the dependency ‘maptools’

trying URL 
'http://cran.utstat.utoronto.ca/bin/windows/contrib/3.3/maptools_0.8-39.zip'

Content type 'application/zip' length 1816384 bytes (1.7 MB)
downloaded 0 bytes

trying URL 
'http://cran.utstat.utoronto.ca/bin/windows/contrib/3.3/ggplot2_2.1.0.zip'

Content type 'application/zip' length 1996146 bytes (1.9 MB)
downloaded 4096 bytes

Error in read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", 
"Type")) :

  cannot open the connection
In addition: Warning messages:
1: In download.file(url, destfile, method, mode = "wb", ...) :
  downloaded length 0 != reported length 1816384
2: In download.file(url, destfile, method, mode = "wb", ...) :
  downloaded length 4096 != reported length 1996146
3: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file
4: In read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) :
  cannot open compressed file 'maptools/DESCRIPTION', probable reason 
'No such file or directory'

> library(rms)
Loading required package: Hmisc
Loading required package: ggplot2
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), 
versionCheck = vI[[j]]) :

  there is no package called ‘Rcpp’
Error: package ‘ggplot2’ could not be loaded
> session.info()
Error: could not find function "session.info"
> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 10586)

locale:
[1] LC_COLLATE=English_Canada.1252  LC_CTYPE=English_Canada.1252 
LC_MONETARY=English_Canada.1252

[4] LC_NUMERIC=CLC_TIME=English_Canada.1252

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

other attached packages:
[1] Formula_1.2-1   survival_2.39-4 lattice_0.20-33

loaded via a namespace (and not attached):
[1] Matrix_1.2-6  tools_3.3.1   gtable_0.2.0  splines_3.3.1 grid_3.3.1
>

--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Multistate survival models

2016-05-20 Thread Kevin E. Thorpe

A quick (I think) question.

Does the survreg() function in the survival package handle Surv() 
objects of type mstate?


It's not clear from the documentation that it doesn't. The Vignette only 
discusses the Cox model and the Fine-Gray model.


I tried using survreg() on an mstate Surv() object. It did not give an 
error and produced a result but I don't know if it did a competing risk 
analysis or not.


Thanks.

--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] factor variables in logistic regression

2016-05-11 Thread Kevin E. Thorpe

On 05/11/2016 08:00 AM, ch.elahe via R-help wrote:

Hi all,

I have a plot for TSTMean vs. SNRMean and both of these variables are factors. 
How can I use Logistic Regression for factor variables?
Currently I use model=lm(TSTMean~SNRMean,data=df) but when I check 
summary(model) I get this error: r error in quartile.default (resid) factors 
are not allowed

thanks for any help,
Elahe



First of all, lm() is for linear regression, not logistic regression. 
For logistic regression you need to use glm() and make sure you set the 
correct family (see ?glm). I don't recall if glm() accepts a factor 
outcome but if not, you would need to re-code it to 0/1.


Kevin

--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] R-help mailing list activity / R-not-help?

2016-01-25 Thread Kevin E. Thorpe
k the "Don't send" or 
"Save" button and think better of their replies.





--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] package broom

2016-01-06 Thread Kevin E. Thorpe

On 01/06/2016 12:57 PM, James Henson wrote:

Dear R community

My version is R version 3.2.3.
The package "broom" appears to install, but it will not load.
The error message is below.



library(broom)

Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck
= vI[[j]]) :
   there is no package called ‘mnormt’
Error: package or namespace load failed for ‘broom’




It looks like you need to install the package mnormt.


Thanks,
James F. Henson

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.




--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Correct notation for functions, packages when using LaTex

2015-12-10 Thread Kevin E. Thorpe

On 12/10/2015 12:10 PM, Erin Hodgess wrote:

Hello everyone!

I am writing up something (quickly) using LaTex and periodically refer to R
functions and packages.

What is the correct way to put those into LaTex, please?  I know that R
itself is {\tt R}, but am not sure about the others.

Thanks for any help,
Sincerely,
Erin
PS  Or should I just be doing this in R Studio, even though there is no
code, please?




When I refer to R function in a LaTeX document I tend to use \texttt{} 
(same as your {\tt } construct). Historical convention rendered computer 
code in a monospace font (akin to Courier) so that's what I follow.


--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Issues with loading csv file

2015-05-25 Thread Kevin E. Thorpe

On 05/25/2015 08:19 AM, Shivi82 wrote:

HI All,

I am trying to load an CSV file into the R project. the code for the same
is:
mydata- read.csv(Jan-May Data.csv, header=TRUE)

however with this I am getting the below error message:
/*Error in file(file, rt) : cannot open the connection
In addition: Warning message:
In file(file, rt) :
   cannot open file 'Jan-May Data.csv': No such file or directory*/

I am under the impression that R automatically pulls the data from the
working directory and we do not have to add the location where the file is
saved. Please let me know if my understanding is correct and help on the
error as well.

Please note the csv file is already saved in the WD.
Thank you, Shivi



The error message suggests that R is not finding the file. Are you sure 
it is in R's working directory? Try explicitly setting the working 
directory to the directory (folder) where your CSV file is. There is a 
menu option for this.


Kevin

--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Randomly interleaving data frames while preserving order

2015-03-31 Thread Kevin E. Thorpe

Hello.

I am trying to simulate recruitment in a randomized trial. Suppose I 
have three streams (strata) of patients represented by these data frames.


df1 - data.frame(strat=rep(1,10),id=1:10,pid=1001:1010)
df2 - data.frame(strat=rep(2,10),id=1:10,pid=2001:2010)
df3 - data.frame(strat=rep(3,10),id=1:10,pid=3001:3010)

What I need to do is construct a data frame with all of these combined 
where the order of selection from one of the three data frames is 
randomized but once a stratum is selected patients are selected 
sequentially from that data frame.


To see what I'm looking to achieve, suppose the first five subjects were 
to come, in order, from strata (data frames) 1, 2, 1, 3 and 2. The 
expected result should look like this:


rbind(df1[1,],df2[1,],df1[2,],df3[1,],df2[2,])
   strat id  pid
1  1  1 1001
2  2  1 2001
21 1  2 1002
4  3  1 3001
22 2  2 2002

I hope what I'm trying to accomplish makes sense. Maybe I'm missing 
something obvious, but I really have no idea at the moment how to 
achieve this elegantly. Since I need to simulate many trial recruitments 
it needs to be general and compact.


I appreciate any advice.

Kevin

--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Randomly interleaving data frames while preserving order

2015-03-31 Thread Kevin E. Thorpe

On 03/31/2015 01:44 PM, Duncan Murdoch wrote:

On 31/03/2015 1:05 PM, Kevin E. Thorpe wrote:

Hello.

I am trying to simulate recruitment in a randomized trial. Suppose I
have three streams (strata) of patients represented by these data frames.

df1 - data.frame(strat=rep(1,10),id=1:10,pid=1001:1010)
df2 - data.frame(strat=rep(2,10),id=1:10,pid=2001:2010)
df3 - data.frame(strat=rep(3,10),id=1:10,pid=3001:3010)

What I need to do is construct a data frame with all of these combined
where the order of selection from one of the three data frames is
randomized but once a stratum is selected patients are selected
sequentially from that data frame.

To see what I'm looking to achieve, suppose the first five subjects were
to come, in order, from strata (data frames) 1, 2, 1, 3 and 2. The
expected result should look like this:

rbind(df1[1,],df2[1,],df1[2,],df3[1,],df2[2,])
 strat id  pid
1  1  1 1001
2  2  1 2001
21 1  2 1002
4  3  1 3001
22 2  2 2002

I hope what I'm trying to accomplish makes sense. Maybe I'm missing
something obvious, but I really have no idea at the moment how to
achieve this elegantly. Since I need to simulate many trial recruitments
it needs to be general and compact.

I appreciate any advice.


How about something like this:

# Permute an ordered vector of selections:
sel - sample(c(rep(1, nrow(df1)), rep(2, nrow(df2)), rep(3, nrow(df3

# Create an empty dataframe to hold the results
df - data.frame(strat=NA, id=NA, pid=NA)[rep(1, length(sel)),]

# Put the original dataframes into the appropriate slots:
df[sel == 1,] - df1
df[sel == 2,] - df2
df[sel == 3,] - df3

# Clean up the rownames
rownames(df) - NULL

Duncan Murdoch



Thanks Duncan.

Once you see the solution it is indeed obvious.

Kevin

--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Use of R for Hypothesis Testing

2015-02-14 Thread Kevin E. Thorpe
You will only really learn R by reading and trying things yourself. As 
John says, there are many good books out there. Have you read the 
introductory material that comes with R in the help system? I would 
recommend you start the help system and scroll through the list of 
functions contained in the stats package. You will be amazed at what you 
find.


Kevin

On 02/14/2015 12:08 PM, John Kane wrote:

There are anumber of good papers and books in pdf format at the
R site.  Select a CRAN location and you should see an entry for them on the 
left side of the page. Pick a couple and see if they help.

And for a fun read on introductory statistics in general which should cover 
everything you wanted to know and more have a look at
Danial Navarro's downloadable stats book at 
http://health.adelaide.edu.au/psychology/ccs/teaching/lsr/

John Kane
Kingston ON Canada



-Original Message-
From: lis...@terpmail.umd.edu
Sent: Fri, 13 Feb 2015 12:17:10 -0500
To: r-help@r-project.org
Subject: [R] Use of R for Hypothesis Testing

Dear Staff
Hello,

I am recently trying to learn some functions of R. How would I use R to
do
T-test, confidence interval calculation, chi-square test and ANOVA?

--
Thank you
Sike Li (Lydia)

[[alternative HTML version deleted]]




--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] the less-than-minus gotcha

2015-02-01 Thread Kevin E. Thorpe

Using = has it's problems too.

For example,

print(fit - lm(...))

Assigns the result of the lm call to fit and prints the results. This is 
quite a useful trick actually.


print(fit = lm(...))

Throws an error.

Moral of story, computers do what you tell them, not what you meant.

Kevin

On 02/01/2015 08:26 PM, Steve Taylor wrote:

All the more reason to use = instead of -


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ben Bolker
Sent: Monday, 2 February 2015 2:07p
To: r-h...@stat.math.ethz.ch
Subject: Re: [R] the less-than-minus gotcha

Mike Miller mbmiller+l at gmail.com writes:



I've got to remember to use more spaces.  Here's the basic problem:

These are the same:

v 1
v1

But these are extremely different:

v -1
v-1



This is indeed documented, in passing, in one of the pages you listed:

http://tim-smith.us/arrgh/syntax.html

Whitespace is meaningless, unless it isn't. Some parsing ambiguities
are resolved by considering whitespace around operators. See and
despair: x-y (assignment) is parsed differently than x  -y (comparison)!




--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Injecting a column of characters to a matrix of numerics

2014-10-29 Thread Kevin E. Thorpe

On 10/29/2014 11:41 AM, Steven Yen wrote:

Hello
I am designing a regression printout, which works out nicely. Then, I
try to inject a column of characters to indicate a discrete regressor
with a dot (.). Then, all numbers seem to turn into characters, in
quotations. Is there a way to do this right? Below, I show the lines of
codes before and after. Thanks.
Steven Yen

---
out-round(cbind(me,se,t,p),digits)
colnames(out)-c(estimates,s.e.,|t-value|,p-value)
rownames(out)-rownames(me)
out
 estimates s.e. |t-value|  p-value
(Intercept)  0.223263 0.146167  1.527459 0.127173
sex  0.049830 0.039612  1.257973 0.208890
age -0.070423 0.029539  2.384035 0.017433
yrmarry  0.015567 0.005298  2.938126 0.003429
children 0.060525 0.044778  1.351659 0.176993
religius-0.053128 0.014413  3.686260 0.000248
educ 0.003226 0.008453  0.381636 0.702866
occu 0.003915 0.011860  0.330147 0.741404
rating  -0.077856 0.014466  5.381925 0.00

out-round(cbind(me,se,t,p),digits); out-cbind(out,disc)
colnames(out)-c(estimates,s.e.,|t-value|,p-value,disc)
rownames(out)-rownames(me)

(Intercept) 0.223263  0.146167 1.527459 0.127173 
sex 0.04983   0.039612 1.257973 0.20889  .
age -0.070423 0.029539 2.384035 0.017433 
yrmarry 0.015567  0.005298 2.938126 0.003429 
children0.060525  0.044778 1.351659 0.176993 .
religius-0.053128 0.014413 3.68626  0.000248 
educ0.003226  0.008453 0.381636 0.702866 
occu0.003915  0.01186  0.330147 0.741404 
rating  -0.077856 0.014466 5.381925 0


Use data frames instead.

out-data.frame(round(cbind(me,se,t,p),digits)); out-cbind(out,disc)
names(out)-c(estimates,s.e.,|t-value|,p-value,disc)


__
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.



--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] R for Android

2014-05-08 Thread Kevin E. Thorpe
This is a question asked purely out of idle curiosity (and may also be 
in wrong list). Are there plans for porting R to Android devices or 
chromebooks? Maybe it's as simple as compiling the source, but I don't 
know what tools are available.


One of the current advantages of R is it runs on all commonly used 
platforms. If chromebooks and android devices get into greater use, it 
would be cool if R were available.


Kevin

--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] R for Android

2014-05-08 Thread Kevin E. Thorpe

Thanks. I guess I could have searched for that. Apologies.

I'll have to try it on my tablet.

Kevin

On 05/08/2014 11:57 AM, Jeremy Miles wrote:


It exists:
https://play.google.com/store/apps/details?id=com.appsopensource.R

No graphics.

Jeremy




On 8 May 2014 05:44, Kevin E. Thorpe kevin.tho...@utoronto.ca
mailto:kevin.tho...@utoronto.ca wrote:

This is a question asked purely out of idle curiosity (and may also
be in wrong list). Are there plans for porting R to Android devices
or chromebooks? Maybe it's as simple as compiling the source, but I
don't know what tools are available.

One of the current advantages of R is it runs on all commonly used
platforms. If chromebooks and android devices get into greater use,
it would be cool if R were available.

Kevin




--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] 'rms' package error

2014-04-03 Thread Kevin E. Thorpe

On 04/02/2014 10:29 PM, Lucy Leigh wrote:

Hi everyone,
I am attempting to use the R package 'rms'
http://biostat.mc.vanderbilt.edu/wiki/Main/Rrms
to implement a PH weibull model, using the pphsm() function.

However, I get the following error,
f.ph - pphsm(f)
Warning message:
In pphsm(f) :
   at present, pphsm does not return the correct covariance matrix

I tried simply running the example on page 117 of the manual, i.e.
set.seed(1)
S - Surv(runif(100))
x - runif(100)
dd - datadist(x); options(datadist='dd')
f - psm(S ~ x, dist=exponential)
summary(f) # effects on log(T) scale
f.ph - pphsm(f)
## Not run: summary(f.ph)

But I still got the above error message.
I have looked through the R help archives, and it appears that this question 
has been asked before in 2011, but
there were no replies.
http://r.789695.n4.nabble.com/HELP-td3494640.html

Does anyone know how to get this function to work? Or if there is an 
alternative package that can implement
a Weibull PH model?
Cheers,
Lucy



Maybe I'm missing something, but since the AFT and PH models intersect 
in the weibull distribution, why not just use the psm() function to fit 
the parametric model. You can still obtain hazard ratio estimates from 
that model with a little bit of calculation (e.g. exp(-beta/scale)).



--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] Syntax for order()

2014-03-25 Thread Kevin E. Thorpe

On 03/25/2014 02:36 PM, John Kane wrote:

Has there been a change in the syntax for order() or am I just making some 
stupid mistake here?

dat1 -read.table(text=
name val
Alex 4
Jim 10
Fred 8
Julie 44
,sep=,header=TRUE,stringsAsFactors=FALSE)
dat1[order(val), ]  # Gives Error in order(val) : object 'val' not found

dat1[order(dat1[,2]), ] # Works just fine.

John Kane
Kingston ON Canada


I don't think the behaviour has changed. I bet dat1[order(dat1$val), ] 
works just fine.


--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] A 'good' way to build a matrix from a sequence of integers?

2013-10-15 Thread Kevin E. Thorpe

On 10/15/2013 07:11 PM, Stock Beaver wrote:

# I understand that a good way to build a vector from a sequence of integers,
# is to use syntax like this:
myvec = c(1:99)


First, the c() is not needed here.

myvec - 1:99

works just fine.



# Here is the 'short' version of my question:
# I want to understand a 'good' way to build a matrix from a sequence of 
integers.

# If that question is not clear, here is a longer version:

# Here is what I did for a 1D-matrix:

# I pick the sequence 1:3
# I build a vector:
vec1x3 = c(1:3)
vec1x3
# I transform it into a 1 x 3 matrix:
m1x3 = matrix(vec1x3, c(length(vec1x3),1))
m1x3
#  [,1]
# [1,]1
# [2,]2
# [3,]3
# 

# That was easy.

# Next I want to expand from a 1 x 3 matrix to a 2 x 9 matrix
# which contains all combinations of 1:3


I think you want expand.grid.

expand.grid(x1=1:3, x2=1:3)



# So the first 4 rows would look like this:
# 1 1
# 1 2
# 1 3 I call this a rowvec
# 2 1

# My first idea is write a loop like this:

for (i in 1:3) {
   for(j in 1:3) {
 rowvec = c(i,j)
 # Place rowvec in matrix
   }
}

# I'm curious if a skilled R-person would do it differently?
[[alternative HTML version deleted]]



__
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.




--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] Memory limit on Linux?

2013-08-13 Thread Kevin E. Thorpe

On 08/13/2013 03:06 PM, Stackpole, Chris wrote:



From: Kevin E. Thorpe [mailto:kevin.tho...@utoronto.ca]
Sent: Monday, August 12, 2013 11:00 AM
Subject: Re: [R] Memory limit on Linux?

What does ulimit -a report on both of these machines?


Greetings,
Sorry for the delay. Other fires demanded more attention...

For the system in which memory seems to allocate as needed:
$ ulimit -a
core file size  (blocks, -c) 0
data seg size   (kbytes, -d) unlimited
scheduling priority (-e) 0
file size   (blocks, -f) unlimited
pending signals (-i) 386251
max locked memory   (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files  (-n) 1024
pipe size(512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority  (-r) 0
stack size  (kbytes, -s) 10240
cpu time   (seconds, -t) unlimited
max user processes  (-u) 386251
virtual memory  (kbytes, -v) unlimited
file locks  (-x) unlimited

For the system in which memory seems to hang around 5-7GB:
$ ulimit -a
core file size  (blocks, -c) 0
data seg size   (kbytes, -d) unlimited
scheduling priority (-e) 0
file size   (blocks, -f) unlimited
pending signals (-i) 2066497
max locked memory   (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files  (-n) 1024
pipe size(512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority  (-r) 0
stack size  (kbytes, -s) unlimited
cpu time   (seconds, -t) unlimited
max user processes  (-u) 1024
virtual memory  (kbytes, -v) unlimited
file locks  (-x) unlimited

I can also confirm the same behavior on a Scientific Linux system though the 
difference besides CentOS/RHEL is that the Scientific is at an earlier 
version of 6 (6.2 to be exact). The Scientific system has the same ulimit configuration 
as the problem box.

I could be mistaken, but here are the differences I see in the ulimits:
pending signals: shouldn't matter
max locked memory: The Scientific/CentOS system is higher so I don't think this 
is it.
stack size: Again, higher on Scientific/CentOS.
max user processes: Seems high to me, but I don't see how this is capping a 
memory limit.

Am I missing something? Any help is greatly appreciated.
Thank you!

Chris Stackpole



It appears that at the shell level, the differences are not to blame. 
It has been a long time, but years ago in HP-UX, we needed to change an 
actual kernel parameter (this was for S-Plus 5 rather than R back then). 
 Despite the ulimits being acceptable, there was a hard limit in the 
kernel.  I don't know whether such things have been (or can be) built in 
to your problem machine.  If it is a multiuser box, it could be that 
limits have been set to prevent a user from gobbling up all the memory.


The other thing to check is if R has/can be compiled with memory limits.

Sorry I can't be of more help.

--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] Memory limit on Linux?

2013-08-12 Thread Kevin E. Thorpe

On 08/12/2013 10:18 AM, Stackpole, Chris wrote:

Greetings, I have a user who is running an R program on two different
Linux systems. For the most part, they are very similar in terms of
hardware and 64bit OS. However, they perform significantly different.
Under one box the program uses upwards of 20GB of ram but fluctuates
around 15GB of ram and the job runs for a few hours. The second box
has even more memory available to it, however, the exact same program
with the exact same data set peaks at 7GB of ram but runs around 5GB
of ram and takes 3x longer to run the job!

I did some research, and from what I can tell R should just use as
much memory as it needs on Linux. So a lot of the help I found
online has been windows related information (eg: --max-mem-size ) and
not very useful to me. I looked at the ulimits and everything looks
like it should be correct (or at least it is comparable to the
ulimits on the system that is working correctly). I have also checked
other tidbits here and there but nothing seems to be of use. I also
checked that a single user can allocate large quantities of memory
(eg: Matlab and SAS both were able to allocate 20GB+ of memory) so I
don't think it is a user-restriction placed by the OS.

The only differences I have found between the two boxes that really
stands out is that the system that works runs RHEL proper and has R
compiled but the one that doesn't allocate all of the memory was
installed via EPEL RPM on CentOS. Compiling R on the CentOS system is
on the try-this list, but before I spend that time trying to compile
I thought I would ask a few questions.

1) Anyone know why I might be seeing this strange behavior? 5-7GB of
ram is clearly over any 32bit limitation so I don't think it has
anything to do with that. It could be a RHEL vs CentOS thing, but
that seems very strange to me.

2) When I compile from source to test this, is there a specific
option I should pass to ensure max usage?

Thank you.

Chris Stackpole



What does ulimit -a report on both of these machines?

--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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

2013-05-17 Thread Kevin E. Thorpe

On 05/17/2013 02:34 PM, masumeh akhgar wrote:

hi deer all
Estimate KM survival probabilities for each categories of RX means
‘treatment’ and ‘placebo’ separately

surv.Rx-survfit(Surv(SURVT,STATUS)~strata(RX),data=rem.data)

when write that command. it doesnt run.
what should i do?
thanks



What do you mean it doesn't run?  Is there an error message?  What is 
it?  Also, you do not need to put RX in strata() in the survfit() function.



--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] Strange graphical pattern when using hist() function

2013-04-23 Thread Kevin E. Thorpe

On 04/23/2013 01:40 PM, Humberto Mohr wrote:

Running the following lines I got a strange plot from hist function:

x-0:30
hist(x,breaks=31)

As you can see, the 0 value appears two times in the plot.
The Y axis only presents 1 as the highest value when:

hist(x,breaks=62)

Nevertheless, it seems to have two bars between 0 and 1.

Could someone please explain to me why it is happening?

Many thanks in advance!



I think if you do print(hist(x,breaks=31)) you will see it.

The zero bin has the values for zero and one.  There are 30 bins, not 
31, as I think you are expecting.


Take a look at the ?hist to understand how the bins are constructed.

--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] t-statistic for independent samples

2013-04-17 Thread Kevin E. Thorpe


On 04/17/2013 06:24 PM, David Arnold wrote:

Hi,

Typical things you read when new to stats are cautions about using a
t-statistic when comparing independent samples. You are steered toward a
pooled test or welch's approximation of the degrees of freedom in order to
make the distribution a t-distribution. However, most texts give no
information why you have to do this.

So I thought I try a little experiment which is outlined here.

Distrubtion of differences of independent samples
http://msemac.redwoods.edu/~darnold/math15/R/chapter11/DistributionForTwoIndependentSamplesPartII.html

As you can see in the above link, I see no evidence why you need a pooled or
Welch's in these images.

Anyone care to comment? Or should I put this on Stack Exchange?

D.


Admittedly, I just skimmed the page, but one thing stands out.  Your 
standard deviations are really quite close to each other.  Try your 
simulations again with variance ratios exceeding 2 and see what happens.



--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] update.packages(checkBuilt = TRUE) fails in updating rpanel_1.1-1 due to missing package BWidget

2013-03-26 Thread Kevin E. Thorpe
I encountered the same problem.  I emailed the maintainer last week but 
have not yet received a response.


I don't see a BWidget package on CRAN either.

On 03/26/2013 04:31 AM, Juergen Rose wrote:

update.packages(checkBuilt = TRUE) fails with:


update.packages(checkBuilt = TRUE)

rpanel :
  Version 1.0-6 installed in /usr/lib64/R/library built under R 2.15.0
  Version 1.1-1 available at http://mirrors.softliste.de/cran
Update (y/N/c)?  y
trying URL
'http://mirrors.softliste.de/cran/src/contrib/rpanel_1.1-1.tar.gz'
Content type 'application/x-gzip' length 702508 bytes (686 Kb)
opened URL
==
downloaded 686 Kb

* installing *source* package ‘rpanel’ ...
** package ‘rpanel’ successfully unpacked and MD5 sums checked
** R
** data
**  moving datasets to lazyload DB
** demo
** inst
** preparing package for lazy loading
Error in structure(.External(dotTcl, ..., PACKAGE = tcltk), class =
tclObj) :
   [tcl] can't find package BWidget.

Error : unable to load R code in package ‘rpanel’
ERROR: lazy loading failed for package ‘rpanel’
* removing ‘/usr/lib64/R/library/rpanel’
* restoring previous ‘/usr/lib64/R/library/rpanel’

The downloaded source packages are in
 ‘/tmp/RtmpCltR3Z/downloaded_packages’
Updating HTML index of packages in '.Library'
Making packages.html  ... done
Warning message:
In install.packages(update[instlib == l, Package], l, contriburl =
contriburl,  :


Installed is tcl-8.6.0-r1 and tk-8.6.0 in a GENTOO environment.




--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] Excuse me

2013-03-21 Thread Kevin E. Thorpe

On 03/21/2013 08:38 AM, John Kane wrote:

If I remember correctly this was possible a few versions ago but was dropped.  
To do it now you need to use write.table and set row.names = FALSE.

John Kane
Kingston ON Canada


I used write.csv with row.names=FALSE yesterday with no issues at all in 
the current version of R.


Kevin





-Original Message-
From: lina...@pku.edu.cn
Sent: Thu, 21 Mar 2013 16:27:18 +0800 (CST)
To: r-help@r-project.org
Subject: [R] Excuse me



Dear R software faculty:

B B B B B B There is a question bothering me. That is why we can not set
the property of row.names=false when we output csv data. But there exists
that parameter in R help. Hoping for your reply!

Best regards!

B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B
B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B Li
Nan




--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] How to get the t-stat for arima()?

2013-03-20 Thread Kevin E. Thorpe

On 03/20/2013 03:49 AM, Prof Brian Ripley wrote:


If things are not readily available in R it is always good to pause and
reflect if there might be a good reason.


I nominate this as a fortune candidate.

--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] On p-values presented in the summary of Linear Models

2013-02-07 Thread Kevin E. Thorpe

On 02/07/2013 08:22 PM, Antonio Silva wrote:

Dear list members

I have a doubt on how p-values for t-statistics are calculated in the
summary of Linear Models.

Here goes an example:

x - rnorm(100,50,10)
y - rnorm(100,0,5)
fit1-lm(y~x)
summary(fit1)
summary(fit1)$coef[2] # b
summary(fit1)$coef[4] # Std. Error
summary(fit1)$coef[6] # t-statistic
summary(fit1)$coef[8] # Pr(|t|
summary(fit1)$df [2] # degrees of freedom

# t-statistic can be calculated as:
t-(summary(fit1)$coef[2])/summary(fit1)$coef[4]
t # t-statistic

# the critical value for t0.05(2)df can be obtained in a t distribuition
table
# http://www.math.unb.ca/~knight/utility/t-table.htm or with
qt(0.975,summary(fit1)$df[2])

# Two-sided p-value should be estimated with
dt(t,summary(fit1)$df[2]) # isn't it?



The dt() function is giving you the value from the density function, not 
the probability.  Use pt() to obtain probabilities.




But this value is different from summary(fit1)$coef[8]

My question is: how to reach to the same p-value indicated in Pr(|t|) or
summary(fit1)$coef[8]?

Thanks in advance,

Antonio Olinto

[[alternative HTML version deleted]]

__
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.





--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] Relative Risk in logistic regression

2013-01-30 Thread Kevin E. Thorpe

On 01/30/2013 09:02 AM, nalluri pratap wrote:

Relative risk = exp(coef(model))



Only if you fit using the log link.  Using the logit link, this gives 
odds ratios.



--- On Wed, 30/1/13, aminreza Aamini amin.r@gmail.com wrote:


From: aminreza Aamini amin.r@gmail.com
Subject: [R] Relative Risk in logistic regression
To: R-help R-help@r-project.org
Date: Wednesday, 30 January, 2013, 4:19 PM


Hi all,
I am very grateful to all those who write to me
1) how i  can  obtain relative risk (risk ratio) in logistic regression in R.
2) how to obtain  the predicted risk for a certain individual using
fitted regression model in R.

Many thanks, in advance, for your help.

Amin.

__
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.

[[alternative HTML version deleted]]



__
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.




--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] Relative Risk in logistic regression

2013-01-30 Thread Kevin E. Thorpe

On 01/30/2013 11:17 AM, John Sorkin wrote:

I am not sure why one would want a relative risk from a logistic
regression. The measure of association from a logistic regression is the
odds ratio, not the relative risk.
John



Yes, the natural measure, when using the logit link, is the OR.  I 
always use that myself, but if you use the log link, you get RR.  As for 
why you would, I would suggest it's because physicians think they 
understand a RR better than and OR.




Kevin E. Thorpe kevin.tho...@utoronto.ca 1/30/2013 11:14 AM 
On 01/30/2013 09:02 AM, nalluri pratap wrote:
  Relative risk = exp(coef(model))
 

Only if you fit using the log link.  Using the logit link, this gives
odds ratios.

  --- On Wed, 30/1/13, aminreza Aamini amin.r@gmail.com wrote:
 
 
  From: aminreza Aamini amin.r@gmail.com
  Subject: [R] Relative Risk in logistic regression
  To: R-help R-help@r-project.org
  Date: Wednesday, 30 January, 2013, 4:19 PM
 
 
  Hi all,
  I am very grateful to all those who write to me
  1) how i  can  obtain relative risk (risk ratio) in logistic
regression in R.
  2) how to obtain  the predicted risk for a certain individual using
  fitted regression model in R.
 
  Many thanks, in advance, for your help.
 
  Amin.
 
  __
  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.
 
  [[alternative HTML version deleted]]
 
 
 
  __
  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.
 





--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] Relative Risk in logistic regression

2013-01-30 Thread Kevin E. Thorpe

On 01/30/2013 11:26 AM, John Sorkin wrote:

If you use a log link, you are not, I believe, performing a logistic
regression!


I guess strictly speaking, that is true.  I was being a little sloppy in 
terminology.




Kevin E. Thorpe kevin.tho...@utoronto.ca 1/30/2013 11:22 AM 
On 01/30/2013 11:17 AM, John Sorkin wrote:
  I am not sure why one would want a relative risk from a logistic
  regression. The measure of association from a logistic regression is the
  odds ratio, not the relative risk.
  John
 

Yes, the natural measure, when using the logit link, is the OR.  I
always use that myself, but if you use the log link, you get RR.  As for
why you would, I would suggest it's because physicians think they
understand a RR better than and OR.


  Kevin E. Thorpe kevin.tho...@utoronto.ca 1/30/2013 11:14 AM 
  On 01/30/2013 09:02 AM, nalluri pratap wrote:
Relative risk = exp(coef(model))
   
 
  Only if you fit using the log link.  Using the logit link, this gives
  odds ratios.
 
--- On Wed, 30/1/13, aminreza Aamini amin.r@gmail.com wrote:
   
   
From: aminreza Aamini amin.r@gmail.com
Subject: [R] Relative Risk in logistic regression
To: R-help R-help@r-project.org
Date: Wednesday, 30 January, 2013, 4:19 PM
   
   
Hi all,
I am very grateful to all those who write to me
1) how i  can  obtain relative risk (risk ratio) in logistic
  regression in R.
2) how to obtain  the predicted risk for a certain individual using
fitted regression model in R.
   
Many thanks, in advance, for your help.
   
Amin.
   
__
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.
   
[[alternative HTML version deleted]]
   
   



--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] how to suppress the intercept in an lm()-like formula method?

2013-01-29 Thread Kevin E. Thorpe
For lm() the intercept can be removed by adding a - 1 to the RHS of 
the formula.  Does that not work in your case?


Kevin

On 01/29/2013 09:14 AM, Michael Friendly wrote:

To partly answer my own question:  It wasn't that hard to hack the
result of model.matrix() to remove the intercept,

remove.intercept - function(x) {
 if (colnames(x)[1] == (Intercept)) {
 x - x[,-1]
 attr(x, assign) - attr(x, assign)[-1]
 }
 x
}

However, the model frame and therefore the model terms stored in the
object are wrong, still including the intercept:

Browse[1] str(mt)
Classes 'terms', 'formula' length 3 cbind(SAT, PPVT, Raven) ~ n + s + ns
+ na + ss
   ..- attr(*, variables)= language list(cbind(SAT, PPVT, Raven), n,
s, ns, na, ss)
   ..- attr(*, factors)= int [1:6, 1:5] 0 1 0 0 0 0 0 0 1 0 ...
   .. ..- attr(*, dimnames)=List of 2
   .. .. ..$ : chr [1:6] cbind(SAT, PPVT, Raven) n s ns ...
   .. .. ..$ : chr [1:5] n s ns na ...
   ..- attr(*, term.labels)= chr [1:5] n s ns na ...
   ..- attr(*, order)= int [1:5] 1 1 1 1 1
   ..- attr(*, intercept)= int 1
   ..- attr(*, response)= int 1
   ..- attr(*, .Environment)=environment: R_GlobalEnv
   ..- attr(*, predvars)= language list(cbind(SAT, PPVT, Raven), n, s,
ns, na, ss)
   ..- attr(*, dataClasses)= Named chr [1:6] nmatrix.3 numeric
numeric numeric ...
   .. ..- attr(*, names)= chr [1:6] cbind(SAT, PPVT, Raven) n s
ns ...
Browse[1]


On 1/29/2013 8:44 AM, Michael Friendly wrote:

I'm trying to write a formula method for canonical correlation analysis,
that could be called similarly to lm() for
a multivariate response:

cancor(cbind(y1,y2,y3) ~ x1+x2+x3+x4, data=, ...)
or perhaps more naturally,
cancor(cbind(y1,y2,y3) ~ cbind(x1,x2,x3,x4), data=, ...)

I've adapted the code from lm() to my case, but in this situation, it
doesn't make sense to
include an intercept, since X  Y are mean centered by default in the
computation.

In the code below, I can't see where the intercept gets included in the
model matrix and therefore
how to suppress it.  There is a test case at the end, showing that the
method fails when called
normally, but works if I explicitly use -1 in the formula.  I could hack
the result of model.matrix(),
but maybe there's an easier way?

cancor - function(x, ...) {
 UseMethod(cancor, x)
}

cancor.default - candisc:::cancor

# TODO: make cancisc::cancor() use x, y, not X, Y
cancor.formula - function(formula, data, subset, weights,
 na.action,
 method = qr,
 model = TRUE,
 x = FALSE, y = FALSE, qr = TRUE,
 contrasts = NULL, ...) {

 cl - match.call()
 mf - match.call(expand.dots = FALSE)
 m - match(c(formula, data, subset, weights, na.action),
names(mf), 0L)
 mf - mf[c(1L, m)]

 mf[[1L]] - as.name(model.frame)
 mf - eval(mf, parent.frame())

 mt - attr(mf, terms)
 y - model.response(mf, numeric)
 w - as.vector(model.weights(mf))
 if (!is.null(w)  !is.numeric(w))
 stop('weights' must be a numeric vector)

 x - model.matrix(mt, mf, contrasts)
 # fixup to remove intercept???
 z - if (is.null(w))
 cancor.default(x, y,  ...)
 else stop(weights are not yet implemented)  # lm.wfit(x, y, w,
...)

 z$call - cl
 z$terms - mt
 z
}

TESTME - FALSE
if (TESTME) {

# need to get latest version, 0.6-1 from R-Forge
install.packages(candisc, repo=http://R-Forge.R-project.org;)
library(candisc)

data(Rohwer)

# this bombs: needs intercept removed
cc - cancor.formula(cbind(SAT, PPVT, Raven) ~  n + s + ns + na + ss,
data=Rohwer)
## Error in chol.default(Rxx) :
##  the leading minor of order 1 is not positive definite

#this works as is
cc - cancor.formula(cbind(SAT, PPVT, Raven) ~  -1 + n + s + ns + na +
ss, data=Rohwer)
cc
## Canonical correlation analysis of:
##   5   X  variables:  n, s, ns, na, ss
##   with3   Y  variables:  SAT, PPVT, Raven
##
## CanR  CanRSQ   Eigen percentcum
## 1 0.6703 0.44934 0.81599   77.30  77.30
## 2 0.3837 0.14719 0.17260   16.35  93.65
## 3 0.2506 0.06282 0.067046.35 100.00
##
## Test of H0: The canonical correlations in the
## current row and all that follow are zero
##
   ...
}








--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] 1-KM and Cumulative incidence

2012-11-12 Thread Kevin E. Thorpe

On 11/12/2012 06:50 AM, cachimo wrote:

Dear

I want to know how to plot 1-KM and Cumulative incidence curves in on
graph.

Thanks



For 1-KM, see the fun argument to plot.survfit.  Do you mean the 
Cumulative incidence curve for competing risks?  If so, see the cmprsk 
package for one approach.


--
Kevin E. Thorpe
Biostatistician/Trialist,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] linux

2012-05-23 Thread Kevin E. Thorpe

On 05/23/2012 05:00 AM, Soheila Khodakarim wrote:

Dear All

I can not download R for Linux.

I do not know which file I should install?

Best Regards,
Soheila



Can you provide the list with additional information such as:

What Linux distribution?
What have you tried?

For what it's worth, I always compile from source on Linux.  To do that,
download the source tarball, unpack it and then run the following in the
directory the tarball unpacked to.  For this to work, you will probably
need the devel libraries installed on your system.

./configure
make
make install

Note that you will usually need to run make install as root, unless
you modify the installation location.

One reason I do this is, that I figure if my system has the tools
to compile R, I likely won't have concerns about installing packages
that require some compilation as well.

Kevin

--
Kevin E. Thorpe
Biostatistician/Trialist,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] Loading the stupid dataset--help!!!

2012-05-19 Thread Kevin E. Thorpe

On 05/19/2012 07:44 AM, SteveQ wrote:

I am using the following:
library(RODBC)
chan = odbcConnectExcel(rats-lda)
rats.lda = sqlFetch(chan, data)
close(chan)

And getting the following error message:

library(RODBC)

Error in library(RODBC) : there is no package called ‘RODBC’


The above error message indicates that the ROBDC package is not
installed.  Have you done an install.packages(ROBDC)?


chan = odbcConnectExcel(rats-lda)

Error: could not find function odbcConnectExcel

rats.lda = sqlFetch(chan, data)

Error: could not find function sqlFetch

close(chan)




I am sure there is a simple answer to this.  Thanks.



--
Kevin E. Thorpe
Biostatistician/Trialist,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] Finding the median

2012-03-12 Thread Kevin E. Thorpe
Also, if it is not homework, why are you reinventing some functionality 
already in R?  R can easily calculate medians for you.


Kevin

On 03/12/2012 12:35 PM, Sarah Goslee wrote:

Did you try what I suggested?

If you go to www.rseek.org and search for odd or even integers you
will get various solutions.

You could even write your own test by comparing x/2 with round(x/2).

Also, it's good form to copy the list on your replies, not just me.

Sarah

On Mon, Mar 12, 2012 at 12:29 PM,elliot.we...@virgin.net  wrote:

I can't find it that thing. And its not a homework task, I work for a company 
who require this function to do analysis on some data but we're all new to R?
--Original Message--
From: Sarah Goslee
To: elliot.we...@virgin.net
To: r-help
Subject: Re: [R] Finding the median
Sent: Mar 12, 2012 16:14

Hi,

On Mon, Mar 12, 2012 at 12:10 PM,elliot.we...@virgin.net  wrote:

I've tried the if function? Its just defining when something is even or odd?


R's help system might be useful. www.rseek.org might be useful.

You haven't accomplished the second part of my response, and this
isn't a homework help list, so you'll need to do your own work from
here.

Sarah


--Original Message--
From: Sarah Goslee
To: elliot.we...@virgin.net
Cc: r-h...@stat.math.ethz.ch
Subject: Re: [R] Finding the median
Sent: Mar 12, 2012 15:59

I'd start by using if().

If you can convince the list that this isn't homework, you might get more help.

Sarah

On Mon, Mar 12, 2012 at 7:15 AM,elliot.we...@virgin.net  wrote:

Hi just a quick question in which I must use the function and return part of 
R.

If I was asked to define a function called median where the function has a 
single argument x and returns the median value of a vector. How would I go about saying 
the median = element x in terms of n (say (n + 1)/2 or whatever it would be) if there is 
an even amount of elements, or x in terms of n (with a different way of saying how many 
n) if there is an odd amount of elements?

Much appreciated






--
Kevin E. Thorpe
Biostatistician/Trialist,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] Multiple Correspondence Analysis

2012-03-09 Thread Kevin E. Thorpe
You should send this to r-h...@stat.math.ethz.ch.

On 03/09/2012 09:21 AM, Andrea Sica wrote:
 Hello everybody, I'm looking for someone who is able with MCA and 
 would like to gives some help.

 If what I'm doing is not wrong, according to the purpose I have, I 
 need to understand how to create a dependence matrix, where I can 
 analyze the
 dependence between all my variables.
 Till now this is what I was able to do:

 /p - length(spain)/ #this is the number of the variables (91)

 /chisquare - matrix(spain, nrow=(p-1), ncol=p)/ #it creates a 
 squared-matrix with all the variables (if I'm not already wrong)

 /for(i in (1:(p-1))){/
 /chisquare[i, (1:(p-1))] - chisq.test(spain[,i], spain[, i+1])$statistic/
 /chisquare[i, p] - chisq.test(spain[,i], spain[, i+1])$p.value/
 /} /#it should have related the p variables to analyze whether in 
 pairs they are dependents, but it seems like it just related two of 
 them and repeated the relations for all the number of columns (since 
 it gives the same values in each cell by row)

 /chisquare/ #all the cells have the same values by row

 Anyway, I think is also the way I'm proceeding which is wrong, since I 
 want to relate all the variables in pairs thus to be able to calculate 
 the dependence between all of them. That's why I am going for a 
 dependence matrix. Where am I wrong?


 After that I can proceed with the MCA. Of course, I would also
 need help there.

 I used the following codes to do it:

 /spain.mca - mjca(spain) /#it makes the mca for all the data
 /spain.mca/
 /plot(spain.mca)/ #it shows the plot

 But the plot was overcrowded. Anyway, I must first complete the first 
 step, this was just to make some practice on it.

 As you can see, until now I didn't succeed.

 I hope someone will be so gentle to give it a try. Attached you are 
 the data-set
 Thank you

 Best


-- 
Kevin E. Thorpe
Biostatistician/Trialist,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016


[[alternative HTML version deleted]]

__
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] R help

2012-01-18 Thread Kevin E. Thorpe

On 01/18/2012 06:53 AM, Catarina Maia wrote:

hello!

A few days ago I subscribed the R mailing list in order to ask for some
help. The thing is that now I am receiving a lot of mails with doubts from
other users but i am just a R begginer and i will not able to give useful
help.  So,  i would like to quit the from the mainling list. I'm so sorry for
the inconvenience.

best regards,

Catarina Maia


An alternative to unsubscribing is to disable mail delivery.  This is 
done by signing on to your account (you should have received a 
confirmation email at some point with the link and password you 
created).  There you will find a check box to disable delivery.


The advantage of this approach is you don't need to re-subscribe later 
if you have another question.


As others have said, you can learn many things by reading some of the 
posts.  If volume is too high, you could create filters for you inbox 
that automatically moves them to another folder for reading.  That's 
what I do and it makes managing the volume trivial.




__
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.




--
Kevin E. Thorpe
Biostatistician/Trialist,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] net classification improvement?

2012-01-17 Thread Kevin E. Thorpe

On 01/17/2012 07:16 AM, Essers, Jonah wrote:

Thanks for the reply. I think more the issue is whether it can be applied
to cross-sectional data. This I'm not sure. This method is heavily cited
in the New England Journal of Medicine, but thus far I've only seen it
used with longitudinal data.


As I recall, the Pencina et al paper does not suggest it cannot be used 
outside of longitudinal data.  In fact, I don't remember them using 
longitudinal data at all.  So, unless I'm misunderstanding your 
question, I think the function in Hmisc (whose name I always forget) 
should be fine.




On 1/16/12 10:23 PM, Kevin E. Thorpekevin.tho...@utoronto.ca  wrote:


On 01/16/2012 08:10 PM, Essers, Jonah wrote:

Greetings,

I have generated several ROC curves and would like to compare the AUCs.
The data are cross sectional and the outcomes are binary. I am testing
which of several models provide the best discrimination. Would it be
most
appropriate to report AUC with 95% CI's?

I have been looking in to the net reclassification improvement (see
below for reference) but thus far I can only find a version in Hmisc
package which requires survival data. Any idea what the best approach is
for cross-sectional data?


I believe that the function in Hmisc that does this will also work on
binary data.



Thanks

Pencina MJ, D'Agostino RB Sr, D'Agostino RB Jr, Vasan RS. Evaluating the
added predictive ability of a new marker: from area under the ROC curve
to
reclassification and beyond. Stat Med 2008;27:157-172






--
Kevin E. Thorpe
Biostatistician/Trialist,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] net classification improvement?

2012-01-17 Thread Kevin E. Thorpe

On 01/17/2012 11:55 AM, Essers, Jonah wrote:

Actually, I don't think I made myself clear and I wrote this late last
nightSorry. More the issue is that the raw model predictions (from 0
to 1) have no inherent clinical value to them. I.e. They aren't risk of
disease or risk of outcome. They are raw scores that are specific to
each model and are meant to discriminate one disease from another disease.
Trying to compare models is impossible because the NRI requires cutoff
values.  The cutoffs are different for each model.

So, as I've done more reading, it appears the the IRI--Integrated
Discrimination Improvement Index--which is naïve to cutoff values--may be
more what I'm looking for. Does this make sense? I guess I just need a
sanity check.


Yes, the IRI makes sense to me.



I have been toying with the PredictABEL package and this seems to like my
data inputs just fine and relies on HMISC and ROCR, both packages I know
well.

Thanks
jonah

On 1/17/12 11:49 AM, Kevin E. Thorpekevin.tho...@utoronto.ca  wrote:


On 01/17/2012 07:16 AM, Essers, Jonah wrote:

Thanks for the reply. I think more the issue is whether it can be
applied
to cross-sectional data. This I'm not sure. This method is heavily cited
in the New England Journal of Medicine, but thus far I've only seen it
used with longitudinal data.


As I recall, the Pencina et al paper does not suggest it cannot be used
outside of longitudinal data.  In fact, I don't remember them using
longitudinal data at all.  So, unless I'm misunderstanding your
question, I think the function in Hmisc (whose name I always forget)
should be fine.



On 1/16/12 10:23 PM, Kevin E. Thorpekevin.tho...@utoronto.ca   wrote:


On 01/16/2012 08:10 PM, Essers, Jonah wrote:

Greetings,

I have generated several ROC curves and would like to compare the
AUCs.
The data are cross sectional and the outcomes are binary. I am testing
which of several models provide the best discrimination. Would it be
most
appropriate to report AUC with 95% CI's?

I have been looking in to the net reclassification improvement (see
below for reference) but thus far I can only find a version in Hmisc
package which requires survival data. Any idea what the best approach
is
for cross-sectional data?


I believe that the function in Hmisc that does this will also work on
binary data.



Thanks

Pencina MJ, D'Agostino RB Sr, D'Agostino RB Jr, Vasan RS. Evaluating
the
added predictive ability of a new marker: from area under the ROC
curve
to
reclassification and beyond. Stat Med 2008;27:157-172








--
Kevin E. Thorpe
Biostatistician/Trialist,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] net classification improvement?

2012-01-16 Thread Kevin E. Thorpe

On 01/16/2012 08:10 PM, Essers, Jonah wrote:

Greetings,

I have generated several ROC curves and would like to compare the AUCs.
The data are cross sectional and the outcomes are binary. I am testing
which of several models provide the best discrimination. Would it be most
appropriate to report AUC with 95% CI's?

I have been looking in to the net reclassification improvement (see
below for reference) but thus far I can only find a version in Hmisc
package which requires survival data. Any idea what the best approach is
for cross-sectional data?


I believe that the function in Hmisc that does this will also work on 
binary data.




Thanks

Pencina MJ, D'Agostino RB Sr, D'Agostino RB Jr, Vasan RS. Evaluating the
added predictive ability of a new marker: from area under the ROC curve to
reclassification and beyond. Stat Med 2008;27:157-172




--
Kevin E. Thorpe
Biostatistician/Trialist,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] mgcv 1.7-12 crashes R

2011-12-16 Thread Kevin E. Thorpe

On 12/16/2011 08:52 AM, Reinhard Seifert wrote:

Dear community,

I encountered a very disturbing phenomenon today:

When I try to fit any gam() with mgcv R aborts. I could not find any post
regarding this in google, which mades in even more strange.

I am using the latest Ubuntu, latest R and latest mgcv everything up to
date. The crash occured too with the last mgcv 1.7-11.

This is the output from the R shell:

pre

R version 2.14.0 (2011-10-31)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-pc-linux-gnu (64-bit)


library(mgcv)

This is mgcv 1.7-12. For overview type 'help(mgcv-package)'.

dat- gamSim(1 , n=400 , dist=normal,scale = 2)

Gu  Wahba 4 term additive model

gam( y ~ s(x0) , data = dat)

Aborted

/pre

I am using Ubuntu 11.10 - amd64, R version 2.14.0 and mgcv 1.7-12.

any ideas?

Reinhard


It works for me in Slackware 13.37 (64bit)

 library(mgcv)
This is mgcv 1.7-11. For overview type 'help(mgcv-package)'.
 dat - gamSim(1 , n=400 , dist=normal,scale = 2)
Gu  Wahba 4 term additive model
 gam( y ~ s(x0) , data = dat)

Family: gaussian
Link function: identity

Formula:
y ~ s(x0)

Estimated degrees of freedom:
2.4812  total = 3.481196

GCV score: 13.66653

 sessionInfo()
R version 2.14.0 Patched (2011-11-29 r57769)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US   LC_NUMERIC=C LC_TIME=en_US
 [4] LC_COLLATE=C LC_MONETARY=en_USLC_MESSAGES=en_US
 [7] LC_PAPER=C   LC_NAME=CLC_ADDRESS=C
[10] LC_TELEPHONE=C   LC_MEASUREMENT=en_US LC_IDENTIFICATION=C

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

other attached packages:
[1] mgcv_1.7-11

loaded via a namespace (and not attached):
[1] Matrix_1.0-2   grid_2.14.0lattice_0.20-0 nlme_3.1-102




--
Kevin E. Thorpe
Biostatistician/Trialist,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] Weird Excel Time Format

2011-11-29 Thread Kevin E. Thorpe

On 11/29/2011 01:39 PM, Hasan Diwan wrote:

On 29 November 2011 10:26, Jeff Newmillerjdnew...@dcn.davis.ca.us  wrote:


For my part, I highly recommend exporting to CSV before importing to R.


Will look into doing so...


I don't think this point can be stressed enough.  I have had too many 
bad experiences with dates in excel, especially when multiple computers 
are involved.  When someone has data in excel, I now require them to 
make the csv file on their system and manually verify the dates but 
opening the file in notepad.


--
Kevin E. Thorpe
Biostatistician/Trialist,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] avoiding the sample in built function

2011-11-23 Thread Kevin E. Thorpe

On 11/23/2011 02:01 PM, sarah44 wrote:

Dear all,

I am currently working on a function in which I would like to avoid using
the command sample().

Therefore, I am now trying to make a for loop that does the same thing as
the in built function sample
does: Rearranging the items of a object randomly.

So, the output I want to you get is the same as sample() would give me:

e.g.:
data- c(5,4,6,7,8)
sample(data)


data- c(5,4,6,7,8)
sample(data)

[1] 4 6 7 8 5

sample(data)

[1] 6 8 4 7 5

sample(data)

[1] 6 5 4 8 7

Herefore I made a for loop which you can see here:
This for loop is supposed to do the same as the sample() function, 3 times.

data- c(5,4,6,7,8)
numsim- 3
n- length(data)
sample- matrix(0,numsim,1)


for (i in 1:numsim) {indices- runif(pool, min = 1, max = n)
   sample[i,]- data[indices]
   }

the idea behind this for loop is dat it first creates randomly data by
runif, and then it should
somehow, by using indeces, store this 3 times in a matrix 'sample'.
Somehow, I am stuck here and I think that the sample[,i] part is just very
wrong. I am however
not for a very long time an R user, so I cannot find the solution to this
problem.

Can someone give me a hint?

Thanks very much!

Bye, sarah



The only reason I can think of you wanting to avoid sample() is because 
this is homework and the list is not for homework.  If I have misjudged 
the intent of your post, please forgive me.


--
Kevin E. Thorpe
Biostatistician/Trialist,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] oversampling code

2011-11-01 Thread Kevin E. Thorpe

On 11/01/2011 12:32 PM, loubna181 wrote:

Hi,
Thanks all for your responses, but as I m a new user of R while trying to
apply what David suggests I dont know what *dorm *refers to.

dfrm[c(rownames(dfrm[*dorm*$Y==1,]), sample(rownames(dfrm[dfrm$Y==0]),
0.10)) , ]


I suspect that dorm was a typo and that dfrm is what was meant.



But to give you more details , I'm working on a table calles balance from
UCI machine learning
I do have a variable called class and takes 3 values : B, L and R.
B represents 8% of the total and L and R 46% each one.
The purpose is to have a data set with 10% of B, 40% of L and 40% of R.
Thank u

--
View this message in context: 
http://r.789695.n4.nabble.com/oversampling-code-tp3956664p3964240.html
Sent from the R help mailing list archive at Nabble.com.

__
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.




--
Kevin E. Thorpe
Biostatistician/Trialist,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] SPlus to R

2011-10-05 Thread Kevin E. Thorpe

On 10/05/2011 07:44 AM, Scott Raynaud wrote:

Hope I did this right.  I repeated what I'd done before:

1) Opened script 2) Selected run all (this produced my inital post

Then as suggested I:

3) Typed ls() 4) Saw that the function was present and issued
sshc(100,10)

Here's what I got:


ls()

[1] c.searchd convexEpowernef   nef2
power1.f [7] ss.rand   sshc  vertex

sshc(100,10)

Error in return(ne = ne, Ep = Ep1) : multi-argument returns are not
permitted

So it looks like I need to change the return(ne = ne, Ep = Ep1) to
two separate lines, correct?


As another poster suggested, use list(ne = ne, Ep = Ep1) instead of the 
the present return().



On a brighter note, I did get a power curve as expected.  One thing I
don't understand is the meaning of the arguments in sshc(100,10).

Thanks agian for your help.


 From: Barry
Rowlingsonb.rowling...@lancaster.ac.uk

Cc: r-help@r-project.orgr-help@r-project.org Sent: Wednesday,
October 5, 2011 4:02 AM Subject: Re: [R] SPlus to R


te:

I'm trying to convert an S-Plus program to R.  Since I'm a SAS
programmer I'm not facile is either S-Plus or R, so I need some
help.  All I did was convert the underscores in S-Plus to the
assignment operator-.  Here are the first few lines of the S-Plus
file:

sshc _ function(rc, nc, d, method, alpha=0.05, power=0.8, tol=0.01,
tol1=.0001, tol2=.005, cc=c(.1,2), l.span=.5) { ### for method 1 if
(method==1) { ne1 _ ss.rand(rc,nc,d,alpha=.05,power=.8,tol=.01)
return(ne=ne1) }


My translation looks like this:

sshc-function(rc, nc=500, d=.5, method=3, alpha=0.05, power=0.8,
tol=0.01, tol1=.0001, tol2=.005, cc=c(.1,2), l.span=.5) { ### for
method 1 if (method==1) {
ne1-ss.rand(rc,nc,d,alpha=.05,power=.8,tol=.01) return(ne=ne1) }

The program runs without throwing errors, but I'm not getting any
ourput in the console.  This is where it should be, right?  I think
I have this set up correctly.  I'm using method=3 which only
requires nc and d to be specified.  Any ideas why I'm not seeing
output?


Long shot: the code you posted looked like (and hard to tell without
indentation) just a bunch of function definitions. R won't actually
do anything unless you call those functions with some parameters.

So, when you say you get no output when you 'run' the code, what
exactly do you mean by 'run' the code? What I would do is:

1. Put the code in a file called 'whatever.R'. 2. Start R, and do
source(whatever.R). That defines the functions. do ls() and you
should see them. 3. Call one of the functions: sshc(100,10)

I'd call that, in R terms, calling the sshc function rather than
running anything.

Barry



--
Kevin E. Thorpe
Biostatistician/Trialist,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] Meta-analysis of test statistics in metafor package?

2011-10-03 Thread Kevin E. Thorpe

On 10/03/2011 01:07 PM, davidyeager wrote:

Hi -

I am conducting a meta-analysis and I have a matrix of f-statistics, Ns and
dfs from a series of studies that tested for an interaction in a 2x2 anova.
I'd like to test whether the 2x2 interaction is significant in the
aggregate.

Similarly, I have a matrix of chi-square statistics that I'd like to
meta-analyze.

How can I input these test statistics into the metafor package and conduct
these meta-analyses?  I see how to input raw data or standardizes effect
sizes (e.g., d) into metafor, but not test statistics.

Best,

David



I believe the MAd package may have what you are looking for.  It can 
call metafor for you.


Kevin

--
Kevin E. Thorpe
Biostatistician/Trialist,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] X11 problem

2011-08-25 Thread Kevin E. Thorpe

On 08/25/2011 08:27 AM, carol white wrote:

Hello,
TO update R under Ubuntu on my macchine, I downloaded R-2.13.1. When running 
./configure, I got the following error message:

checking for X... no
configure: error: --with-x=yes (default) and X11 headers/libs are not available



But I could use X11() function in R-2-10. So where does the problem come from?

Cheers,

Carol



It looks like you're compiling from source and your system does not have 
the header files required installed.  Did you compile your previous 
version or use a pre-built (binary) package?  A binary package would not 
require the headers.


I don't use Ubuntu, so I don't know what the name of packages you need 
for the headers.  Typically the packages have the devel versions 
separate, you you need those.


--
Kevin E. Thorpe
Biostatistician/Trialist,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] X11 problem

2011-08-25 Thread Kevin E. Thorpe

On 08/25/2011 08:49 AM, carol white wrote:

Thanks for your reply. I used the following commands:
sudo apt-get update
sudo apt-get install r-base



Is that how you installed R-2-10 or how you tried to install 2.13.1?


- Original Message -
From: Kevin E. Thorpekevin.tho...@utoronto.ca
To: carol whitewht_...@yahoo.com
Cc: r-h...@stat.math.ethz.chr-h...@stat.math.ethz.ch
Sent: Thursday, August 25, 2011 2:34 PM
Subject: Re: [R] X11 problem

On 08/25/2011 08:27 AM, carol white wrote:

Hello,
TO update R under Ubuntu on my macchine, I downloaded R-2.13.1. When running 
./configure, I got the following error message:

checking for X... no
configure: error: --with-x=yes (default) and X11 headers/libs are not available



But I could use X11() function in R-2-10. So where does the problem come from?

Cheers,

Carol



It looks like you're compiling from source and your system does not have
the header files required installed.  Did you compile your previous
version or use a pre-built (binary) package?  A binary package would not
require the headers.

I don't use Ubuntu, so I don't know what the name of packages you need
for the headers.  Typically the packages have the devel versions
separate, you you need those.




--
Kevin E. Thorpe
Biostatistician/Trialist,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] assign using =

2011-06-27 Thread Kevin E. Thorpe

On 06/27/2011 10:34 AM, Berry Boessenkool wrote:



Hey all,

I learned that using the equals sign = to assign objects is generally OK, but 
will not work in some cases.
As I always use - for assignments, I have not encoutered any problems.

Could somebody provide an example or explanation, why getting used to = is 
not a good idea?
Or is it?

Thanks ahead,

Berry



As a top-level expression, it probably doesn't matter too much.  I 
always use - myself.  Here is an example where = does not equal -


print(fit - lm(...)) is very different from print(fit = lm(...)).


--
Kevin E. Thorpe
Biostatistician/Trialist,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] Merge matrix

2011-04-12 Thread Kevin E. Thorpe

On 04/12/2011 10:54 AM, pankaj borah wrote:

I have two matrices A and B


dim (A)

[1] 30380   104


dim(Bt)


[1] 3038063

I want to  combine both A and B to matrix C where

dim(C)

[1] 30380   167

How do I do that ?



Assuming that Bt is the transpose of B and you want C = [A|Bt] you could do:

C - cbind(A,t(B))



Regards,

Pankaj Barah
Department of Biology,
Norwegian University of Science  Technology (NTNU)
Realfagbygget, N-7491

[[alternative HTML version deleted]]




__
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.



--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] Sweave with pdf(): how to remove mention null device

2011-01-27 Thread Kevin E. Thorpe
Hi there.

Out of curiosity, why are you doing it that way instead of this:

fig=TRUE,echo=FALSE=
plot(runif(100))
@

Kevin

On January 27, 2011 05:30:08 am Matthieu Stigler wrote:
 great, solved! Thanks a lot for your quick help!

 Le 27. 01. 11 11:22, Prof Brian Ripley a écrit :
  Note that the 'problem' is with dev.off(), not pdf(), and the answer
  is ?invisible.
 
  pdf()
  invisible(dev.off())
 
  On Thu, 27 Jan 2011, Matthieu Stigler wrote:
  Hi
 
  I am sorry, my question seems simple and must already have been
  asked, but I did not find any aswser on the archives :-(
 
  Searching for the irrelevant 'pdf()' will not have helped, I fear ...
 
  I am trying to use a plot in Sweave, where I include myself the
  statement
  results=tex,echo=FALSE=
  pdf(plot.pdf)
  plot(runif(100))
  dev.off()
  cat(\\includegraphics{plot}\n\n)
 
  @
 
  as is documented in the Sweave user guide A.9. The problem is that a
  null device 0 is printed in my document! Indeed, each time one
  opens pdf() or any device, some mention pdf inevitably shows up...
  try:
 
  pdf()
  plot(runif())
  dev.off()
 
  How can one get rid of this? The only workaround I found is to place
  it into a if() loop:
 
  for(i in 1:1){
  pdf()
  plot(runif())
  dev.off()
  }
 
  so there is no track of the mention null device, and my sweave pdf
  looks better. Any idea of a more elegant solution?
 
  Thanks!!
 


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] (OT) Change of email address

2010-09-29 Thread Kevin E. Thorpe

Ted is well aware of how to change his list email.  He was advising
people on the list who who have his old email address in their address
books to remove it.

On 09/29/2010 12:16 PM, Vojtěch Zeisek wrote:

Hello,
go to https://stat.ethz.ch/mailman/options/r-help/y...@email and if You do not
remember Your password, use Password reminder (down) to mail it to Your
address. Then login and do all needed changes. You can replace r-hep in link
above with r-sig-phylo, r-announce and so on. And of course replace y...@email
above with probable ted.hard...@wlandres.net.
Have a nice day!
Vojtěch

Dne St 29. září 2010 10:58:22 ted.hard...@wlandres.net napsal(a):

Apologies for bothering anyone who may not be interested in
this, but some of you will, for instance, have my current
email address in your address books, etc.

As  result of a new policy by Manchester University, retired
former staff who no longer contribute actively to research
in their former departments are to have their email accounts
closed.

The address from which I have been mailing to R-help (etc.):
   ted.hard...@manchester.ac.uk
will therefore soon be closed down.

I have set up (and subscribed to R-help, R-devel, R-announce)
a new email address:

   ted.hard...@wlandres.net

If you have kept a record of my current (manchester.ac.uk)
address, please modify this to the new address.

Messages sent to the current address will continue to arrive,
for another week or two.

With thanks, and best wishes to all,
Ted.




--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] reshape is re-ordering my variables

2010-09-22 Thread Kevin E. Thorpe

On 09/21/2010 09:44 PM, Dennis Murphy wrote:

Hi:

Reshaping multiple variables is nontrivial.  Try the following (untested):

reshape(rcw, idvar = 'ICU', varying = list(c(paste('Q6.RC', 1:4, sep = '.'),
c(paste('Q6.FT.RC', 1:4, 'years', sep =
'.'),
   c(paste('Q6.FT.RC', 1:4, 'months', sep =
'.'),
c(paste('Q6.PT.RC', 1:4, 'years', sep =
'.'),
   c(paste('Q6.PT.RC', 1:4, 'months', sep =
'.')),
  v.names = c(init,FTy,FTm,PTy,PTm), direction =
'long')



Thanks.  Your approach worked although there were unnecessary 'c(' in
varying component.  The command that seems to have worked for me is:

rcl - reshape(rcw, idvar = 'ICU',
   varying = list(paste('Q6.RC', 1:4, sep = '.'),
 paste('Q6.FT.RC', 1:4, 'years', sep = '.'),
 paste('Q6.FT.RC', 1:4, 'months', sep = '.'),
 paste('Q6.PT.RC', 1:4, 'years', sep = '.'),
 paste('Q6.PT.RC', 1:4, 'months', sep = '.')),
   v.names = c(init,FTy,FTm,PTy,PTm),
   direction = 'long')

So, thanks again for pointing me in the right direction here.

Kevin


The list contains the subgroups of the variables you want combined and
v.names, as you appear to know, provides new names for the reshaped
columns. My template example also has a times variable, but it may not
be necessary in your case.

HTH,
Dennis

On Tue, Sep 21, 2010 at 12:01 PM, Kevin E. Thorpe
kevin.tho...@utoronto.ca mailto:kevin.tho...@utoronto.ca wrote:

Is it an undocumented (at least I missed it if it's documented) feature
of the reshape function to do numeric variables followed by character?
I ask because that seems to be the case below.

  str(rcw)
'data.frame':   23 obs. of  21 variables:
  $ ICU  : int  1 18 17 9 22 19 6 16 25 26 ...
  $ Q6.RC.1  : chr SM JF IW MS ...
  $ Q6.FT.RC.1.years : int  0 8 12 3 9 1 5 16 5 5 ...
  $ Q6.FT.RC.1.months: int  0 0 0 0 0 0 0 6 0 0 ...
  $ Q6.PT.RC.1.years : int  2 0 0 1 2 0 0 0 0 0 ...
  $ Q6.PT.RC.1.months: int  0 0 0 0 0 0 0 0 0 0 ...
  $ Q6.RC.2  : chr BA ML TM YL ...
  $ Q6.FT.RC.2.years : int  0 0 7 3 0 9 0 0 0 0 ...
  $ Q6.FT.RC.2.months: int  0 0 0 0 0 9 0 0 0 0 ...
  $ Q6.PT.RC.2.years : int  2 10 2 0 0 9 0 5 0 0 ...
  $ Q6.PT.RC.2.months: int  0 0 0 0 8 9 1 0 6 6 ...
  $ Q6.RC.3  : chr LL TM 9 9 ...
  $ Q6.FT.RC.3.years : int  6 0 9 9 9 9 0 9 0 0 ...
  $ Q6.FT.RC.3.months: int  0 0 9 9 9 9 0 9 0 0 ...
  $ Q6.PT.RC.3.years : int  0 8 9 9 9 9 0 9 0 0 ...
  $ Q6.PT.RC.3.months: int  0 0 9 9 9 9 1 9 4 4 ...
  $ Q6.RC.4  : chr 9 IW 9 9 ...
  $ Q6.FT.RC.4.years : int  9 0 9 9 9 9 9
9 9 9 ...
  $ Q6.FT.RC.4.months: int  9 0 9 9 9 9 9
9 9 9 ...
  $ Q6.PT.RC.4.years : int  9 12 9 9 9 9 9
9 9 9 ...
  $ Q6.PT.RC.4.months: int  9 0 9 9 9 9 9
9 9 9 ...

This data frame needs to be converted to long format with 5
variables repeating over 4 observations.

  rcl -

reshape(rcw,idvar=ICU,varying=2:21,direction=long,v.names=c(init,FTy,FTm,PTy,PTm))

  str(rcl)
'data.frame':   92 obs. of  7 variables:
  $ ICU : int  1 18 17 9 22 19 6 16 25 26 ...
  $ time: int  1 1 1 1 1 1 1 1 1 1 ...
  $ init: int  0 0 0 0 0 0 0 6 0 0 ...
  $ FTy : int  0 8 12 3 9 1 5 16 5 5 ...
  $ FTm : int  0 0 0 0 0 0 0 0 0 0 ...
  $ PTy : int  2 0 0 1 2 0 0 0 0 0 ...
  $ PTm : chr SM JF IW MS ...
  - attr(*, reshapeLong)=List of 4
  ..$ varying:List of 5
  .. ..$ FTm : chr Q6.FT.RC.1.months Q6.FT.RC.2.months
Q6.FT.RC.3.months Q6.FT.RC.4.months
  .. ..$ FTy : chr Q6.FT.RC.1.years Q6.FT.RC.2.years
Q6.FT.RC.3.years Q6.FT.RC.4.years
  .. ..$ PTm : chr Q6.PT.RC.1.months Q6.PT.RC.2.months
Q6.PT.RC.3.months Q6.PT.RC.4.months
  .. ..$ PTy : chr Q6.PT.RC.1.years Q6.PT.RC.2.years
Q6.PT.RC.3.years Q6.PT.RC.4.years
  .. ..$ init: chr Q6.RC.1 Q6.RC.2 Q6.RC.3 Q6.RC.4
  .. ..- attr(*, v.names)= chr init FTy FTm PTy ...
  .. ..- attr(*, times)= int  1 2 3 4
  ..$ v.names: chr init FTy FTm PTy ...
  ..$ idvar  : chr ICU
  ..$ timevar: chr time

In the result, the values in the first of the varying variables goes
into the last variable while the other values are shifted left.  The
attributes in the result are correct, but the contents of rcl$PTm are
what I expected in rcl$init.

  sessionInfo()
R version 2.11.1 Patched (2010-07-21 r52598)
Platform: i686-pc-linux-gnu (32-bit)

locale:
  [1] LC_CTYPE=en_US   LC_NUMERIC=C

[R] reshape is re-ordering my variables

2010-09-21 Thread Kevin E. Thorpe

Is it an undocumented (at least I missed it if it's documented) feature
of the reshape function to do numeric variables followed by character?
I ask because that seems to be the case below.

 str(rcw)
'data.frame':   23 obs. of  21 variables:
 $ ICU  : int  1 18 17 9 22 19 6 16 25 26 ...
 $ Q6.RC.1  : chr  SM JF IW MS ...
 $ Q6.FT.RC.1.years : int  0 8 12 3 9 1 5 16 5 5 ...
 $ Q6.FT.RC.1.months: int  0 0 0 0 0 0 0 6 0 0 ...
 $ Q6.PT.RC.1.years : int  2 0 0 1 2 0 0 0 0 0 ...
 $ Q6.PT.RC.1.months: int  0 0 0 0 0 0 0 0 0 0 ...
 $ Q6.RC.2  : chr  BA ML TM YL ...
 $ Q6.FT.RC.2.years : int  0 0 7 3 0 9 0 0 0 0 ...
 $ Q6.FT.RC.2.months: int  0 0 0 0 0 9 0 0 0 0 ...
 $ Q6.PT.RC.2.years : int  2 10 2 0 0 9 0 5 0 0 ...
 $ Q6.PT.RC.2.months: int  0 0 0 0 8 9 1 0 6 6 ...
 $ Q6.RC.3  : chr  LL TM 9 9 ...
 $ Q6.FT.RC.3.years : int  6 0 9 9 9 9 0 9 0 0 ...
 $ Q6.FT.RC.3.months: int  0 0 9 9 9 9 0 9 0 0 ...
 $ Q6.PT.RC.3.years : int  0 8 9 9 9 9 0 9 0 0 ...
 $ Q6.PT.RC.3.months: int  0 0 9 9 9 9 1 9 4 4 ...
 $ Q6.RC.4  : chr  9 IW 9 9 ...
 $ Q6.FT.RC.4.years : int  9 0 9 9 9 9 9 9 
9 9 ...
 $ Q6.FT.RC.4.months: int  9 0 9 9 9 9 9 9 
9 9 ...
 $ Q6.PT.RC.4.years : int  9 12 9 9 9 9 9 9 
9 9 ...
 $ Q6.PT.RC.4.months: int  9 0 9 9 9 9 9 9 
9 9 ...


This data frame needs to be converted to long format with 5 variables 
repeating over 4 observations.


 rcl - 
reshape(rcw,idvar=ICU,varying=2:21,direction=long,v.names=c(init,FTy,FTm,PTy,PTm))


 str(rcl)
'data.frame':   92 obs. of  7 variables:
 $ ICU : int  1 18 17 9 22 19 6 16 25 26 ...
 $ time: int  1 1 1 1 1 1 1 1 1 1 ...
 $ init: int  0 0 0 0 0 0 0 6 0 0 ...
 $ FTy : int  0 8 12 3 9 1 5 16 5 5 ...
 $ FTm : int  0 0 0 0 0 0 0 0 0 0 ...
 $ PTy : int  2 0 0 1 2 0 0 0 0 0 ...
 $ PTm : chr  SM JF IW MS ...
 - attr(*, reshapeLong)=List of 4
  ..$ varying:List of 5
  .. ..$ FTm : chr  Q6.FT.RC.1.months Q6.FT.RC.2.months 
Q6.FT.RC.3.months Q6.FT.RC.4.months
  .. ..$ FTy : chr  Q6.FT.RC.1.years Q6.FT.RC.2.years 
Q6.FT.RC.3.years Q6.FT.RC.4.years
  .. ..$ PTm : chr  Q6.PT.RC.1.months Q6.PT.RC.2.months 
Q6.PT.RC.3.months Q6.PT.RC.4.months
  .. ..$ PTy : chr  Q6.PT.RC.1.years Q6.PT.RC.2.years 
Q6.PT.RC.3.years Q6.PT.RC.4.years

  .. ..$ init: chr  Q6.RC.1 Q6.RC.2 Q6.RC.3 Q6.RC.4
  .. ..- attr(*, v.names)= chr  init FTy FTm PTy ...
  .. ..- attr(*, times)= int  1 2 3 4
  ..$ v.names: chr  init FTy FTm PTy ...
  ..$ idvar  : chr ICU
  ..$ timevar: chr time

In the result, the values in the first of the varying variables goes
into the last variable while the other values are shifted left.  The
attributes in the result are correct, but the contents of rcl$PTm are
what I expected in rcl$init.

 sessionInfo()
R version 2.11.1 Patched (2010-07-21 r52598)
Platform: i686-pc-linux-gnu (32-bit)

locale:
 [1] LC_CTYPE=en_US   LC_NUMERIC=C LC_TIME=en_US
 [4] LC_COLLATE=C LC_MONETARY=CLC_MESSAGES=en_US
 [7] LC_PAPER=en_US   LC_NAME=CLC_ADDRESS=C
[10] LC_TELEPHONE=C   LC_MEASUREMENT=en_US LC_IDENTIFICATION=C

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

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

--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] survfit question

2010-09-09 Thread Kevin E. Thorpe

On 09/09/2010 08:50 PM, andre bedon wrote:


Hi,



I am attempting to graph a Kaplan Meier estimate for some claims
using the survfit function. However, I was wondering if it is
possible to plot a cdf of the kaplan meier rather than the survival
function. Here is some of my code:



Do you really want a CDF or just plot 1-KM.  If you want to plot 1-KM, 
just fit your survival model as usual and plot() it with the plot 
argument fun=event.




library(survival) Surv(claimj,censorj==0)
survfit(Surv(claimj,censorj==0)~1)
surv.all-survfit(Surv(claimj,censorj==0)~1) summary(surv.all)
plot(surv.all) I would really appreciate any assistance. Thank you.



Regards,



Andre



--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] ESS question. How to get rid of ess-smart-underscore?

2010-08-09 Thread Kevin E. Thorpe

W Eryk Wolski wrote:

Hi,

ESS replaces _ by -. How can I switch off this feature?

 I need to be able to type the underscore

Thanks
Eryk



Pressing the underscore a second time gives you the underscore.

--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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 installation lme4a,

2010-08-05 Thread Kevin E. Thorpe

rod84 wrote:
Dear R users, 
I recently downloaded the library lme4a by 
svn checkout svn://svn.r-forge.r-project.org/svnroot/lme4. 
I tried to install the library lme4a by copying the downloaded document in
the location where all the R libraries are saved. 
When I try to load the library, I obtain the message 

library(lme4a) 
Error in library(lme4a) : 'lme4a' is not a valid installed package 


R version 2.11.1 (2010-05-31)
Any Ideas on what I should do to be able to use the functions profile and
env ?
Thank you


You probably need to build the package after you download it.  At least 
I had to.


Kevin

--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] Sweave: The opposite of tangle

2010-06-25 Thread Kevin E. Thorpe

stefan.d...@gmail.com wrote:

Hi,
I am using Sweave to write an article. If I want to convert the *.rnw
to a *.tex file I have to run Sweave which might take a long time. Is
there away to get a tex-file as result without (evaluating) the
R-chunks, i.e. the opposite of tangle (that just gives R-chunk).
Thanks,
Stefan



This is untested, but does Sweave(file.rnw, eval=FASLE) do what you want?

--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] Sweave: The opposite of tangle

2010-06-25 Thread Kevin E. Thorpe

Kevin E. Thorpe wrote:

stefan.d...@gmail.com wrote:

Hi,
I am using Sweave to write an article. If I want to convert the *.rnw
to a *.tex file I have to run Sweave which might take a long time. Is
there away to get a tex-file as result without (evaluating) the
R-chunks, i.e. the opposite of tangle (that just gives R-chunk).
Thanks,
Stefan



This is untested, but does Sweave(file.rnw, eval=FASLE) do what you want?



That should be FALSE above.  Don't post before coffee.
h

--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] Latex and r

2010-06-16 Thread Kevin E. Thorpe

moleps wrote:
Dear R´ers 


I´m trying to get a summary table  using latex and summary in the rms package 
to no avail. I´m running R 2.10.1, Mac OS X snow leopard and I have the mactex 
2009 distribution installed. Any obvious things I´m missing?

//M

 


options(digits=3)
set.seed(173)
sex - factor(sample(c(m,f), 500, rep=TRUE))
age - rnorm(500, 50, 5)
treatment - factor(sample(c(Drug,Placebo), 500, rep=TRUE))
f - summary(treatment ~ age + sex + Symptoms, method=reverse, test=TRUE)

latex(f)

results in the following:


This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009)
entering extended mode

(/var/folders/q9/q9COp2FREsikCyHB7w+OxE+++TI/-Tmp-//RtmpVIk0iB/file587f83cb.tex
LaTeX2e 2009/09/24
Babel v3.8l and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, german-x-2009-06-19, ngerman-x-2009-06-19, ancientgreek, ibycus, ar
abic, basque, bulgarian, catalan, pinyin, coptic, croatian, czech, danish, dutc
h, esperanto, estonian, farsi, finnish, french, galician, german, ngerman, mono
greek, greek, hungarian, icelandic, indonesian, interlingua, irish, italian, ku
rmanji, latin, latvian, lithuanian, mongolian, mongolian2a, bokmal, nynorsk, po
lish, portuguese, romanian, russian, sanskrit, serbian, slovak, slovenian, span
ish, swedish, turkish, ukenglish, ukrainian, uppersorbian, welsh, loaded.
(/usr/local/texlive/2009/texmf-dist/tex/latex/base/report.cls
Document Class: report 2007/10/19 v1.4h Standard LaTeX document class
(/usr/local/texlive/2009/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2009/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/local/texlive/2009/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2009/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/local/texlive/2009/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
(/usr/local/texlive/2009/texmf-dist/tex/xelatex/xetexconfig/geometry.cfg))
No file file587f83cb.aux.
*geometry auto-detecting driver*
*geometry detected driver: dvips*

Overfull \hbox (1.14412pt too wide) in paragraph at lines 9--23
 [] 
[1] (./file587f83cb.aux)


LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.

 )
(see the transcript file for additional information)
Output written on file587f83cb.dvi (1 page, 1620 bytes).
Transcript written on file587f83cb.log.
sh: xdvi: command not found



I believe there is something in the latex help page in the rms package 
that talks about preview difficulties on MAC.


--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] ICD9 codes

2010-05-29 Thread Kevin E. Thorpe
 codes
verification and manipulation.

Thanks
Vishwanath




--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] R eat my data

2010-05-25 Thread Kevin E. Thorpe
When I encounter problems like this, I make sure each row has the 
expected number of columns.  Something like the following awk code is 
useful.


awk -F\t '{print NF}' id_name_gh5.txt | sort | uniq -c

Note: I'm not sure is the \t will work with the -F switch as above.

Kevin

Changbin Du wrote:

c...@nuuk:~/operon$ grep '^#' id_name_gh5.txt
c...@nuuk:~/operon$

no lines starts with #



On Tue, May 25, 2010 at 9:11 AM, Barry Rowlingson 
b.rowling...@lancaster.ac.uk wrote:


On Tue, May 25, 2010 at 4:42 PM, Changbin Du changb...@gmail.com wrote:

HI, Dear R community,

My original file has 1932 lines, but when I read into R, it changed to

1068

lines, how comes?


c...@nuuk:~/operon$ wc -l id_name_gh5.txt
1932 id_name_gh5.txt



gene_name-read.table(/home/cdu/operon/id_name_gh5.txt, sep=\t,

skip=0, header=F, fill=T)

dim(gene_name)

[1] 10683



 Do any of your lines start with a #?


read.table(test.txt,sep=\t)

 V1
1 line 1
2 line 2
3 line 3
4 line 4


read.table(test.txt,comment.char=,sep=\t)

  V1
1  line 1
2  #commented
3  line 2
4  line 3
5 #nother comment
6  line 4

 just a guess. hard to tell without the file...

Barry








--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] BRugs under Linux?

2010-05-17 Thread Kevin E. Thorpe

Hello.

In this post:

http://finzi.psych.upenn.edu/Rhelp10/2010-March/233815.html

Uwe Ligges suggests using BRugs rather than R2WinBUGS under windows.  He 
also notes that it is not in the main CRAN repository, but it is in 
extras which is a default repository under windows.


I have OpenBUGS 3.1.0 (the latest that has a native Linux version  which 
is no longer called linBUGS) installed on my Linux box and would like to 
interact with it from R.  I see posts on this from 2009, but these 
predate the 3.1.0 version, so I'm wonering if there is anything new here.


Is BRugs the recommended approach from Linux?  If so, the required 
repository is not a default on my installation.  What is the address of 
the repository where this will be found?  If BRugs is not the best 
solution from Linux, can anyone suggest a better alternative?


Note that I also know about jags and have that installed also, but until 
I become a bit more familiar with this software I'm starting from BUGS.


Kevin

--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] sample size for survival curves

2010-05-06 Thread Kevin E. Thorpe

array chip wrote:

Dear R users, I am not asking questions specifically on R, but I know there are 
many statistical experts here in the R community, so here it goes my questions:

Freedman (1982) propose an approximation of sample size/power calculation based 
on log-rank test using the formula below (This is what nQuery does):
 (Z(1-α/side)+Z(power))^2*(hazard.ratio+1)^2
  N  =  -
 (2-p1-p2)*(hazard.ratio-1)^2

Where Z is the standard normal cumulative distribution. p1 and p2 are the 
survival probability of the 2 groups at a given time, say t.

As you can see, the sample size depends on the survival probabilities, p1 and 
p2. This is where my question lies. Let’s say we have 2 survival curves. I can 
choose p1 and p2 at time 1 year, and calculate a sample size. I can also choose 
p1 and p2 at time 5 years (still the same hazard ratio since the same 2 
survival curves), and calculate a different sample size. How to interpret the 2 
estimates of sample size?

This problem doesn’t occur when we calculate the number of events required 
using this formula:
   4*( Z(α/side)+Z(power))^2
  --
 (log(hazard.ratio))^2

Because number of events required only depends on hazard ratio.

Thanks for any suggestions.

John


As I recall, the survival probability used in Freedman is not at some 
arbitrary time of your choosing, but rather at the average length of 
follow-up time anticipated in the study.


Kevin

--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] 1 - Survival Plot

2010-03-25 Thread Kevin E. Thorpe

Euphoria wrote:

Hi all!

I have created survival vs. time plots. Now I would like to plot (1 -
Survival) vs. time.
Is there a way for me to retrieve the survival estimate information, to
which I can manually make an adjustment (ie; failure = 1 - survival) before
I re-plot this information?

Here is the code I use to attain the survival vs. time plot:

plot (survfit (Surv(DTDMRS3, DMRS3) ~ RS2540477, data = wise),
lty = 1:2:3, mark.DTDMRS3 = 0, ylab = Probability, xlab = Survival 
Time
in Days)
legend(200, 0.2, legend = c (CC, TC, TT), lty = c(3, 2, 1), title
LAT4H)

Thanks!


In the help file for plot.survfit you can read about the fun argument. 
fun=event does what you want.


--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] R on Linux - a primer

2010-03-16 Thread Kevin E. Thorpe

Axel Urbiz wrote:

Hi,

I'm looking to move from Windows into a 64-bit Linux environment. Which is
the best Linux Flavor to use within R? To install R on this environment, do
I need to do any compiling?

Thanks all!

Axel.



You have received a number of useful replies.  I will add my 2 cents as 
well.


First, make sure the distribution you choose does have a 64 bit version, 
since that is what you are looking for.  That said, allow me to share my 
Linux philosophy.


There are many distributions out there, each with their pluses and 
minuses.  For example, I used SuSE and OpenSuSE for awhile.  It was good 
in that things worked out of the box, and it has (had?) a good 
sysadmin tool.  The problem was, if I needed to compile stuff, the tools 
for development were not included in the default install, so I had to 
search for them (a full install may have fixed this, but the full 
install was really bloated).


Most of the popular distributions come with some kind of sysadmin tool. 
 This is a useful thing for someone totally new to Linux.  It can be 
frustrating if you decide on a new distribution, since the sysadmin 
stuff will look different.


I eventually moved away from OpenSuSE because the life cycle of 
supported versions was quite short.  I don't like being forced to 
re-install a new OS just to get the latest patches.  So, I moved to 
Slackware (they have a 64 bit version now BTW).  I love it, but it's not 
for everybody.  The biggest obstacle to most people is that it has no 
sysadmin tool.  It is your responsibility to edit the config files in a 
text editor, if you want to fine-tune or customize things.  It is your 
responsibility to do dependency checking when installing packages (this 
is a plus in that when you install something and something breaks, you 
know what to blame).  This means you need to invest some time and learn 
a little more Linux than other distributions forces you to learn.  The 
full install is not bloated and comes with all the development tools 
needed.  I always compile R from source and it is easy.


./configure
make
su
make install

In closing (congratulations if you've read this far), there is probably 
not a wrong choice of Linux to run R on.  Choose a flavour of Linux that 
you like.  Many distributions have Live versions.  These are versions 
that boot and run from your DVD drive.  It's a good way to get a feeling 
for a particular distribution without installing anything.


--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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 on getting help from manuals

2010-03-12 Thread Kevin E. Thorpe

Claudia Beleites wrote:

ManInMoon wrote:

Hi,

A number of people have suggested I read the manuals...

Could someone help me by telling me where the primary start point is 
please?

In R, type
help.start ()
this should open a browser window with links to
- the packages
- the manuals
- a search engine
Please note: this is written in section 1.7 Getting help with functions 
and features of Introduction to R

In the same section, you learn about
help.search

Note also:
? help
leads you to the man page describing the help system. In section see 
also you find a list of other useful commands to find help


If you look them up and look a again what alternatives they suggest and 
actually try them out (again with topic help) you will come across all 
informations about finding help on R topics that is written in this email.



- There also exists apropos ().
- In addition, e.g. reading this mailing list, you learn about the sos 
package.

- You can also use the internet resources: on r-project.org - manuals

- I personally use a lot:
http://finzi.psych.upenn.edu/cgi-bin/namazu.cgi (which is where 
RSiteSearch () gets you). You can nicely decide where to search: 
documentation of R and CRAN packages, and/or the mailing list archives.


Homework try out  read the results of:
RSiteSearch (help)



For example, I am interested in writing functions with variable number of
arguments - where should I start to look?

An introduction to R only show a brief example - with no pointer to 
where

to find further data.

I can't do ?xxx from R console in most cases - as I don't know what the
function name is that I am looking for!!!

Then do
??xxx
or
???xxx (needs sos)
or
RSiteSearch (xxx)
or
apropos (xxx)
...
which you could have found out by reading
? help




People have helped me find substitute to get some metadata out - BUT 
how

could I have found that without guidance from nice people in Nabble?

Any help on this very much appreciated.


Sometimes it _is_ difficult to find the correct search terms.
However, I think that people in this list will appreciate if you
- show that you did search before asking, and also tell then with which 
terms you did the search

- particularly for questions about the meaning of commands:
  Try them out!
  Put the command into pieces and look what each piece does
- people will appreciate if you ask what the correct search terms are 
for your problem (as opposed to ask them doing your homework)
  Learning R is learning a language. Including vocabulary (i.e. terms 
for the different concepts).
  Asking for help with searching is like asking How do you say in R for 
concept xyz? instead of Could anyone do the translation I got as 
homework?


HTH,

Claudia





This is all great advice for you ManInMoon.  One additional comment. 
When you have read the help page and don't understand something.  You 
will get far better answers here to explain what you have tried and what 
you don't understand.  Failure to do that makes it appear that you are 
too lazy to be bothered to try and solve your problems.  I'm not saying 
you are, it's how it appears (hence my terse reply the other day).


Also, at the bottom of every r-help email is a link to the Posting 
Guide.  Following the instructions there, for example, creating a toy 
example that illustrates your problem is often very useful in helping 
you solve the problem without posting a question.


I hope this helps.

--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] Deltas or changes

2010-03-10 Thread Kevin E. Thorpe

ManInMoon wrote:

Hi, I am new to R.

What does a negative amount in an index do?

i.e. x[-lenght[x]]
  

Why don't you try it and see for yourself?

--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] Deltas or changes

2010-03-10 Thread Kevin E. Thorpe

ManInMoon wrote:

Because I am asking for help...

  
In the time it has taken for you to ask your question and wait for 
answers, you could have experimented yourself and actually learned 
something.   The only way you will learn the language is to actually try 
using the language.



On 10 March 2010 20:19, Kevin E. Thorpe [via R] 
ml-node+1587986-1699461774-180...@n4.nabble.comml-node%2b1587986-1699461774-180...@n4.nabble.com
  

wrote:



  

ManInMoon wrote:


Hi, I am new to R.

What does a negative amount in an index do?

i.e. x[-lenght[x]]

  

Why don't you try it and see for yourself?





--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] how to make R plot under Linux

2010-02-22 Thread Kevin E. Thorpe

xin wei wrote:

thank you for reply. I just type: hist(x) from SSH terminal, expecting a
histogram to pop up like what i got under windows.instead I got the
following error msg:

Error in X11(d$display, d$width, d$height, d$pointsize, d$gamma,
d$colortype,  : 
  unable to start device X11cairo

In addition: Warning message:
In function (display = , width, height, pointsize, gamma, bg,  :
  unable to open connection to X11 display ''

Would you give some clues what is going on?

thanks




Did you start ssh with the -X switch?

--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] how to make R plot under Linux

2010-02-22 Thread Kevin E. Thorpe

K. Elo wrote:

Hi!

22.02.2010 19:53, xin wei wrote:

hi, Kevin and K.Elo:
thank you for the suggestion. Can you be more specific on these? (like how
exactly get into x-switch or man ssh). I am totally ignorant about linux and
SSH:( Memory limitation forces me to switch from windows to Linux
cluster.


Could you provide us with more information about the software you use
for establishing the ssh connection (i.e. your ssh client). I suppose
you are connecting a linux server (having R on it) from a windows
system, aren't you? And you use a ssh client software, right? There
should be an enable X11 forwarding (or something similar) option in
your ssh client application. You should look e.g. in connection settings.

Kind regards,
Kimmo


Agree.  Sounds like you are using a client on Windows.  Also, Vojtech 
Zeisek's reply is pertinent too.


--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] Fonts in X11(type=Xlib): Was: What font exactly is tkrplot looking for

2010-02-04 Thread Kevin E. Thorpe

Kevin E. Thorpe wrote:

Hello.

I am getting an error thrown from tkrplot.  It is

X11 font -adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*, face 1 at size 12 
could not be loaded


  sessionInfo()
R version 2.10.1 Patched (2009-12-29 r50852)
i686-pc-linux-gnu

locale:
 [1] LC_CTYPE=en_US   LC_NUMERIC=C LC_TIME=en_US
 [4] LC_COLLATE=C LC_MONETARY=CLC_MESSAGES=en_US
 [7] LC_PAPER=en_US   LC_NAME=CLC_ADDRESS=C
[10] LC_TELEPHONE=C   LC_MEASUREMENT=en_US LC_IDENTIFICATION=C

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

other attached packages:
[1] tkrplot_0.0-18TeachingDemos_2.5

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

I know this means tkrplot can't find the font it's looking for.  I have 
that font family available as 75dpi (according to xfontsel).  Is it 
looking for the 100dpi version?


I'm pretty sure I have the necessary fonts.  I just may need to tell X 
where they are, so I'm wondering exactly which font(s) are being requested.


Thanks.



Luke Tierney (maintainer of tkrplot) informed me that this is coming 
from X11(type=Xlib).  Sure enough, if I do


 X11(type=Xlib)
 plot(sin,-pi,pi)
Error in axis(side = side, at = at, labels = labels, ...) :
  X11 font -adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*, face 1 at size 
12 could not be loaded


Also,

 X11Fonts()
$serif
[1] -*-times-%s-%s-*-*-%d-*-*-*-*-*-*-*

$sans
[1] -*-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*

$mono
[1] -*-courier-%s-%s-*-*-%d-*-*-*-*-*-*-*

On my OS (Slackware 12.2) I get the following (long) output from 
xlsfonts.  So, these are all 75dpi fonts.  Is X11(type=Xlib) looking 
for 100dpi or something else?


xlsfonts -fn *helvetica*
-adobe-helvetica-bold-o-normal--10-100-75-75-p-60-iso10646-1
-adobe-helvetica-bold-o-normal--10-100-75-75-p-60-iso10646-1
-adobe-helvetica-bold-o-normal--10-100-75-75-p-60-iso8859-1
-adobe-helvetica-bold-o-normal--10-100-75-75-p-60-iso8859-1
-adobe-helvetica-bold-o-normal--10-100-75-75-p-60-iso8859-10
-adobe-helvetica-bold-o-normal--10-100-75-75-p-60-iso8859-10
-adobe-helvetica-bold-o-normal--10-100-75-75-p-60-iso8859-13
-adobe-helvetica-bold-o-normal--10-100-75-75-p-60-iso8859-13
-adobe-helvetica-bold-o-normal--10-100-75-75-p-60-iso8859-14
-adobe-helvetica-bold-o-normal--10-100-75-75-p-60-iso8859-14
-adobe-helvetica-bold-o-normal--10-100-75-75-p-60-iso8859-15
-adobe-helvetica-bold-o-normal--10-100-75-75-p-60-iso8859-15
-adobe-helvetica-bold-o-normal--10-100-75-75-p-60-iso8859-2
-adobe-helvetica-bold-o-normal--10-100-75-75-p-60-iso8859-2
-adobe-helvetica-bold-o-normal--10-100-75-75-p-60-iso8859-3
-adobe-helvetica-bold-o-normal--10-100-75-75-p-60-iso8859-3
-adobe-helvetica-bold-o-normal--10-100-75-75-p-60-iso8859-4
-adobe-helvetica-bold-o-normal--10-100-75-75-p-60-iso8859-4
-adobe-helvetica-bold-o-normal--10-100-75-75-p-60-iso8859-9
-adobe-helvetica-bold-o-normal--10-100-75-75-p-60-iso8859-9
-adobe-helvetica-bold-o-normal--12-120-75-75-p-69-iso10646-1
-adobe-helvetica-bold-o-normal--12-120-75-75-p-69-iso10646-1
-adobe-helvetica-bold-o-normal--12-120-75-75-p-69-iso8859-1
-adobe-helvetica-bold-o-normal--12-120-75-75-p-69-iso8859-1
-adobe-helvetica-bold-o-normal--12-120-75-75-p-69-iso8859-10
-adobe-helvetica-bold-o-normal--12-120-75-75-p-69-iso8859-10
-adobe-helvetica-bold-o-normal--12-120-75-75-p-69-iso8859-13
-adobe-helvetica-bold-o-normal--12-120-75-75-p-69-iso8859-13
-adobe-helvetica-bold-o-normal--12-120-75-75-p-69-iso8859-14
-adobe-helvetica-bold-o-normal--12-120-75-75-p-69-iso8859-14
-adobe-helvetica-bold-o-normal--12-120-75-75-p-69-iso8859-15
-adobe-helvetica-bold-o-normal--12-120-75-75-p-69-iso8859-15
-adobe-helvetica-bold-o-normal--12-120-75-75-p-69-iso8859-2
-adobe-helvetica-bold-o-normal--12-120-75-75-p-69-iso8859-2
-adobe-helvetica-bold-o-normal--12-120-75-75-p-69-iso8859-3
-adobe-helvetica-bold-o-normal--12-120-75-75-p-69-iso8859-3
-adobe-helvetica-bold-o-normal--12-120-75-75-p-69-iso8859-4
-adobe-helvetica-bold-o-normal--12-120-75-75-p-69-iso8859-4
-adobe-helvetica-bold-o-normal--12-120-75-75-p-69-iso8859-9
-adobe-helvetica-bold-o-normal--12-120-75-75-p-69-iso8859-9
-adobe-helvetica-bold-o-normal--14-140-75-75-p-82-iso10646-1
-adobe-helvetica-bold-o-normal--14-140-75-75-p-82-iso10646-1
-adobe-helvetica-bold-o-normal--14-140-75-75-p-82-iso8859-1
-adobe-helvetica-bold-o-normal--14-140-75-75-p-82-iso8859-1
-adobe-helvetica-bold-o-normal--14-140-75-75-p-82-iso8859-10
-adobe-helvetica-bold-o-normal--14-140-75-75-p-82-iso8859-10
-adobe-helvetica-bold-o-normal--14-140-75-75-p-82-iso8859-13
-adobe-helvetica-bold-o-normal--14-140-75-75-p-82-iso8859-13
-adobe-helvetica-bold-o-normal--14-140-75-75-p-82-iso8859-14
-adobe-helvetica-bold-o-normal--14-140-75-75-p-82-iso8859-14
-adobe-helvetica-bold-o-normal--14-140-75-75-p-82-iso8859-15
-adobe-helvetica-bold-o-normal--14-140-75-75-p-82-iso8859-15
-adobe-helvetica-bold-o-normal--14-140-75-75-p-82-iso8859-2
-adobe-helvetica-bold-o-normal

[R] What font exactly is tkrplot looking for

2010-02-03 Thread Kevin E. Thorpe

Hello.

I am getting an error thrown from tkrplot.  It is

X11 font -adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*, face 1 at size 12 
could not be loaded


 sessionInfo()
R version 2.10.1 Patched (2009-12-29 r50852)
i686-pc-linux-gnu

locale:
 [1] LC_CTYPE=en_US   LC_NUMERIC=C LC_TIME=en_US
 [4] LC_COLLATE=C LC_MONETARY=CLC_MESSAGES=en_US
 [7] LC_PAPER=en_US   LC_NAME=CLC_ADDRESS=C
[10] LC_TELEPHONE=C   LC_MEASUREMENT=en_US LC_IDENTIFICATION=C

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

other attached packages:
[1] tkrplot_0.0-18TeachingDemos_2.5

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

I know this means tkrplot can't find the font it's looking for.  I have 
that font family available as 75dpi (according to xfontsel).  Is it 
looking for the 100dpi version?


I'm pretty sure I have the necessary fonts.  I just may need to tell X 
where they are, so I'm wondering exactly which font(s) are being requested.


Thanks.

--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] An R vs. SAS Discrepancy: How do I determine which is correct?

2009-12-01 Thread Kevin E. Thorpe

I was messing around with some data in R and SAS (the reason is
unimportant) fitting a multiple linear regression and got a
curious discrepancy.  The data set is too big to post, but if
someone wants it, I can send it.

So, here are the (partial) results:

From R:

Coefficients:
Estimate Std. Error t value Pr(|t|)
(Intercept) 61.114341.48065  41.275   2e-16 ***
sexWomen 2.911080.35753   8.1425e-16 ***
diabp0.206750.01504  13.746   2e-16 ***
age -0.080850.02088  -3.871 0.000110 ***

From SAS (sorry about word-wrap if it happens):

  Parameter Estimates

Parameter Standard
 Variable   Label DF EstimateError 
 t Value


 Intercept  Intercept  1 58.20326  1.57802 
   36.88
 SEXSEX1  2.91108  0.35753 
8.14
 DIABP  Diastolic BP mmHg  1  0.20675  0.01504 
   13.75
 AGEAge (years) at examination 1 -0.08085  0.02088 
   -3.87


  Parameter Estimates

 Variable   Label DF  Pr  |t|

 Intercept  Intercept  1.0001
 SEXSEX1.0001
 DIABP  Diastolic BP mmHg  1.0001
 AGEAge (years) at examination 10.0001

The curious thihs is that all parameter estimates agree except the
intercept.  In R I also computed the coefficients directly using
(X'X)^(-1) X' y and get the same coefficients as lm() have me.
Also, ols() in Design agrees with lm()

As far as I can tell, the data used in R and SAS are identical.  So,
whose answer is correct and how do I prove it?  Here's my sessionInfo
(yes, I know my version of R is oldish).

 sessionInfo()
R version 2.8.0 (2008-10-20)
i686-pc-linux-gnu

locale:
LC_CTYPE=en_US;LC_NUMERIC=C;LC_TIME=en_US;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=en_US;LC_PAPER=en_US;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US;LC_IDENTIFICATION=C

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

other attached packages:
[1] Design_2.2-0survival_2.35-4 Hmisc_3.6-0 lattice_0.17-25

loaded via a namespace (and not attached):
[1] cluster_1.12.0 grid_2.8.0

--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] An R vs. SAS Discrepancy: How do I determine which is correct?

2009-12-01 Thread Kevin E. Thorpe

Thanks to an insightful comment from Jeremy Miles, who politely
pointed out my thick-headed moment, I know what happened.

The sex variable was coded as 1/2 in the SAS data, but was a factor
in the R data and so became a properly coded dummy variable.

Sorry for the obvious question and answer.

Kevin E. Thorpe wrote:

I was messing around with some data in R and SAS (the reason is
unimportant) fitting a multiple linear regression and got a
curious discrepancy.  The data set is too big to post, but if
someone wants it, I can send it.

So, here are the (partial) results:

 From R:

Coefficients:
Estimate Std. Error t value Pr(|t|)
(Intercept) 61.114341.48065  41.275   2e-16 ***
sexWomen 2.911080.35753   8.1425e-16 ***
diabp0.206750.01504  13.746   2e-16 ***
age -0.080850.02088  -3.871 0.000110 ***

 From SAS (sorry about word-wrap if it happens):

  Parameter Estimates

Parameter Standard
 Variable   Label DF EstimateError 
 t Value


 Intercept  Intercept  1 58.20326  1.57802 
   36.88
 SEXSEX1  2.91108  0.35753 
8.14
 DIABP  Diastolic BP mmHg  1  0.20675  0.01504 
   13.75
 AGEAge (years) at examination 1 -0.08085  0.02088 
   -3.87


  Parameter Estimates

 Variable   Label DF  Pr  |t|

 Intercept  Intercept  1.0001
 SEXSEX1.0001
 DIABP  Diastolic BP mmHg  1.0001
 AGEAge (years) at examination 10.0001

The curious thihs is that all parameter estimates agree except the
intercept.  In R I also computed the coefficients directly using
(X'X)^(-1) X' y and get the same coefficients as lm() have me.
Also, ols() in Design agrees with lm()

As far as I can tell, the data used in R and SAS are identical.  So,
whose answer is correct and how do I prove it?  Here's my sessionInfo
(yes, I know my version of R is oldish).

  sessionInfo()
R version 2.8.0 (2008-10-20)
i686-pc-linux-gnu

locale:
LC_CTYPE=en_US;LC_NUMERIC=C;LC_TIME=en_US;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=en_US;LC_PAPER=en_US;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US;LC_IDENTIFICATION=C 



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

other attached packages:
[1] Design_2.2-0survival_2.35-4 Hmisc_3.6-0 lattice_0.17-25

loaded via a namespace (and not attached):
[1] cluster_1.12.0 grid_2.8.0




--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] From R to LaTeX to pdf?

2009-11-24 Thread Kevin E. Thorpe

Joel Fürstenberg-Hägg wrote:

Hi all,

 


Anyone experienced in the LaTeX format?

 


I'm trying to use the xtable package to create nice anova tables, but how do I 
do to produce a pdf from the resulting LaTeX table? I've tried WinShell and 
MiKTeX, but I couldn't get any of them working...

 


Here's an example of the output in R:

 


% latex table generated in R 2.9.2 by xtable 1.5-6 package
% Tue Nov 24 14:17:32 2009
\begin{tabular}{lr}
  \hline
  Df  Sum Sq  Mean Sq  F value  Pr($$F) \\ 
  \hline
cat  2  40.50  20.25  6.66  0.0019 \\ 
  Residuals  107  325.13  3.04 \\ 
   \hline

\end{tabular}


The output from xtable (above) is not a self-contained, complete
LaTeX file.  You need, at the very least, A \documentclass statement
at the beginning of the file and the code above needs to be inside a
\begin{document} ... \end{document} pair.

Then, the pdflatex (I beilieve this exists in MiKTeX) command builds
a pdf file.

Kevin



 


Best regards,

 


Joel



--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] Collapse factor levels

2009-11-01 Thread Kevin E. Thorpe

I'm sure this is simple enough, but an R site search on my subject
terms did suggest a solution.  I have a numeric vector with many
values that I wish to create a factor from having only a few levels.
Here is a toy example.

 x - 1:10
 x - 
factor(x,levels=1:10,labels=c(A,A,A,B,B,B,C,C,C,C))

 x
 [1] A A A B B B C C C C
Levels: A A A B B B C C C C
 summary(x)
A A A B B B C C C C
3 0 0 3 0 0 4 0 0 0

So, there are clearly still 10 underlying levels.  The results I would
like to see from printing the value and summary(x) are:

 x
 [1] A A A B B B C C C C
Levels: A B C
 summary(x)
A B C
3 3 4

Hopefully this makes sense.

Thanks,

Kevin

--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] Collapse factor levels

2009-11-01 Thread Kevin E. Thorpe

Peter Dalgaard wrote:

Kevin E. Thorpe wrote:

I'm sure this is simple enough, but an R site search on my subject
terms did suggest a solution.  I have a numeric vector with many
values that I wish to create a factor from having only a few levels.
Here is a toy example.

  x - 1:10
  x - 
factor(x,levels=1:10,labels=c(A,A,A,B,B,B,C,C,C,C))

  x
 [1] A A A B B B C C C C
Levels: A A A B B B C C C C
  summary(x)
A A A B B B C C C C
3 0 0 3 0 0 4 0 0 0

So, there are clearly still 10 underlying levels.  The results I would
like to see from printing the value and summary(x) are:

  x
 [1] A A A B B B C C C C
Levels: A B C
  summary(x)
A B C
3 3 4

Hopefully this makes sense.

Thanks,

Kevin



It's an anomaly inherited frokm S-PLUS (or so I have been told). 
Actually, with the current R, you should get a warning:


  x - 1:10
  x - 
factor(x,levels=1:10,labels=c(A,A,A,B,B,B,C,C,C,C))

Warning message:
In `levels-`(`*tmp*`, value = c(A, A, A, B, B, B, C,  :
  duplicated levels will not be allowed in factors anymore

This works (as documented on the help page for levels!):

  x - 1:10
  x - factor(x,levels=1:10)
  levels(x) - c(A,A,A,B,B,B,C,C,C,C)
  table(x)
x
A B C
3 3 4




Thanks.  That's exactly what I need.  I knew it was simple.
I've even used levels() before, but it just didn't occur to
me this time.  I'm clearly not on current R. :-)
When I have some time, I'll upgrade.

Kevin

--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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] Simple question, I think

2009-10-22 Thread Kevin E. Thorpe

David Kaplan wrote:

Greetings,

I am recoding a dummy variable (coded 1,0) so that 0 = 2.  I am using 
the line


sciach$dummyba[sciach$ba==0] - 2

I notice that it creates a new column dummyba, with 0 coded as 2 but 
with 1's now coded as NA.  Is there a simple way around this in the line 
I am using, or do I need to have an additional line


sciach$dummyba[sciach$ba==1] - 1

Thanks in advance.


David


Try sciach$dummyba - ifelse(sciach$ba==0,2,1)


--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
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 me...!!!

2009-05-26 Thread Kevin E. Thorpe

Is this homework?

If so, please read the posting guide and note the part about homework.
Specifically, Basic statistics and classroom homework:  R-help is not 
intended for these.


http://www.r-project.org/posting-guide.html


abel1682 wrote:

Hi to all...i'm a new R'user and i have to solve some exercies so i ask to
tou for an help...

1.) How i can demonstrate  in R that  the limit for x--infinite of
(1+1/x)^x is equal to e?
2.) if i have a vector of values how can i create a function that, applied
to my vector, give me median, mean, Var and length togheter?
3.)Find the minimum of this function: 
f(x)=(x-3)^4

with the Newton method.

4.) Define a function that is able to calculate the geometric mean of a
seriation:

Sorry for all these questions...
Thanks a lot!!!...



--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.6057

__
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] Call R from Perl

2009-05-06 Thread Kevin E. Thorpe

Daniel Fernandez wrote:

Hi,
I am trying to call R in my perl program but is not working. It does not
give an error but my program gets stuck indefinitely.

I am using the following command to call R from Perl

`R BATCH regressExpr.spl temp`;

Any suggestions?

Best,

Daniel F.



Does `R CMD BATCH regressExpr.spl temp` work?


--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.6057

__
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] Call R from Perl

2009-05-06 Thread Kevin E. Thorpe

Daniel Fernandez wrote:
I'm not sure but my guess is that part isn't working... is that the way 
to call R from perl?


It's the way I would call R in batch from the command line.  In your 
call you are missing the CMD part.




Sent from my iPhone

On May 6, 2009, at 8:09 AM, Kevin E. Thorpe kevin.tho...@utoronto.ca 
wrote:



Daniel Fernandez wrote:

Hi,
I am trying to call R in my perl program but is not working. It does not
give an error but my program gets stuck indefinitely.
I am using the following command to call R from Perl
`R BATCH regressExpr.spl temp`;
Any suggestions?
Best,
Daniel F.


Does `R CMD BATCH regressExpr.spl temp` work?




--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.6057

__
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] Difference between gam() and loess().

2009-03-20 Thread Kevin E. Thorpe

Ravi Varadhan wrote:
Good try, Kevin.  But that doesn't seem to do it. 


set.seed(123)

x - sort(runif(100))

y - sin(4*pi*x) + rnorm(100, sd=0.2)

ans.lo2 - loess(y ~ x, degree=2, span=0.75)

ans.gam2 - gam(y ~ lo(x, degree=2, span=0.75))

summary(ans.lo2$fitted - ans.gam2$fitted) # larger differences, about 10%

ans.lo1 - loess(y ~ x, degree=1, span=0.75)

ans.gam1 - gam(y ~ lo(x, degree=1, span=0.75))

summary(ans.lo1$fitted - ans.gam1$fitted) # smaller differences, about 2-5 
percent

I also tried a number of other things including changing the family, and parameters in 
loess.control, but to no avail.  I looked at the Fortran codes from both loess and gam. 
 They are daunting, to say the least. They are dense, and there are absolutely no comments 
whatsoever.  But one thing is clear - they are using different Fortran codes.

So, the best bet might be to get Trevor Hastie or Bill Cleveland to help you out.  


But, before that:  why is this an issue, Rolf?  Is it important that these two 
results be identical?

Best,
Ravi.



There was one other thing I found that I shared with Rolf off-list.
In loess.control() there is an iterations argument which is related
to the robustness of the estimates.  I would think that could also
account for tail departures especially.

I don't gave the gam package installed, so can't test these myself
at the moment.




- Original Message -
From: Kevin E. Thorpe kevin.tho...@utoronto.ca
Date: Thursday, March 19, 2009 8:23 pm
Subject: Re: [R] Difference between gam() and loess().
To: Rolf Turner r.tur...@auckland.ac.nz
Cc: R-help Forum r-help@r-project.org



Rolf Turner wrote:
  
  It seems that in general
  
  gam(y~lo(x)) # gam() from the gam package.
  
  and

  loess(y~x)
  
  give slightly different results (in respect of the predicted/fitted 


  values).
  Most noticeable at the endpoints of the range of x.
  
  Can anyone enlighten me about the reason for this difference?
  
  Is it possible to twiddle the control parameters, for either or 
both 
  functions,

  so as to obtain identical results?
 
 There are two obvious differences in the defaults.  In lo() from the 
gam 
 package, span=0.5 and degree=1 while for loess(), span=0.75 and degree=2.
 
 Try gam(y~lo(x,span=0.75,degree=2)) and see if that helps.
 
 Kevin



--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.6057

__
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] Difference between gam() and loess().

2009-03-20 Thread Kevin E. Thorpe

Kevin E. Thorpe wrote:

Ravi Varadhan wrote:

Good try, Kevin.  But that doesn't seem to do it.
set.seed(123)

x - sort(runif(100))

y - sin(4*pi*x) + rnorm(100, sd=0.2)

ans.lo2 - loess(y ~ x, degree=2, span=0.75)

ans.gam2 - gam(y ~ lo(x, degree=2, span=0.75))

summary(ans.lo2$fitted - ans.gam2$fitted) # larger differences, about 10%

ans.lo1 - loess(y ~ x, degree=1, span=0.75)

ans.gam1 - gam(y ~ lo(x, degree=1, span=0.75))

summary(ans.lo1$fitted - ans.gam1$fitted) # smaller differences, about 
2-5 percent


I also tried a number of other things including changing the family, 
and parameters in loess.control, but to no avail.  I looked at the 
Fortran codes from both loess and gam.  They are daunting, to say the 
least. They are dense, and there are absolutely no comments 
whatsoever.  But one thing is clear - they are using different Fortran 
codes.


So, the best bet might be to get Trevor Hastie or Bill Cleveland to 
help you out. 
But, before that:  why is this an issue, Rolf?  Is it important that 
these two results be identical?


Best,
Ravi.



There was one other thing I found that I shared with Rolf off-list.
In loess.control() there is an iterations argument which is related
to the robustness of the estimates.  I would think that could also
account for tail departures especially.

I don't gave the gam package installed, so can't test these myself
at the moment.


Somehow when I read the above Ravi, I missed that you had fiddled with 
loess.contol() AND looked at the Fortran.


I guess one simple parameter change may not quite do it. :-)

Kevin






- Original Message -
From: Kevin E. Thorpe kevin.tho...@utoronto.ca
Date: Thursday, March 19, 2009 8:23 pm
Subject: Re: [R] Difference between gam() and loess().
To: Rolf Turner r.tur...@auckland.ac.nz
Cc: R-help Forum r-help@r-project.org



Rolf Turner wrote:
It seems that in general
gam(y~lo(x)) # gam() from the gam package.
and
  loess(y~x)
give slightly different results (in respect of the 
predicted/fitted

  values).
  Most noticeable at the endpoints of the range of x.
Can anyone enlighten me about the reason for this difference?
Is it possible to twiddle the control parameters, for either or 
both   functions,

  so as to obtain identical results?
 
 There are two obvious differences in the defaults.  In lo() from the 
gam  package, span=0.5 and degree=1 while for loess(), span=0.75 and 
degree=2.
 
 Try gam(y~lo(x,span=0.75,degree=2)) and see if that helps.
 
 Kevin






--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.6057

__
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] Difference between gam() and loess().

2009-03-19 Thread Kevin E. Thorpe

Rolf Turner wrote:


It seems that in general

gam(y~lo(x)) # gam() from the gam package.

and
loess(y~x)

give slightly different results (in respect of the predicted/fitted 
values).

Most noticeable at the endpoints of the range of x.

Can anyone enlighten me about the reason for this difference?

Is it possible to twiddle the control parameters, for either or both 
functions,

so as to obtain identical results?


There are two obvious differences in the defaults.  In lo() from the gam 
package, span=0.5 and degree=1 while for loess(), span=0.75 and degree=2.


Try gam(y~lo(x,span=0.75,degree=2)) and see if that helps.

Kevin

--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.6057

__
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.


  1   2   >